An Agent-Based CoEvolutionary Multi-Objective Algorithm for Portfolio Optimization

Algorithms based on the process of natural evolution are widely used to solve multi-objective optimization problems. In this paper we propose the agent-based co-evolutionary algorithm for multi-objective portfolio optimization. The proposed technique is compared experimentally to the genetic algorithm, co-evolutionary algorithm and a more classical approach—the trend-following algorithm. During the experiments historical data from the Warsaw Stock Exchange is used in order to assess the performance of the compared algorithms. Finally, we draw some conclusions from these experiments, showing the strong and weak points of all the techniques.


Introduction
The portfolio optimization problem is very important for every investor willing to risk their money in order to obtain potential benefits exceeding the average rate of profit of the capitalist economy.Before the 1950s, investors relied on common sense, experience or even premonitions in order to construct their portfolios.Then, some theories establishing the relation between the risk and the potential return of the investment were formulated [1].Finally, the investors had solid tools at hand to ease the complex process of investing their money.Obviously, the proposed theories could not make each of us a millionaire-they are merely used as a yet another source of analytic information that can be taken into consideration.
In this paper we propose the agent-based co-evolutionary multi-objective algorithm for portfolio optimization and we will compare the quality of its solutions to the those obtained with the use of evolutionary, co-evolutionary and trend-following algorithms.
Two groups of experiments were carried out.In the first experiment, data from the year 2010a year of moderate stock market rises-was used.In the second experiment, data was used from the year 2008, which was an extremely difficult time for investors-the Warsaw Stock Exchange (WSE) WIG20 index (WIG20 is the capitalization-weighted stock market index of the twenty largest companies on the Warsaw Stock Exchange) lost over 47% in value.The model of co-evolutionary multi-agent system (CoEMAS), developed in our previous papers, allows for using many different biologically and socially inspired computation and simulation techniques and algorithms within one coherent agent-based system.Such techniques can be introduced in a very natural way because of the decentralized character of the CoEMAS model.They can also be combined together on the basis of the agent-based approach, eventually causing a synergistic effect and emergent phenomena to appear during experiments.
Thanks to the possibilities of introducing the co-evolutionary interaction and sexual selection mechanisms, we have techniques for maintaining population diversity, which are very important in the case of multi-modal optimization and multi-objective optimization problems.One such mechanism, based on the co-evolution of sexes and the sexual selection, is proposed in this paper.The multi-objective portfolio optimization problem is used as a testbed for assessing the agent-based co-evolutionary multi-objective algorithm and the proposed technique for maintaining population diversity.This is of course only a small fragment of much broader research aiming at the formulation of a general model of agent-based systems for computing and simulation, utilizing biologically and socially inspired techniques and algorithms.
The rest part of the paper is organized as follows.First, we will introduce basic concepts of multi-objective optimization and agent-based evolutionary algorithms and we will present related research on applications of the bio-inspired techniques to financial and economic problems.In the next part of the paper the evolutionary algorithm, the co-evolutionary algorithm, and the proposed agent-based co-evolutionary algorithm are presented.Also, the trend-following technique used as a reference point in our experiments is described.The last part of the paper includes the results of two types of experiments, discussion of the results, and conclusions.

Multi-Objective Optimization
The main goal of continuous optimization is to find the very best solution from a most likely infinite set of possible solutions.The optimization procedure relies on finding and comparing feasible solutions until no better solution can be found.Each solution can be classified as a good or a bad one in terms of the specific objective we are interested in.For example, we could define an objectives in terms of costs of fabrication, efficiency of a technological process, etc.In the case of multi-objective optimization, as opposed to single-objective optimization, there is no clearly defined optimum.Instead, we have to deal with a set of trade-off optimal solutions.They are generally known as Pareto-optimal solutions [2].
The vast majority of the real-world problems involve more than one objective.That is why it is so crucial to develop methods that can efficiently solve this type of optimization problem [2,3].
The multi-objective optimization problem (MOOP) deals with more than one objective function.It turns out that the objectives are most likely contradictory, which makes the MOOP difficult to solve.In fact, it is the most common situation we will ever encounter.Following [3], the formal definition of the MOOP is as follows: Minimize/Maximize f m ( x), m = 1, 2, . . ., M Subject to g j ( x) ≥ 0, j = 1, 2, . . ., J h k ( x) = 0, k = 0, 1, . . ., K x (L) i The constraints and bounds (g j (x), and h k (x) are the constraint functions) constitute a decision space (set D) [3].Any solution that satisfies all the constraints and bounds is called the feasible solution [3].
Because in the case of multi-objective problems there are many minimized/maximized criteria, we have to somehow indicate which solution is better than the other one.In order to avoid converting the minimization to maximization (or the maximization to minimization) problems, the additional operator has to be defined-notation f i ( x1 ) f i ( x2 ) indicates that the solution x1 is better than the solution x2 for the objective f i (regardless of whether the criterion f i is minimized or maximized).Now, the dominance relation can be defined-it is said that the solution xA dominates the solution xB ( xA ≺ xB ) if and only if [2]: A solution is non-dominated when it is not dominated by any other solution of a given problem.A solution in the Pareto sense of the multi-objective optimization problem is a set of all non-dominated alternatives from the set D. The set of all non-dominated solutions (see Figure 1) can be then presented to a human decision-maker who chooses one of them.
The main difference between these two groups of techniques is the utilization of the so-called elite-preserving operators.Thanks to the elite-preserving techniques the best individuals can be directly transferred to the next generation, omitting the actual selection mechanism.Of course there is a rotation within the elite set-if the algorithm finds a better solution then it replaces one of the individuals from the elite.

