Agents-based Commodity Market Simulation with Jade

A market of potato commodity for industry scale USAge is engaging several types of actors. They are farmers, middlemen, and industries. A multi-agent system has been built to simulate these actors into agent entities, based on manually given parameters within a simulation scenario file. Each type of agents has its own fuzzy logic representing actual actors' knowledge, to be used to interpreting values and take appropriated decision of it while on simulation. The system will simulate market activities with programmed behaviors then produce the results as spreadsheet and chart graph files. These results consist of each agent's yearly finance and commodity data. The system will also predict each of next value from these outputs.


Introduction
In potato commodity market, industries and farmers, as end buyer and raw producer respectively, hold big role in market activities that can give impact to each other.Industries need the farmers to fulfill their raw commodity requirement for continuous production.For industries, their production is vital activities to gain profit.At other side, farmers need to keep producing and sell their harvest revenue to have income.However, both farmers and industries are QRW WKH RQO\ RQH ³VHOOHU´ DQG ³EX\HU´ LQ PDUket.Middlemen hold those both two roles, positioning themselves a competitor to farmers and industries and gain profit from it.
In market competition, each actor's assets, knowledge, and behaviors can be different to others thus giving different measures on the same situation.A simulation system will help by simulating the market activities and the produce the data to see if their current conditions can give positive impact in achieving their goal.
Agent Oriented Programming (AOP) is one of the best approaches to declare actual actors as system entities, called agent, and simulate their actions [5].AOP offers several advantages like message based communication, multi-behaviors support, life cycle management, and more [2].The capability of agents can be improved by posing artificial intelligent backup to help them sense conditions of environment where they live and take appropriated actions regarding to it.Thus this type of agents are called intelligent agent [1].Users have to supply actors' knowledge and scenario to the system.The system will be limited to give output data as it is, without any conclusion.

Methodology
The methodology that is used consists four phases in order [2].Each phase has multiple steps inside them to be done in order too.The flow, phases, and steps of the methodology are illustrated in Fig 1.This methodology is used corresponding to JADE (Java Agent Development) library which is used to built system's architecture.JADE is Java based library with ACL (Agent Communication Language) that is defined by FIPA (Foundation for Intelligent Physical Agent) [8].In general, this ACL declares the messages per formative and VHUYLFH W\SH ³\HOORZ SDJLQJ´ DV EDVLF ZD\ IRU agents to communicate.
The methodology serves as a guide for the system designer when developing a system.In general, a software development methodology may comprise of [2,3,4,6]: 1.A process, i.e. a sequence of phases and steps that guide the developer in building the system.2. A set of heuristic rules that support the developer in making relevant choices.3. A number of artifacts, i.e. diagrams, schemas or documents representing in graphical or textual form one or more models of the system.4. A suitable notation to be used in the artifacts.5.A set of patterns that can be applied to solve common situations.6.One or more tools that: automate, as much as possible, the phases and step specified in the process; force consistency between the models produced; highlight problems arising from incorrect design choices, when possible; generate code and documentation, etc.
The focus of the methodology is on the process and the artifacts that are produced.The described process covers the analysis phase and the design phase and is shown in Fig. 1.The analysis phase is general in nature and independent of the adopted platform.Conversely, the design phase specifically assumes JADE as the implementation platform and focuses directly on the classes and concepts provided by JADE.Observing Fig. 1, it can be seen that there is no strict boundary between the analysis and design phases.Moreover, the methodology is of an iterative nature, thus allowing the designer to move back and forth between the analysis and design phases and the steps therein.
At the end of the design phase, the developer should be able to progress straight to the implementation, which is where the actual coding occurs.In addition, most of this phase can probably be carried out by means of a proper tool which automates the implementation process.The planning stage, like implementation and testing, is not formally addressed in the methodology.However, for the sake of the methodology, a question is included (see Fig. 1), which initially asks if the designer has made a rational decision on whether to use an agent-based solution.If the answer is yes, the designer moves on the analysis, while if the answer is no, the designer should seek an alternative solution.

Planning Phase
The system uses intelligent agent and Fuzzy logic is chosen as knowledge implementation since the actual actors may interpret some values into natural language.The fuzzy rules are written as FCL (Fuzzy Control Language) script and applied with help of jFuzzyLogic library and its built-in fuzzy inference system.The required input is simulation scenario describing some parameters including FCL scripts' location in form of spreadsheet file.At start, system will ask user to select this file in order to run.Finally, each agent will produce their finance and commodity data at the end of simulation, both in form of spreadsheet files (tabular) and picture files (charts) by using jExcel and jFreeChart libraries.

