40 mEvaluationValue(std::numeric_limits<
C_FLOAT64 >::
max()),
45 mpOptProblemLocal(NULL),
46 mpLocalMinimizer(NULL)
70 mEvaluationValue(std::numeric_limits<
C_FLOAT64 >::
max()),
75 mpOptProblemLocal(NULL),
76 mpLocalMinimizer(NULL)
151 if (pFitProblem != NULL)
173 if (pFitProblem != NULL)
207 mRefSetVal = std::numeric_limits<C_FLOAT64>::infinity();
214 mChild.resize(mPopulationSize);
221 mChildVal = std::numeric_limits<C_FLOAT64>::infinity();
244 mPoolVal = std::numeric_limits<C_FLOAT64>::infinity();
247 mBestValue = std::numeric_limits<C_FLOAT64>::infinity();
251 mFreq.resize(mVariableSize);
277 for (i = 0; i <
mRefSet.size(); i++)
280 for (i = 0; i <
mChild.size(); i++)
283 for (i = 0; i <
mPool.size(); i++)
286 for (i = 0; i <
mFreq.size(); i++)
310 optitem[i]->setStartValue(solution[i]);
360 COptItem & OptItem = *(*mpOptItem)[j];
372 if ((mn < 0.0) || (mx <= 0.0))
386 Sol = (mx + mn) * 0.5;
403 (*(*mpSetCalculateVariable)[j])(Sol);
426 for (i = 0; (i < 4) && Running; i++)
431 COptItem & OptItem = *(*mpOptItem)[j];
443 if ((mn < 0.0) || (mx <= 0.0))
457 Sol = (mx + mn) * 0.5;
474 (*(*mpSetCalculateVariable)[j])(Sol);
485 COptItem & OptItem = *(*mpOptItem)[j];
505 (*(*mpSetCalculateVariable)[j])(Sol);
519 COptItem & OptItem = *(*mpOptItem)[j];
525 for (k = 0; k < 4; k++)
527 for (l = 0, sum = 0.0 ; l < 4; l++)
528 sum += 1.0 / (*
mFreq[j])[l];
538 for (k = 0; k < 4; k++)
549 if ((mn < 0.0) || (mx <= 0.0))
563 Sol = (mx + mn) * 0.5;
580 (*(*mpSetCalculateVariable)[j])(Sol);
602 for (i = 1; i < h; i++)
609 if (child == 0)
break;
611 parent = floor((
double)(child - 1) / 2);
619 tempvec =
mPool[child];
621 mPool[parent] = tempvec;
634 for (
size_t leaf = h / 2; leaf < h; leaf++)
644 if (child == 0)
continue;
652 tempvec =
mPool[child];
659 if (child == 0)
break;
661 parent = floor((
double)(child - 1) / 2);
669 tempvec =
mPool[child];
671 mPool[parent] = tempvec;
689 for (i = 0; i <= j; i++)
698 mPool[i + 1] = tempvec;
737 for (i = lower + 1; i < upper; i++)
744 if (child == 0)
break;
746 parent = floor((
double)(child - 1) / 2);
775 for (i = lower; i < j; i++)
805 mx = (fabs((*
mChild[i])[k]) + fabs((*
mPool[j])[k])) / 2.0;
807 if (fabs((*
mChild[i])[k] - (*
mPool[j])[k]) / mx > dist)
return false;
823 if (fabs((*
mRefSet[i])[k] - (*
mRefSet[j])[k]) / mx > dist)
return false;
849 xnew.
resize(mVariableSize);
850 xpr.
resize(mVariableSize);
867 if (i < j) alpha = 1.0;
else alpha = -1.0;
870 omatb = (1.0 + alpha * beta) * 0.5;
876 COptItem & OptItem = *(*mpOptItem)[k];
931 (*(*mpSetCalculateVariable)[k])(xnew[k]);
967 dd = (xpr[i] - (*
mChild[i])[k]) * lambda;
970 COptItem & OptItem = *(*mpOptItem)[k];
986 (*(*mpSetCalculateVariable)[k])(xnew[k]);
1005 if (improvement == 2)
1021 bool Running =
true;
1025 bestVal = std::numeric_limits<C_FLOAT64>::infinity();
1038 if (best == -1)
return true;
1072 bool Running =
true;
1152 if (needsort)
sortRefSet(0, mPopulationSize);
1193 if (needsort)
sortRefSet(0, mPopulationSize);
1242 std::ofstream ofile;
1244 ofile.open(
"ssprob.txt", std::ios::out);
1246 if (! ofile.is_open())
1248 std::cerr <<
"error opening file \'ssprob.txt\'" << std::endl;
1252 ofile <<
mProb << std::endl;
1264 std::ofstream ofile;
1267 ofile.open(
"sspool.txt", std::ios::out | std::ios::app);
1269 if (! ofile.is_open())
1271 std::cerr <<
"error opening file \'sspool.txt\'" << std::endl;
1275 for (i = first; i < Last; i++)
1281 ofile << mut <<
"\t";
1295 std::ofstream ofile;
1298 ofile.open(
"ssrefset.txt", std::ios::out | std::ios::app);
1300 if (! ofile.is_open())
1302 std::cerr <<
"error opening file \'ssrefset.txt\'" << std::endl;
1308 case 1: ofile <<
"element " << element <<
" improved in combination" << std::endl;
break;
1310 case 2: ofile <<
"element " << element <<
" improved in go-beyond" << std::endl;
break;
1312 case 3: ofile <<
"No element improved in iteration " << element << std::endl ;
break;
1314 case 4: ofile <<
"element " << element <<
" randomized, too close to another" << std::endl;
break;
1316 case 5: ofile <<
"element " << element <<
" randomized, was stuck" << std::endl;
break;
1318 case 6: ofile <<
"child" << element <<
" too close to previous solution, no local min" << std::endl;
break;
1320 case 7: ofile <<
"c1 is NaN (element" << element <<
")" << std::endl;
break;
1322 case 8: ofile <<
"c2 is NaN (element" << element <<
")" << std::endl;
break;
1324 case 9: ofile <<
"xnew[k] is NaN (element" << element <<
")" << std::endl;
break;
1326 case 10: ofile <<
"Children of " << element << std::endl;
break;
1328 case 11: ofile <<
"Local minimization at value " << element << std::endl;
break;
1340 std::ofstream ofile;
1343 ofile.open(
"ssrefset.txt", std::ios::out | std::ios::app);
1345 if (! ofile.is_open())
1347 std::cerr <<
"error opening file \'ssrefset.txt\'" << std::endl;
1351 ofile << std::endl <<
"Refset" << std::endl;
1353 for (i = first; i < Last; i++)
1359 ofile << mut <<
"\t";
1374 std::ofstream ofile;
1377 ofile.open(
"ssrefset.txt", std::ios::out | std::ios::app);
1379 if (! ofile.is_open())
1381 std::cerr <<
"error opening file \'ssrefset.txt\'" << std::endl;
1388 ofile << x[i] <<
"\t";
1392 ofile << xval << std::endl;
1405 std::ofstream ofile;
1408 ofile.open(
"sschild.txt", std::ios::out | std::ios::app);
1410 if (! ofile.is_open())
1412 std::cerr <<
"error opening file \'sschild.txt\'" << std::endl;
1416 for (i = first; i < Last; i++)
1422 ofile << mut <<
"\t";
virtual bool setObjectParent(const CCopasiContainer *pParent)
std::vector< CVector< C_INT32 > * > mFreq
virtual C_INT32 checkConstraint() const
void incrementEvaluations(unsigned C_INT32 increment)
virtual bool initialize()
bool closerRefSet(C_INT32 i, C_INT32 j, C_FLOAT64 dist)
unsigned C_INT32 mIterations
bool serializechildren(size_t first, size_t last)
CVector< C_FLOAT64 > mProb
void setProblem(COptProblem *problem)
virtual bool elevateChildren()
static COptMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
virtual bool initialize()
void resize(size_t size, const bool ©=false)
COptProblem * mpOptProblem
void sortRefSet(C_INT32 lower, C_INT32 upper)
virtual void output(const COutputInterface::Activity &activity)
CVector< C_FLOAT64 > mChildVal
std::vector< CVector< C_FLOAT64 > * > mChild
bool inforefset(C_INT32 type, C_INT32 element)
CVector< C_INT32 > mStuck
virtual bool progressItem(const size_t &handle)
bool evaluate(const CVector< C_FLOAT64 > &individual)
virtual bool setCallBack(CProcessReport *pCallBack)
bool removeParameter(const std::string &name)
std::vector< CVector< C_FLOAT64 > * > mPool
const C_FLOAT64 & getSolutionValue() const
static CRandom * createGenerator(CRandom::Type type=CRandom::mt19937, unsigned C_INT32 seed=0)
virtual C_FLOAT64 getRandomCC()
const std::vector< COptItem * > & getOptItemList() const
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
COptMethod * mpLocalMinimizer
unsigned C_INT32 mVariableSize
const Value & getValue() const
bool localmin(CVector< C_FLOAT64 > &solution, C_FLOAT64 &fval)
COptMethodSS(const COptMethodSS &src, const CCopasiContainer *pParent=NULL)
COptProblem * mpOptProblemLocal
bool setValue(const std::string &name, const CType &value)
const C_FLOAT64 * getLowerBoundValue() const
const CVector< C_FLOAT64 > & getSolutionVariables() const
virtual bool setSolution(const C_FLOAT64 &value, const CVector< C_FLOAT64 > &variables)
bool serializevector(CVector< C_FLOAT64 > x, C_FLOAT64 xval)
virtual bool finishItem(const size_t &handle)
virtual bool initializeSubtaskBeforeOutput()
CVector< C_FLOAT64 > mPoolVal
bool randomize(C_INT32 i)
unsigned C_INT32 mLocalStored
virtual bool checkFunctionalConstraints()
bool closerChild(C_INT32 i, C_INT32 j, C_FLOAT64 dist)
const C_FLOAT64 & getStartValue() const
void setRandomizeStartValues(const bool &randomize)
const std::vector< COptItem * > * mpOptItem
bool serializerefset(C_INT32 first, C_INT32 last)
unsigned C_INT32 mLocalIter
CVector< C_FLOAT64 > mRefSetVal
const C_FLOAT64 * getUpperBoundValue() const
bool serializepool(size_t first, size_t last)
virtual bool initialize()
bool addParameter(const CCopasiParameter ¶meter)
C_FLOAT64 mEvaluationValue
unsigned C_INT32 mIteration
std::vector< CVector< C_FLOAT64 > * > mRefSet
const unsigned C_INT32 & getFunctionEvaluations() const
const C_FLOAT64 & getCalculateValue() const
CCopasiObject * addObjectReference(const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
CProcessReport * mpCallBack
void setCalculateStatistics(const bool &calculate)
CCopasiContainer * getObjectParent() const
unsigned C_INT32 mLocalFreq