Maintaining Population Diversity in Evolutionary Multi-Objective Algorithms
Maintaining population diversity and introducing speciation are two very important issues in the case of evolutionary algorithms.Techniques used for obtaining these goals are called niching (or speciation) mechanisms.
Maintaining population diversity and finding many different solutions through the use of niching techniques are very important in the case of multi-modal optimization problems and of course also in the case of multi-objective optimization problems, since we are interested in finding all non-dominated solutions-the whole Pareto frontier should be evenly "covered" by the individuals.
The niching techniques allow for finding multiple solutions (forming sub-populations or species of individuals) via the modification of the mechanism of selecting individuals for a new generation (crowding model [23]), a modification of the parent selection mechanism (fitness sharing technique [24] or sexual selection mechanism [25]).Other possibilities include limited application of the selection and/or the recombination mechanisms (by explicit grouping of individuals into sub-populations [26] or by introducing the environment, in which the individuals are located and which restricts the possibilities of recombination [27,28]).Some of the above techniques were used in the multi-objective evolutionary algorithms.For example the fitness-sharing technique was used in Hajela and Lin genetic algorithms for multi-objective optimization based on weighting method [29].Fitness sharing was also used by Fonseca and Fleming in their multi-objective genetic algorithm using a Pareto-based ranking procedure [21].In the niched Pareto genetic algorithm (NPGA) [19] the fitness-sharing mechanism was used in the objective space during the tournament selection (when the mechanism based on the domination relation failed to choose the winner).In the case of a non-dominated sorting genetic algorithm (NSGA) [20] fitness sharing is used within each set of non-dominated individuals separately in order to maintain the population diversity.In the strength Pareto evolutionary algorithm (SPEA) [2] a special type of fitness sharing (based on the Pareto dominance) is used in order to maintain the population diversity.
Co-evolutionary techniques for evolutionary algorithms are applicable in the cases where the fitness function formulation is difficult (or even impossible), like in the problem of generating strategies for computer games.However, co-evolutionary algorithms can also be used as techniques for maintaining population diversity because they eventually lead to speciation and formation of sub-populations.
Generally speaking, co-evolutionary techniques can be classified as competitive [30] or co-operative [31].In the case of competitive co-evolution two (or more) individuals coming from the same or different sub-populations compete in a game and their "competitive fitness functions" are calculated on the basis of their performance [32].In the case of co-operative co-evolutionary algorithms a problem is decomposed into sub-problems solved by different sub-populations [31].
In [33] the co-evolutionary algorithm with predator-prey model and spatial graph-like structure for multi-objective optimization was proposed.Deb later modified this algorithm in such a way that predators eliminated prey on the basis of the weighted sum of all criteria [3].Additional modification was introduced by Li [34].In his algorithms prey could migrate within the environment.In [35] the model of cooperative co-evolution was applied to multi-objective optimization.
Sexual selection results from the fact that the proportion of individuals from each sex within a given species is almost 1:1 and the reproduction costs are much higher in the case of one of the sexes (usually females).These facts lead to female-male co-evolution, in which the females evolve to keep the reproduction at the optimal level and the males evolve to attract females.Sexual selection is considered to be one of the mechanisms responsible for biodiversity and sympatric speciation [36,37].The sexual selection mechanism was used in the multi-objective evolutionary algorithms as a tool for maintaining the population diversity.
In [38] Allenson proposed the genetic algorithm with sexual selection for multi-objective optimization.The number of sexes was the same as the number of criteria of the given problem being solved.The sex of the child was determined randomly and the child replaced the poorest individual from its sex in the population.The partner for reproduction was selected on the basis of preferences encoded within the genotype of the given individual.
Lis and Eiben proposed the multi-sexual genetic algorithm (MSGA) for multi-objective optimization [39].One sex for each criterion was used.The recombination operator was used randomly.The partners for reproduction were chosen from each sex separately with the use of a ranking mechanism.The offspring was created with the use of a multi-parent crossover operator.The sex of child was the same as the sex of the parent that provided most of the genes.The group of Pareto-optimal individuals found so far was maintained during the run of the algorithm.
Bonissone and Subbu [40] further developed Lis and Eiben's algorithm.Additional mechanisms for determining the sex of the offspring were proposed.One of them was to determine the sex at random and the second mechanism was based on the solution encoded within the individual-the sex of the child was determined by the criterion for which it best fitted.
Co-evolution of species and sexual selection are the biological mechanisms responsible for sympatric speciation and the introduction of diversity of the population.However, these techniques were not widely used as mechanisms for maintaining the population diversity and as speciation mechanisms for classical evolutionary algorithms.It was probably caused by the centralized nature of these algorithms and the problems with introducing some more advanced techniques based on the ecological phenomena existing in nature.On the other hand, co-evolution and sexual selection can be quite easily introduced into agent-based evolutionary algorithms because they quite well suit the decentralized character of these algorithms.In fact in some of the previous papers we developed the niching techniques for CoEMAS working on the basis of sexual selection and co-evolution [41].

Agent-Based Co-Evolutionary Algorithms
The idea of agent-based evolutionary algorithms was proposed in [42].In this approach the individuals are agents which "live" within an environment and act independently, making the decisions about reproduction, migration and interactions with other agents.The selection mechanism is based on resources, which are needed for performing every action, so when an agent runs out of the resources it dies and is removed from the multi-agent system.The resources are also used to maintain the functional integrity of the system [43].
The model of agent-based evolutionary algorithms was further developed in [44].In this work the model of co-evolutionary interactions between species and sexes was introduced-basically it allowed for constructing the agent-based evolutionary algorithms utilizing many co-evolving species and sexes.Co-evolutionary multi-agent systems (CoEMAS) were applied with success to multi-modal optimization (for example see [41]) and multi-objective optimization (for example see [45][46][47]), in which case it allowed for constructing novel and very effective mechanisms for maintaining the population diversity [48].The CoEMAS model was then generalized and the bio-inspired multi-agent system for simulation and computations was proposed in [49].This approach was applied to the modeling and simulation of species formation processes based on the co-evolutionary interactions.
Our generalized model allows for use together the computation and simulation techniques within one coherent system.It was possible due to the agent-based approach.Using agent-based simulation algorithms together with biologically and socially inspired computation techniques opens up quite new possibilities.We can simulate biological, social, economical and political systems, additionally using the computation algorithms within agents for optimization and learning.Additionally, we can simulate selected biological mechanisms and introduce them into social and economical simulations.It is possible to observe emergent phenomena resulting from the interactions of the agents acting within the system.Using the agent-based approach, it is quite natural and relatively easy to model and simulate whole artificial societies, with different modes of production and social relations.It is possible to simulate the effects of social stratification, social power, political systems etc.Hence, our model is not just a tool for constructing computational systems but the more general approach allowing for the agent-based simulations of biological and social systems, additionally allowing for using the computational techniques within the agents.This opens quite new possibilities of introducing learning, perception and reasoning components into the social, economical and biological simulations.
In this paper we focus on only one aspect of our research-agent-based computing systems.We introduce the co-evolutionary multi-agent system with two co-evolving sexes for solving the multi-objective portfolio optimization problem, which serves as a testbed for our algorithm and techniques.We will compare the results of the proposed system with the results of genetic algorithm, co-evolutionary algorithm and trend-following approach in order to asses the quality of the results and the ability to maintain the population diversity.

