Package madkit.kernel
Class Madkit
java.lang.Object
madkit.kernel.Madkit
MaDKit 5 booter class.
MaDKit v.5 new features
- One big change that comes with version 5 is how agents are identified and
localized within the artificial society. An agent is no longer binded to a
single agent address but has as many agent addresses as holden positions in
the artificial society. see
AgentAddress
for more information. - With respect to the previous change, a
withRole
version of all the messaging methods has been added. SeeAbstractAgent.sendMessageWithRole(AgentAddress, Message, String)
for an example of such a method. - A replying mechanism has been introduced through
SendReply
methods. It enables the agent with the possibility of replying directly to a given message. Also, it is now possible to get the reply to a message, or to wait for a reply ( forAgent
subclasses only as they are threaded) SeeAbstractAgent.sendReply(Message, Message)
for more details. - Agents now have a formal state during a MaDKit session. See the
AbstractAgent.getState()
method for detailed information. - One of the most convenient improvement of v.5 is the logging mechanism
which is provided. See the
AbstractAgent.getLogger()
for more details. - Internationalization is being made (fr_fr and en_us for now).
- Since:
- MaDKit 4.0
- Version:
- 5.2
- Author:
- Fabien Michel, Jacques Ferber
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Option used to activate or disable features on startup.static enum
MaDKit options valued with a string representing aLevel
value.static enum
MaDKit options which are valued with a string representing parameters. -
Field Summary
-
Constructor Summary
-
Method Summary
-
Field Details
-
VERSION
-
BUILD_ID
-
WEB
-
-
Constructor Details
-
Madkit
Launch a new kernel with predefined options. The call returns when the new kernel has finished to take care of all options. Moreover the kernel automatically ends when all the agents living on this kernel are done.Here is an example of use:
public void somewhereInYourCode() { new Madkit(Option.launchAgents.toString(), // gets the --launchAgents string Client.class.getName() + ",true,20;" + Broker.class.getName() + ",true,10;" + Provider.class.getName() + ",false,20"); }
- Parameters:
options
- the options which should be used to launch Madkit. Ifnull
, the dektop mode is automatically used.- See Also:
-
-
Method Details
-
main
This main could be used to launch a new kernel using predefined options. The new kernel automatically ends when all the agents living on this kernel are done. So the JVM automatically quits if there is no other remaining threads. Basically this call just instantiates a new kernel like this:public static void main(String[] options) { new Madkit(options); }
So, this main can be used as a MAS application entry point in two ways :(1) From the command line:
For instance, assuming that your classpath is already set correctly:
>java madkit.kernel.Madkit agentLogLevel INFO --launchAgents madkit.marketorg.Client,20,true;madkit.marketorg.Broker,10,true;madkit.marketorg.Provider,20,true;
(2) It can be used programmatically anywhere, especially within main method of agent classes to ease their launch within an IDE.
Here is an example of how it can be used in this way:
public static void main(String[] args) { String[] argss = { LevelOption.agentLogLevel.toString(), "FINE", Option.launchAgents.toString(), // gets the // -- // launchAgents // string Client.class.getName() + ",true,20;" + Broker.class.getName() + ",true,10;" + Provider.class.getName() + ",false,20" }; Madkit.main(argss);// launching the application }
- Parameters:
options
- the options which should be used to launch Madkit: seeMadkit.LevelOption
,Madkit.BooleanOption
andMadkit.Option
-
doAction
Makes the kernel do the corresponding action. This is done by sending a message directly to the kernel agent. This should not be used intensively since it is better to control the execution flow of the application using the agents running in the kernel. Still it provides a way to launch and manage a kernel from any java application as a third party service.public void somewhereInYourCode() { ... Madkit m = new Madkit(args); ... m.doAction(KernelAction.LAUNCH_NETWORK); //start the network ... m.doAction(KernelAction.LAUNCH_AGENT, new Agent(), true); //launch a new agent with a GUI ... }
- Parameters:
action
- the action to requestparameters
- the parameters of the request. To work properly, the actual class of the parameters should match the class of the parameters of the underlying targeted method. For instance, for launching an Agent, one must usem.doAction(KernelAction.LAUNCH_AGENT, new Agent(),Boolean.TRUE);
That is, in this case, using "true" does not work since it is a String.
-
toString
-