Analysis Phase
The Actual actors are represented by three kind of agents based on service they provide.Farmers, PLGGOHPHQ DQG LQGXVWULHV DUH ³3URGXVHQ$JHQW´, ³'LVWULEXWRU$JHQW´ DQG ³.RQVXPHQ$JHQW´ agents respectively.Since the system needs to access the external resource scenario and FCL files, a transducer agent that not representing actual actorV ³0DLQ$JHQW´ LV FUHDWHG )LJ shows relation between these agents kind.$JHQW ¶V task can be seen in the Table I.

Design Phase
This phase offers chance to improve agents relation and interaction protocol in case FIPA doesn't cover the need.After specify agents relation, a interaction specification table including messages template is made as shown in Table II.All capitalized word refers to messages per formative.To interact with user, the system has its own graphical user interface (GUI) showing finance and commodity charts.The GUI also shows some agent's actions log for debugging case and agent's current status as described in stock, money, and field values.User gives the scenario input through ³0DLQ$JHQW´.The scenario file has two sections of parameters.The first section as described on Table III is used to determine how the simulation will work globally.A scenario file only has one of these sections.
The second section is used to give parameters to agent.This section can appear multiple times in one scenario file.The number of this section must be specified at the start of scenario, in other words first global parameter.The section is described in Table IV.
Each agent has some instance of JADE's Behavior class to describe an action of actual actor into algorithm.These behaviors can be executed in parallel or sequence depends on the need.The lists of behaviors representing actual DFWRUV ¶ actions are mentioned by Table V.
Beside those behaviors, there are some which aren't representing actual actors' actions.These behaviors are related to agents' activities like calculate date and pool received message.They are listed in Table VI.
For ontology, the system will use object serialization as its protocol.To do this, some classes which will be content language like Price, Offer, and Seed have to implement Serializable interface.Instance of these classes will be set to ACLMessage before sent.ACLMessage itself is JADE's class that support performative and object use as content rather plain string.

Implementation and Testing Phase
A test is performed by using a dummy scenario and three kinds of knowledge bases, one for each type of agents.The scenario specifies six block specification for six agents (one block per agent) and put them in group of two.Therefore each type of agents has two agents instance and shares same knowledge base.The complete list of scenario can be seen in Table VII.This table uses scenario's dummy values for test (following [7]).Note that this table doesn't represent how to write them on the actual scenario file because there's difference in format.In order to optimize, several operation parameters for Java Virtual Machine (JVM) and JADE class loader are given as listed in Table VIII.The results of simulation for two agents of ³3URGXVHQ$JHQW´ DUH VKRZQ LQ ILJXUHV ± 11.Fig. 6 shows complete GUI of the agents and commodity charts at same time.The finance charts hidden inside the scroll area can be seen in Fig. 7.
The results of simulation for two agents of ³'LVWULEXWRU$JHQW´ DUH VKRZQ ERWK LQ FRPPRGLW\ (Fig. 8) and in finance (Fig. 9) charts too.For additional test, the system is also strained by simulating some numbers of agents instances (Table IX), including previous dummy test as test no.I.This is conducted to see how well the system's performance is.Table X shows specification of the testing machine where all test performed.Memory and processor (CPU) usages that are used during the are listed by Table XI.

Conclusions
The built system can run simulation based on given scenario then produce output each agent's yearly finance and commodity data in form of spreadsheet and chart graph files.The system is also able to add additional value for spreadsheet files as prediction.The output is limited to raw data without any further analysis or conclusions, which are expected to come from appropriate market experts.Inheriting advantage of agent based application, system extension efforts like adding new agents or new behaviors is possible.For further research, some steps can be taken like implementing self adapting logic, performance optimization, and improvement for better quality of results.

Fig 2 .
Fig 2. Use Case Diagram between Farmers and Middlemen

Fig 4 .
Fig 4. Use Case Diagram between Middlemen and Industries

TABLE I TASKS
Harvest Respond to commodity request Respond to pledge deal Offer own commodity Search highest price for commodity Give harvest revenue to pledge dealer DistributorAgent Sort commodity according to its standard Respond to commodity offers Respond to price request Respond to commodity giving Respond to commodity request Offer own commodity KonsumenAgent Perform monthly production Sort commodity according to its standard Respond to commodity offers Respond to price request Respond to commodity giving Make pledge deal with ProdusenAgent Request for commodity MainAgent Load scenario file Parse scenario's parameters Do the dating count Synchronize date to all active agents

TABLE IX .
NUMBER OF AGENT ¶S INSTANCES FOR STRAIN TEST