Previous Research
The goal of the portfolio optimization is to decide in what proportions various assets should be held in order to obtain the best portfolio according to some criterion.The foundation of all modern theories for building efficient portfolios is Harry Markowitz' modern portfolio theory (MPT) proposed in 1952 [50,51] and its extension consisting of introducing risk-free assets to the model proposed in 1958 by James Tobin [52].These theories and models are the formal foundations of risk-rate of return investment decision-making.
In recent years there has been a growing interest in research on bio-inspired artificial intelligence algorithms for solving economic and financial problems [53][54][55][56][57]. Below, we present some selected applications of the bio-inspired techniques in the investment decision support systems.
In [58] the authors presented a genetic algorithm used for investment decision support.The main task of the algorithm was to choose (on the basis of historical data) the company to invest in.In the system some logical operations were performed on the historical data and the task of the genetic algorithm was to choose proper logical operators in the given situation.
The genetic algorithm for the automatic generation of trade models represented by financial indicators was proposed in [59].The goal of the proposed algorithm was to select the parameters for indicators.The authors presented three algorithms: the genetic algorithm (which performed rather poorly because it converged to local minima and was weak when it came to generalization); the genetic algorithm with the fitness-sharing technique developed by X. Yin and N. Germay [60] (it generally performed better than the genetic algorithm); and the genetic algorithm with the fitness-sharing technique developed by the authors themselves (with the best capability for generalization).
The authors of [61] proposed a genetic algorithm for finding trading rules for the S&P 500 index.The genetic algorithm was used to select the structures and parameters for rules composed of functions organized into a tree and a returned value (which indicated whether the stocks should be bought or sold at a given price).The authors used the following components of the rules: functions operating on historical data, numerical or logical constants, and logical functions (used to build more complex rules).
In [62], genetic programming was used to predict bankruptcy.The authors used historical data to build a function assessing whether the particular company was heading toward financial problems.Approximately 75% of the test data was classified correctly.
Evolutionary algorithms were also used to design and optimize the artificial neural networks designated to automate trading (trading is a process of buying and selling financial instruments).An example of such a system was described in [63]-the authors pointed out that the trading rules were unsophisticated but the systematic execution of them could lead to some substantial returns.
Very interesting modifications to the standard evolutionary approach-quantum-inspired EAs-were used for option pricing model calibration in [64].
The evolutionary approach was compared with some simple investing strategies and the stock market index in [65].In some cases the proposed technique outperformed the basic version of the buy and hold strategy as well as the market index.
The authors of [66] extended the classical mean-variance optimization problem with a third objective-robustness.As a result, it was possible to group the sets of portfolios according to their reliability and provide this additional information to a human decision-maker.
In [67] the authors used multi-objective genetic algorithm for portfolio optimization.Two objectives based on the Markowitz model were used: the risk and the rate of return.The authors of [68] used three higher moment models: mean-variance-skewness with three objectives, mean-variance-skewness-kurtosis with four objectives, and mean-variance-skewness-kurtosis with eight objectives.Three median models with two objectives were used: the median value at risk, median conditional value at risk, and median mean absolute deviation.They constructed multi-objective problems using these models and used the NSGA-II multi-objective evolutionary algorithm to solve them.The real financial data coming from Egyptian Exchange (EGX) was used during the experiments.Generally speaking, the authors concluded that the median models outperformed the higher moments models during the experiments with real data coming from the emerging market.
The co-evolutionary multi-agent system using predator-prey interactions was presented in [69].The system was run against well-known test problems as well as portfolio optimization problem.
The results obtained from both groups of experiments proved that the CoEMAS approach is a robust technique, providing more general solutions that can be used in many different market conditions.
The agent-based co-evolutionary genetic programming approach was also applied with success to investment strategy generation [70,71].During the experiments the agent-based approach was compared to the evolutionary algorithm, a co-evolutionary algorithm, and the buy-and-hold strategy.Also in this case the results of experiments confirmed that the agent-based approach led to obtaining more general investment strategies.
The co-evolutionary multi-agent system with sexual selection was applied to multi-objective optimization problems in [72].This was the very first attempt to realize agent-based sexual selection in the co-evolutionary system for multi-objective optimization.There were two sexes used but they were not connected with any particular objectives of the problem being solved.The partner for reproduction was chosen on the basis of the level of resources.This algorithm was compared experimentally with SPEA and NSGA multi-objective evolutionary algorithms.The results showed that agent-based approach maintains the population diversity much better than the "classic" algorithms.
In [73] another variant of the agent-based sexual selection was proposed.In this algorithm each agent used vector of weights in order to choose the partner for reproduction.This algorithm was compared experimentally with SPEA2 and NSGA-II multi-objective evolutionary algorithms.It was found that each step of the "classical" algorithms is computationally much more complex than the single step of the agent-based approach.
In this paper we propose the agent-based multi-objective co-evolutionary algorithm, which is applied to portfolio optimization and compared to evolutionary and co-evolutionary algorithms.The main contributions of this paper, as compared to the works presented above, are as follows: 1.The idea, design and realization of the agent-based multi-objective co-evolutionary algorithm for portfolio optimization.As compared to our previous research, we propose here different architectures, algorithms and a modified technique for maintaining population diversity.The proposed algorithm utilizes two co-evolving sexes and the competition for limited resources mechanism (dominating agents obtain resources from the dominated ones) in order to obtain high quality solutions and maintain population diversity.The number of the sexes corresponds with the number of objectives of the problem being solved.Each sub-population (sex) is optimized with the use of different objectives.The agents choose partners for the reproduction from the opposite sex and the decision is made on the basis of the quality of the solutions and also on the basis of the resources possessed by the agents.2. Design (including the adjustments needed for solving the multi-objective portfolio optimization problem) and realization of a genetic algorithm and co-evolutionary algorithm (including the fitness function, all genetic operators and the diversity maintaining mechanisms) for multi-objective portfolio optimization.3. Experimental comparison of evolutionary, co-evolutionary, proposed agent-based co-evolutionary and trend-following algorithms with the use of historical data dating two years prior (2010 and 2008) with quite different stock market trends.
The research presented in this paper is the part of our more general research project aiming at the development of a model, architectures, and algorithms for biologically and socially inspired agent-based systems for use in simulation and computation.Our approach would unify many different biologically and socially inspired techniques on the basis of the agent-based approach.The agent-based approach provides a common architecture for designing and implementing mechanisms and algorithms inspired by biological and social mechanisms in a very natural way similar to reality-based techniques.

