3 * SeGMO, a Sequential Global Multiobjective Optimiser
5 * Created by Dario Izzo on 5/16/08.
6 * Copyright 2008 ¿dvanced Concepts Team (European Space Agency). All rights reserved.
15 Population
ASAalgorithm::evolve(Individual x0
, GOProblem
& problem
) {
17 const std::vector
<double>& LB
= problem
.getLB();
18 const std::vector
<double>& UB
= problem
.getUB();
20 std::vector
<double> xNEW
= x0
.getDecisionVector();
21 std::vector
<double> xOLD
= xNEW
;
23 fNEW
= x0
.getFitness();
27 std::vector
<double> Step(SolDim
,StartStep
);
28 std::vector
<int> acp(SolDim
,0) ;
35 for ( int jter
=0; jter
< niterOuter
; jter
++){
36 for ( int mter
= 0; mter
< niterTemp
; mter
++){
37 for ( int kter
= 0 ; kter
< niterRange
; kter
++){
38 int nter
= (int)(drng()*SolDim
);
39 for ( int numb
= 0; numb
< SolDim
;numb
++){
40 nter
=(nter
+1) % SolDim
;
41 //We modify the current point actsol by mutating its nter component within
42 //a Step that we will later adapt
43 r
= 2.0*drng()-1.0; //random number in [-1,1]
44 xNEW
[nter
] = xOLD
[nter
] + r
* Step
[nter
] * ( UB
[nter
] - LB
[nter
] );
46 // If new solution produced is infeasible ignore it
47 if ((xNEW
[nter
] > UB
[nter
]) || (xNEW
[nter
] < LB
[nter
])){
48 xNEW
[nter
]=xOLD
[nter
];
51 //And we valuate the objective function for the new point
52 fNEW
= problem
.objfun(xNEW
);
54 // We decide wether to accept or discard the point
55 if (fNEW
< fOLD
) //accept
57 xOLD
[nter
] = xNEW
[nter
];
59 acp
[nter
]++; //Increase the number of accepted values
61 else //test it with Boltzmann to decide the acceptance
64 prob
= exp ( (fOLD
- fNEW
)/ currentT
);
66 // we compare prob with a random probability.
69 xOLD
[nter
] = xNEW
[nter
];
71 acp
[nter
]++; //Increase the number of accepted values
74 xNEW
[nter
] = xOLD
[nter
];
77 } // end for(nter = 0; ...
78 } // end for(kter = 0; ...
81 // adjust the step (adaptively)
82 for (int iter
=0; iter
< SolDim
; iter
++)
84 ratio
= (double)acp
[iter
]/(double)niterRange
;
85 acp
[iter
]=0; //reset the counter
86 if (ratio
> .6) //too many acceptances, increase the step by a factor 3 maximum
88 Step
[iter
] = Step
[iter
] * (1 + 2 *(ratio
- .6)/.4);
92 if (ratio
< .4) //too few acceptance, decrease the step by a factor 3 maximum
94 Step
[iter
]= Step
[iter
] / (1 + 2 * ((.4 - ratio
)/.4));
97 //And if it becomes too large, reset it to its initial value
98 if ( Step
[iter
] > StartStep
){
99 Step
[iter
] = StartStep
;
108 if (fOLD
< x0
.getFitness()){
109 x0
.setDecisionVector( xOLD
);
110 x0
.setFitness( fOLD
);
112 newpop
.addIndividual( x0
);
116 void ASAalgorithm::initASA(int niterTotInit
, int niterTempInit
, int niterRangeInit
, int SolDimInit
, double T0Init
, double TcoeffInit
, double StartStepInit
, uint32_t randomSeed
){
117 niterTot
=niterTotInit
;
118 niterTemp
=niterTempInit
;
119 niterRange
=niterRangeInit
;
123 StartStep
=StartStepInit
;
124 niterOuter
= niterTot
/ (niterTemp
* niterRange
* SolDim
);
125 drng
.seed(randomSeed
);
128 void ASAalgorithm::initASA(int niterTotInit
,int SolDimInit
, double Ts
, double Tf
, uint32_t randomSeed
){
129 niterTot
=niterTotInit
;
133 niterOuter
= niterTot
/ (niterTemp
* niterRange
* SolDim
);
135 Tcoeff
=pow(Tf
/Ts
,1.0/(double)(niterOuter
));
137 drng
.seed(randomSeed
);