41 mMutationVarians(0.1),
42 mEvaluationValue(std::numeric_limits<
C_FLOAT64 >::
max()),
70 mMutationVarians(0.1),
71 mEvaluationValue(std::numeric_limits<
C_FLOAT64 >::
max()),
114 size_t iTmp =
mWins[to];
138 (*(*mpSetCalculateVariable)[j])(mut);
168 for (i = 0; i < nCross; i++)
189 child1[i] = (*pParent1)[i];
190 child2[i] = (*pParent2)[i];
199 bool Continue =
true;
219 Continue =
evaluate(*mIndividual[i]);
235 size_t sweepNum = TotalPopulation;
240 for (i = 0; i < sweepNum; i++)
246 for (j = 0; j < TotalPopulation - 1; j++)
248 if ((
mPhi[j] == 0 &&
mPhi[j + 1] == 0) ||
269 if (wasSwapped ==
false)
break;
281 std::vector< COptItem * >::const_iterator it =
mpOptItem->begin();
282 std::vector< COptItem * >::const_iterator end =
mpOptItem->end();
285 for (; it != end; ++it, pValue++)
287 switch ((*it)->checkConstraint())
290 phiCalc = *(*it)->getLowerBoundValue() - *pValue;
291 phiVal += phiCalc * phiCalc;
295 phiCalc = *pValue - *(*it)->getUpperBoundValue();
296 phiVal += phiCalc * phiCalc;
304 for (; it != end; ++it)
306 phiCalc = (*it)->getConstraintViolation();
309 phiVal += phiCalc * phiCalc;
344 bool Continue =
true;
346 for (i = first; i < Last && Continue; i++)
351 COptItem & OptItem = *(*mpOptItem)[j];
360 if ((mn < 0.0) || (mx <= 0.0))
375 mut = (mx + mn) * 0.5;
380 (*(*mpSetCalculateVariable)[j])(mut);
421 if (
mPf < 0.0 || 1.0 <
mPf)
470 bool Continue =
true;
482 size_t Stalled, Stalled10, Stalled30, Stalled50;
483 Stalled = Stalled10 = Stalled30 = Stalled50 = 0;
490 (*
mIndividual[0])[i] = (*mpOptItem)[i]->getStartValue();
534 mGeneration++, Stalled++, Stalled10++, Stalled30++, Stalled50++)
537 if (Stalled > 50 && Stalled50 > 50)
541 Stalled10 = Stalled30 = Stalled50 = 0;
543 else if (Stalled > 30 && Stalled30 > 30)
547 Stalled10 = Stalled30 = 0;
549 else if (Stalled > 10 && Stalled10 > 10)
568 Stalled = Stalled10 = Stalled30 = Stalled50 = 0;
bool mutate(CVector< C_FLOAT64 > &individual)
virtual bool initialize()
C_FLOAT64 phi(size_t indvNum)
virtual C_FLOAT64 getRandomNormal(const C_FLOAT64 &mean, const C_FLOAT64 &sd)
CVector< C_FLOAT64 > mPhi
virtual C_FLOAT64 getRandomOO()
unsigned C_INT32 mPopulationSize
virtual ~COptMethodGASR()
void resize(size_t size, const bool ©=false)
COptProblem * mpOptProblem
const std::vector< COptItem * > * mpOptContraints
virtual void output(const COutputInterface::Activity &activity)
virtual bool progressItem(const size_t &handle)
CPermutation * mpPermutation
std::vector< CVector< C_FLOAT64 > * > mIndividual
unsigned C_INT32 mGenerations
static CRandom * createGenerator(CRandom::Type type=CRandom::mt19937, unsigned C_INT32 seed=0)
virtual C_FLOAT64 getRandomCC()
virtual unsigned C_INT32 getRandomU()
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
C_FLOAT64 mEvaluationValue
const std::vector< UpdateMethod * > * mpSetCalculateVariable
const Value & getValue() const
void shuffle(const size_t &swaps=C_INVALID_INDEX)
CVector< C_FLOAT64 > mValue
bool setValue(const std::string &name, const CType &value)
const C_FLOAT64 * getLowerBoundValue() const
COptMethodGASR(const COptMethodGASR &src, const CCopasiContainer *pParent=NULL)
virtual bool setSolution(const C_FLOAT64 &value, const CVector< C_FLOAT64 > &variables)
virtual bool finishItem(const size_t &handle)
C_FLOAT64 mMutationVarians
CVector< bool > mCrossOver
virtual bool initialize()
const std::vector< COptItem * > * mpOptItem
const C_FLOAT64 * getUpperBoundValue() const
bool addParameter(const CCopasiParameter ¶meter)
bool evaluate(const CVector< C_FLOAT64 > &individual)
bool crossover(const CVector< C_FLOAT64 > &parent1, const CVector< C_FLOAT64 > &parent2, CVector< C_FLOAT64 > &child1, CVector< C_FLOAT64 > &child2)
CVector< bool > mCrossOverFalse
bool swap(size_t from, size_t to)
const C_FLOAT64 & getCalculateValue() const
unsigned C_INT32 mGeneration
CCopasiObject * addObjectReference(const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
CProcessReport * mpCallBack
bool creation(size_t first, size_t last=std::numeric_limits< size_t >::max())