Evolutionary, Co-Evolutionary and Agent-Based Algorithms for Portfolio Optimization
All of the algorithms mentioned in this chapter are implemented to calculate the best possible portfolio throughout a specified time period, which forces an adjustment to the changing market's conditions and provides a trading strategy whereby we can follow the portfolio's composition adjustments made on a daily basis.

Genetic Algorithm
Genetic algorithms (GAs) [74] are well-known and popular techniques of dealing with multi-objective optimization problems (MOOPs) [3].
Every time we try to use GA to solve a given problem we have to adjust it accordingly.In our implementation each potential solution should be encoded inside a chromosome.Each chromosome represents the portfolio composition (it is a normalized vector of double values representing the percentage share of each stock)-the same representation is used in the co-evolutionary and the agent-based co-evolutionary algorithms.Before the first round of computation, the entire population is created from scratch using random values in chromosomes.
The following modified GA operations have been implemented: • mutation-the mutation operator changes exactly one value, α i , representing the percentage share of a specific stock i (each time the value i is chosen randomly) to α i (α i ∈ (0,1) is chosen randomly).
After that, we have to normalize the vector.Mutation_coefficient ∈ (0, 1) determines which part of the population will be subjected to the mutation operator.

•
selection-the breeding_coefficient ∈ (0, 1) determines which part of the population will be subjected to crossover operator.Selection is based on the fitness function (only the fittest part of the population will be selected); • crossover-after selecting chromosomes eligible for the reproduction, each pair of chromosomes is subjected to crossover operator.As a result, new chromosomes are created (each pair produces two new chromosomes) and added to the population.Crossover chooses left and right points (both are chosen randomly) which cut parents' chromosomes in the way presented in the Figure 2a.
Children are created according to the process shown in the Figure 2b.Apart from that, an extinction mechanism has been implemented.At the end of each GA round the part of the population that has the lowest fitness is exterminated.The extinction_coefficient determines which part of the population will be subjected to extinction.

Pseudo-code
The pseudo-code of the GA is presented in Algorithm 1.We start by evaluating each chromosome using the fitness function (described in Section 3.1.2),which uses current stock prices.The fittest individuals are allowed to reproduce (this is further controlled by the breeding_coefficient that determines which part of the population will be subjected to crossover operator).New individuals are merged with the existing population.After that, the mutation is applied to a part of the least fit population to assure that population is diverse (in fact it is a way of implementing a reinitialization method, mentioned in [2]) and we do not miss any potentially better solutions.Then, we destroy some of the least fit individuals-in such a way we can control the overall population size and we get rid of the individuals with chromosomes not likely to be successful in the future.Finally, we return the best individual, which becomes our trading strategy for the next day (we adjust our current portfolio to the fittest individual solution).

Fitness Function
Fitness is calculated according to the following formula (for portfolio with N stocks): where: • γ day is the value of the portfolio's fitness calculated for specific day; • α i is the percentage share of a specific stock i in the whole portfolio; • price(i, day) returns the price of the stock i for the specific day.
Clearly, the fitness function favors portfolios which have the highest day-to-day increase in value.Of course ,such methods of calculating fitness have many drawbacks, e.g., they completely omits the aspect of risk associated with the investing in highly volatile stocks.However, it turns out that in spite of this obvious flaw the algorithm performs quite well.

Co-Evolutionary System
Contrary to the genetic algorithm described in Section 3.1, in the co-evolutionary algorithm (CEA) two sub-populations coexist side by side.Each individual represents a potential solution to the portfolio optimization problem.The risk-oriented sub-population tries to optimize the risk (the lower risk value the better), whereas the return oriented sub-population tries to maximize expected return.Usually the greater the expected return, the riskier the investment, so our solutions will involve some trade-offs.However that should not startle us, as we have already predicted in Section 1.1 that optimization under such circumstances is not an easy task.
As presented in Figure 3, the reproduction is allowed only between the members of different sub-populations.Not every member of a particular sub-population is allowed to reproduceonly the fittest ones (fitness of a particular individual depends on the sub-population it belongs tothe fittest one in one sub-population would probably be considered as one of the weakest in another one).Thanks to this approach, the offspring that are created are very diverse.In fact, it is an application of restricted mating [2].Some of the weakest members of both sub-populations are subjected to extinction.Because of that, we do not end up with a too-large population full of useless solutions.In the place of extinct members, the offspring of the fittest individuals are introduced to both sub-populations.Apart from that, some members of the sub-populations are subjected to mutations in order to even further maintain the sub-population diversity.The migration mechanism has the same purpose-it is applied in order to avoid local optima.It is also described in [2] as an isolation by distance.The individuals for migration are selected at random with probability of 0.1.During the migration, selected individuals are moved from one sub-population to another-this introduces new chromosomes into the given sub-population and makes it more diverse.
The risk as well as the expected return are calculated according to capital asset pricing model (described in [75]).

Maintaining Population Diversity
To sum up, several mechanisms have been implemented to keep both sub-populations diverse: • crossover is allowed only between the fittest chromosomes from different sub-populations; • mutations introduce random genetic change; • migration allows chromosomes to travel to different nodes.

Pseudo-Code
Contrary to the GA, we are dealing with two sub-populations (with different objectives) at once (see Algorithm 2).Apart from that, the pseudo-code looks very similar.The reproduction is only allowed between individuals from different sub-populations.To even further assure that populations remain diverse, we mutate part of the least fit individuals.Migration of the individuals between the nodes also helps maintaining the population diversity.Extinction helps to control population size and get rid of useless individuals.A non-dominated solution (in Pareto sense) is returned as a result.

The Co-Evolutionary Multi-Agent System
The co-evolutionary multi-agent system (CoEMAS) is the most sophisticated system that has been implemented.CoEMAS model [44] is the result of merging co-evolutionary computations and multi-agent systems paradigms.
Such systems need an environment as well as a set of autonomous agents interacting with each other.A potential solution to the portfolio optimization problem is stored inside each agent-it is encoded within its genotype.In the CoEMAS model the environment is usually a graph with vertices (nodes) connected with the edges.Agents live within the environment, and can migrate from one node to another (looking for better living conditions), reproduce, and interact with each other.The agents need resources for every activity and these resources can be obtained from the environment or from other agents.An agent dies when it runs out of resources.Each agent can reproduce when it has enough resources-it usually selects a partner for reproduction and when it succeeds offspring are created with the use of the recombination and mutation operators.
Contrary to the co-evolutionary system described in Section 3.2 there are no sub-populations.Instead, we introduced individuals of two different sexes (see Figure 4).Each sex focuses on a different task: • sex1-tries to achieve the lowest risk possible; • sex2-tries to achieve the highest expected return possible.
The risk as well as the expected return is calculated due to the capital asset pricing model (defined in [75]).

CoEMAS Model
A formal model of the co-evolutionary multi-agent system was proposed for the first time in [44] and was further developed and generalized in [49].Below, we will use the CoEMAS model for describing in a more formal way the co-evolutionary multi-agent system used for multi-objective portfolio optimization.
The multi-agent system with two co-evolving sexes is defined as follows: where: The actions have the following meaning: • death-if the amount of the resource that an agent possesses is lower than the threshold value, the agent dies; • mig-the agent is allowed to migrate but the probability of this action is low; • rep-the agents from different sexes are allowed to reproduce provided that they both exceed the minimum amount of resource allowing to reproduce; • give/get-the agent can get a resource from other, dominated agents; • rec-agents produce offspring by means of recombination; • mut-a mutation introduces random change to the potential solution, and normalization of the solution vector is then required; • seek-agents appropriate to the rep as well as get operations can be found thanks to this action.
Environment type et is defined in the following way: EnvT et ⊆ EnvT is the set of environment types that may be connected with the et environment.
VertT et ⊆ VerT is the set of vertice types that may exist within the environment of type et.
ResT et ⊆ ResT is the set of resource types that may exist within the environment of type et.In f T et ⊆ In f T is the set of information types that may exist within the environment of type et.
Environment env of type et is defined as follows: where gr env is directed graph gr env = Vert, Arch, cost , Vert with the cost function defined is the set of vertices, and Arch is the set of arches.The distance between two nodes is defined as the length of the shortest path between them in graph gr env .Env env ⊆ Env is the set of environments of types from EnvT connected with the environment env (in our case it is an empty set).Vertice type vt is defined in the following way: where: • Attr vt ⊆ Attr is the set of attributes of the vt vertice at the beginning of its existence; • Act vt ⊆ Act is the set of actions which the vt vertice can perform at the beginning of its existence, when asked for it;

•
ResT vt ⊆ ResT is the set of resource types which can exist within the vt vertice at the beginning of its existence; • In f T vt ⊆ In f T is the set of information types which can exist within the vt vertice at the beginning of its existence; • Vt vt is the set of types of vertices that can be connected with the vt vertice at the beginning of its existence;

•
ObjT vt ⊆ ObjT is the set of types of objects that can be located within the vt vertice at the beginning of its existence; and • AgT vt ⊆ AgT is the set of types of agents that can be located within the vt vertice at the beginning of its existence.
The element of the structure of the system's environment (vertice) vert ∈ Vert of type vt ∈ VertT env is given by: where: • Attr vert ⊆ Attr is the set of attributes of vertice vert-it can change during its lifetime; • Act vert ⊆ Act is the set of actions, which vertice vert can perform when asked for it-it can change during its lifetime; Res vert is the set of resources of types from ResT that exist within the vert; • In f vert is the set of information of types from In f T that exists within the vert-in f in f t1 is the information about agents of sex1 that are located within the given vertice and in f in f t2 is the information about the agents of sex2; • Vert vert is the set of vertices of types from VertT connected with the vertice vert-in our case it is the set of four vertices (see Figure 4); • Obj vert is the set of objects of types from ObjT that are located in the vertice vert; • Ag vert is the set of agents of types from AgT that are located within the vertice vert.
There are two types of agents (sexes) in the system: sex1 and sex2.The sex1 agent type is defined in the following way: where:

•
Gl sex1 is the set of goals of the sex1 agent at the beginning of its existence; • Attr sex1 ⊆ Attr is the set of attributes of the sex1 agent at the beginning of its existence; • Act sex1 ⊆ Act is the set of actions which the sex1 agent can perform at the beginning of its existence; • ResT sex1 ⊆ ResT is the set of resource types which can be used by the sex1 agent at the beginning of its existence; • In f T sex1 ⊆ In f T is the set of information types which can be used by the sex1 agent at the beginning of its existence; • ObjT sex1 ⊆ ObjT is the set of types of objects that can be located within the sex1 agent at the beginning of its existence; and • AgT sex1 ⊆ AgT is the set of types of agents that can be located within the sex1 agent at the beginning of its existence.
gl 1 is the goal get resource-an agent can get the resources from a dominated agent that is located within the same vertice, gl 2 is the goal reproduce, and gl 3 is the goal migrate to the other vertice.
The sex2 agent type is defined in the same way as sex1 agent-the only difference between these two types of agents is that sex1 tries to achieve the lowest risk possible and sex2 tries to achieve the highest expected return possible.
Agent ag sex1 (of type sex1) is defined in the following way: ag sex1 = Gl ag,sex1 = Gl sex1 , Attr ag,sex1 = Attr sex1 , Act ag,sex1 = Act sex1 , Res ag,sex1 = r ag,sex1 , In f ag,sex1 = in f in f t1 , in f in f t2 , Obj ag,sex1 = ∅, Ag ag,sex1 = ∅ (11) where: is the set of goals, which agent ag sex1 tries to realize-it can change during its lifetime; • Attr sex1 ⊆ Attr is the set of attributes of agent ag sex1 -it can change during its lifetime; • Act sex1 ⊆ Act is the set of actions which agent ag sex1 can perform in order to realize its goals- it can change during its lifetime; • Res sex1 is the set of resources of types from ResT, which are used by agent ag sex1 ; • In f sex1 is the set of information of types from In f T which agent ag sex1 can possess and usean agent uses information about the other agents located within the same vertice; • Obj sex1 is the set of objects of types from ObjT that are located within the agent ag sex1 ; • Ag sex1 is the set of agents of types from AgT that are located within the agent ag sex1 .
Notation Gl ag,sex1 means "the set of goals of agent ag of type sex1".r ag,sex1 is the amount of resource of type rt that is possessed by the agent ag sex1 .
Agent ag sex2 (of type sex2) is defined in the same way as agent of type sex1.
The set of relations is defined as follows: The first relation is defined as follows: Ag {seek,get} is the set of agents capable of performing actions seek, get.Ag {give} is the set of agents capable of performing the action give.This relation represents competition for resources between agents-dominated agents have to give some of its resources to dominating agents.The second relation is defined as follows: Ag sex1,{seek,rep,rec,mut} is the set of agents of type sex1 capable of performing actions seek, rep, rec, mut.Ag sex2,{rep,rec,mut} is the set of agents of type sex2 capable of performing action rep, rec, mut.Ag sex2,{seek,rep,rec,mut} is the set of agents of type sex2 capable of performing actions seek, rep, rec, mut.Ag sex1,{rep,rec,mut} is the set of agents of type sex1 capable of performing action rep, rec, mut.This relation represents searching for reproduction partners and the process of reproduction.It can be initiated by any agent that has enough resources.Reproducing partners come from the opposite sex.
The interactions between the agents are implemented in the following way: • co-evolution is implemented as a sequence of turns; • in each turn every agent performs its action (the action to perform at any particular turn is chosen with a well defined probability, e.g., there is a 10% chance that the agent will try to find a partner for reproduction, and a 60% chance that the agent will try to obtain some resources from the dominated agent); • after every agent performes some action the turn ends and the entire population of agents is checked as to whether some of them should die (when not enough resources are left after other agents take resource from them).
Each agent performs one of the above actions with some probability.

Pseudocode
The pseudocode of CoEMAS is presented in Algorithm 3. The actions are performed with the following probabilities: Similarly to Section 3.2, the mutation is used as a mean of maintaining the population diversity.The role of the environment composed of the computation nodes is to additionally help maintain population diversity.When the agents are located within different nodes, each sub-population evolves in a different direction, so the whole population can avoid local optima (it is the model of speciation caused by the geographic separation of sub-populations).The agent can migrate between the computation nodes when the level of the resource possessed is above the minimal level (the migration costs some amount of the resource).The agent tries to migrate because it can not find asuitable partner for reproduction within the current node or it can not find dominated agents to get resources from them.The decision of migration is made with the probability 0.1.

Trend Following
The concept of price as the trading cue lays the foundations for trend following (TF).Contrary to the other trading strategies based on fundamental analysis (which use the factors like overall state of the economy, interest rates, production, etc. to predict the stock price), TF uses only price as the key trading variable.
Trend following basically does not try to predict when the trend will occur.Instead of that, trend followers will react to the market's movement and adapt accordingly (an example of how TF works in practice is shown in Figure 5).This strategy simply analyses the stock prices and decides whether the current situation is suitable for buying or selling a specific stock.Market breakouts are a great buying opportunities, on the other hand when you recognize that you are wrong you exit immediately in order to cut losses.A set of predefined rules decides whether to take any action (they should recognize when the trend starts as well as when to exit) so the entire process can be easily automated.Such rules are quite simple but disciplined execution of them could lead to achieving spectacular returns year after year.It is all about cutting the losses and letting the profits run.Many leading hedge funds successfully use strategies based on trend following to manage their portfolios [76].Another advantage of this investing method is the fact that the investor does not have to know much about what is being traded (it could be stocks, oil, gold, etc.) Normally, people tend to gather some information about the company they are willing to invest in.They analyze its market situation, competitors, financial performance, etc. which is time consuming, especially for someone who is not a professional trader.With trend following we just have to focus on elaborating trading rules that should reflect our trading strategy.After that, we can automate the decision-making process by designing and implementing our own trading system.

Types of Trends
There are three main types of trends: 1. Short-term trend: any price movement that occurs over a few hours or days.2. Intermediate-term trend: general movement in price data that lasts from three weeks to six months.3. Long-term trend: any price movement that occurs over a significant period of time, often over one year or several years.

Designing Trading System Based on Trend Following
Following [76], the core of each trading system based on a trend-following strategy is a set of rules governing each buy/sell decision.More specifically, we have to devise the rules to answer the following questions: • how much money are we willing to put on a single trade; • when to exit (what kind of losses are acceptable); • when to enter (when the trend has started); • which markets are we interested in and how to split the money between them (we would like to have a diverse portfolio: stocks, gold, etc.).
These rules should reflect our investing style.
The simple moving sverage (SMA) is especially useful for highlighting the longer-term trends in a set of data points [76].
SMA is formulated as the unweighted mean of the previous N data points [76]: where p j is the value of data on day j.In this case, data points will represent closing stock prices.Entry points: • Simple moving average (SMA) of the last N days is greater than SMA of last M days (N < M); • Current stock price is maximal of the last N days (that is usually a good indicator of lucrative opportunity on the market).
As soon as at least one of the above conditions is satisfied we go long (we buy a particular asset).
Exit points: • Losses on a single trade are greater than 2% (this rule is used to quickly abandon an investment where we were wrong about its trend direction; the amount of tolerable loss solely depends on our strategy and does not have to be exactly 2%);

•
The simple moving average (SMA) of the last N days is lesser than the SMA of last M days (N < M).
As soon as the exit condition is satisfied we go short (we sell a particular asset).
Obviously the above rules are very simple and quite straightforward.Nonetheless, the system based on them proves to be robust, as shown in Section 5.
By manipulating the value of N we can seek out different types of trends, as mentioned in Section 4.1.

Pseudo-Code
The Algorithm 4 shows pseudo-code of the trend-following approach.It uses the following functions: The trend-following algorithm has been implemented as a standalone R script-it is not the part of our multi-agent system.

Experimental Results
In this section selected results from the experiments with data coming from the Warsaw Stock Exchange (WSE) are presented.The goal was to test the proposed and reference algorithms during different periods of time on the real data and to compare the obtained results.In the first set of experiments we used the data from the year 2010-a year of moderate stock market rises.In the second set of experiments we used the data from the year 2008-a year which was extremely hard for investors (the WIG20 lost over 47% in value).In this section we will try to answer the question as to which of the used algorithms gives the best results and under what conditions.

First Set of Tests
The first set of tests uses historical data from the year 2010 (data of three different stocks have been used).In spite of the short periods of downturns, 2010 was a year of stock market rises on the Warsaw Stock Exchange (WSE).The upward trend started in the first quarter of 2009 was maintained.The annual change of the stock exchange index (WIG) was +20.5%.The WIG reached its highest value in two years on 15 December 2010 (47,892.91 points).The minimal value of WIG in 2010 was 37,038.90points.
The multi-agent platform has been used to run algorithms.It was configured in the following way: • using a simulation of the trading strategy throughout the entire year 2010; • all investing decisions have been based solely on the results from the implemented algorithms; • the migration mechanism between computing nodes has been enabled; • two computing nodes (with the appropriate algorithms) have been used to obtain results.
The trend-following algorithm has been tested without a multi-agent running platform as it is a standalone R script.Apart from that, it is a completely deterministic algorithm so each time we run it, we will get the same results.There are easily visible periods of time (Figure 6a) when the portfolio value is not changing.It is a time when our portfolio does not contain any assets (but we still have the money).After a while, the conditions change and the trend-following algorithm decides some assets should be bought.

Intermediate-Term Trend Results
In this particular test (with values: N = 20, M = 40), the trend-following algorithm has been adjusted to focus on the intermediate-term trends.The results are presented in Figure 6b.It can be seen that they are slightly better compared with the short-term trends approach.It turned out that focusing on the short-term or intermediate-term trends leads to almost the same results.The intermediate-term trend approach offers a slightly better return from investment.In both cases we encountered periods of time when the portfolio contained no assets because the situation on the market was not good enough to invest in any of the available stocks.

Genetic Algorithm
The best results that we were able to obtain with the use of genetic algorithm are presented in Figure 7a.Apart from that, the average values of 5 runs are shown in Figure 7b.As can be easily spotted, the algorithm performs reasonably well on the average.The following configuration was used: • reproduction_coeff was set to 0.2; • population size was 512; • mutation_coeff was set to 0.1; • extinction_coeff was set to 0.3.

Co-Evolutionary Algorithm
Results for the CEA, presented in Figure 8, clearly show that the return of our investment is much higher than any other algorithm could achieve.The analysis of Figure 9 explains why the results are so good-the risk associated with our portfolio is substantially higher compared to other methods.In this case the algorithm was tuned to prefer the non-dominated solutions from the return-oriented sub-population-this explains why the results provide so much return and risk.The following configuration was used: • reproduction_coeff was set to 0.2; • sub-population size in each computing node was set to 64; • number of computing nodes was set to 2; • mutation_coeff was set to 0.1; • extinction_coeff was set to 0.3.

CoEMAS
Figure 10a presents the average portfolio value in time while Figure 10b presents the average risk associated with our investments.Returns are not as spectacular as in CEA but on the other hand the amount of risk we have to take is much lower.The intermediate-term trend seeking tends to give much better results than focusing on the short-term trends.We managed to minimize the losses thanks to the fact that we completely ceased trading during the worst time on the market.

Genetic Algorithm
The best results that we were able to obtain are presented in Figure 12a.Apart from that, the average values of 5 runs are shown in Figure 12b.As can be easily spotted the algorithms perform reasonably well on the average (especially compared with CEA).
The following configuration was used: • reproduction_coeff was set to 0.

Co-Evolutionary Algorithm
The results presented in Figure 13a are very poor (and yet they are the best results obtained from a series of tests).The average results are shown in Figure 13b.
We have lost almost all our money-approximately 70% of it.Average risk associated with our portfolio is presented in Figure 15a.As we can observe the best obtained results are quite similar to the average ones.
The following configuration was used: • reproduction_coe f f was set to 0.2; • sub-population size in each computing node was set to 64; • number of computing nodes was set to 2; • mutation_coe f f was set to 0.1; • extinction_coe f f was set to 0.3.

CoEMAS
Figure 14a presents the best returns that we managed to obtain with the use of CoEMAS, while Figure 14b presents the average return.The average risk associated with our investments is shown in the Figure 15b.Once again it turns out that the average values are pretty similar to the best we managed to get.It turns out that CoEMAS performs much better in the difficult times than CEA.
The following configuration was used: • reproduction_coe f f was set to 0.

Conclusions from the Second Set of Tests
Clearly, the trend-following approach managed to save almost the entire capital.Losses that we had to experience due to this algorithm seem almost negligible compared with the other methods.
In spite of the fact that fitness function used in the genetic algorithm completely ignores the risk associated with the assets in portfolio, it actually performed better then the solution taking risk into consideration.
The results of the co-evolutionary algorithm are particularly poor.Almost 70% of initial money is lost.CoEMAS performs slightly better, but it is still worse than the simple genetic algorithm approach.
In summary, it appears that algorithms performing exceptionally well in a bull market can potentially lead to catastrophic losses during difficult times.The trend following algorithm has one major advantage among all discussed methods-it allows us to withdraw all our money during the periods of time that are not investor-friendly.

Conclusions
In this paper we have proposed the agent-based co-evolutionary multi-objective algorithm and we have applied it to the portfolio optimization problem.We have also described the proposed algorithm with the use of formal model of co-evolutionary multi-agent system (CoEMAS) proposed in our previous works.Also, the evolutionary algorithm and the co-evolutionary algorithm were implemented within our framework in order to compare the results obtained during the experiments carried out with the use of real world data coming from Warsaw Stock Exchange.Additionally, the trend-following algorithm was implemented as a standalone R script and used during the experiments as the reference point.
All implemented algorithms have been exhaustively tested using the historical data reflecting two completely different situations on the market.Taking into consideration both good and bad times leads to the conclusions that all approaches have advantages as well as disadvantages.That raises a question as to which algorithm to use if we want to build our own portfolio.
The trend-following algorithm obtains good results for unstable times because it somehow guarantees that the losses would be minimized according to our preferences.However, during stock market rise it is outperformed by other algorithms.
The proposed agent-based multi-objective co-evolutionary algorithm gives quite good results.It maintains a high level of population diversity and proposes sustainable strategies, where the risky and safe moves are mixed together.Maintaining high level of the population diversity is especially important in the times when there are rapid and frequent changes on the market.The proposed algorithm can easily adapt to the changing conditions of the environment and escape from local optima.High population diversity also leads to more robust strategies, that can be applied with success in many different conditions and situations.Future work will include the application of our agent-based co-evolutionary approach in business intelligence systems.It would be used not only as an investment strategies generation algorithm but also as a data mining algorithm (with the use of neural and fuzzy classifiers) for market segmentation and preparation of customized products/services and targeted adds.Also, we will integrate the proposed algorithm within a framework ("virtual laboratory") for reproducible research on artificial intelligence techniques supporting financial and economical decision-making.

Figure 1 .
Figure 1.The example of the Pareto-optimal front of a portfolio optimization problem.

Figure 2 .
Figure 2. The example of two (A and B) parents' chromosomes split into three parts (a) and two children's chromosomes containing mixed genetic material of their parents (b).

Figure 3 .
Figure 3. Overview of the co-evolutionary system.

Figure 5 .
Figure 5. Simple example of how trend following works in practice [76].

5. 1
.1.Trend Following 5.1.1.1.Short-Term Trend Results As described in Section 4, we can adjust our trading rules to seek out the short-term trends (by changing the values of N and M in the Simple Moving Average method).With values N = 10, M = 20 the SMA method focused on the short-term trends.

Figure 6 .
Figure 6.Portfolio value in time for trend following (TF) using the short-term (a) and intermediate-term (b) trends.

Figure 7 .
Figure 7. Best (a) and average (b) portfolio values obtained for the genetic algorithm (GA).

Figure 8 .
Figure 8. Best (a) and average (b) portfolio values obtained for CEA.

Figure 9 .
Figure 9. Average value of risk in time for CEA.

Figure 10 .
Figure 10.Average portfolio value (a) and average risk value (b) for CoEMAS.

Figure 12 .
Figure 12.Best (a) and average (b) portfolio value for the GA.

Figure 13 .
Figure 13.Best (a) and average (b) portfolio value for CEA.
2;• each sex was represented initially by 64 agents (in each computing node); • number of computing nodes was set to 2; • mutation_coe f f was set to 0.1; • extinction_coe f f was set to 0.3.
∅ is the set of object (not an object in the sense of object-oriented programming but an object as an element of the simulation model) types that may exist within the system in time t; • AgT(t) = sex1, sex2 is the set of agent types that may exist within the system in time t; Act = death, mig, rep, give, get, rec, mut, seek is the set of environment types in the time t; • Env(t) is the set of environments of the CoEMAS in the time t; • ElT(t) is the set of types of elements that can exist within the system in time t; • VertT(t) = vt is the set of vertice types that can exist within the system in time t; • ObjT(t) = • Attr(t) is the set of attributes of agents, objects, and vertices; and • Act(t) is the set of actions that can be performed by agents, objects, and vertices.The set of actions is defined as follows:

11 end 12 if goal is migrate then 13
1 randomly INITIALIZE agents of two different sexes (risk oriented and return oriented); 2 foreach day do 3 for round ← 1 to number_o f _rounds do 4 foreach agent ∈ population do 5 goal ← chooseGoal(); 6 if goal is get resource then 7 perform actions seek, get leading to the realization of goal get resource 8 end 9 if goal is reproduce then 10 perform actions seek, rep, rec, mut leading to the realization of goal reproduce perform action mig leading to the realization of goal migrate