feat: add an accessor to eoEvalIOH
Useful for using ParadisEO with IOHexperimenter's suites without having to do costly reallocation of operators.
This commit is contained in:
parent
a436fb3fa0
commit
7a6f9a640f
1 changed files with 18 additions and 5 deletions
|
|
@ -23,12 +23,12 @@ class eoEvalIOH : public eoEvalFunc<EOT>
|
||||||
using ScalarType = typename Fitness::ScalarType;
|
using ScalarType = typename Fitness::ScalarType;
|
||||||
|
|
||||||
eoEvalIOH( IOHprofiler_problem<ScalarType> & pb) :
|
eoEvalIOH( IOHprofiler_problem<ScalarType> & pb) :
|
||||||
_ioh_pb(pb),
|
_ioh_pb(&pb),
|
||||||
_has_log(false)
|
_has_log(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
eoEvalIOH( IOHprofiler_problem<ScalarType> & pb, IOHprofiler_csv_logger & log ) :
|
eoEvalIOH( IOHprofiler_problem<ScalarType> & pb, IOHprofiler_csv_logger & log ) :
|
||||||
_ioh_pb(pb),
|
_ioh_pb(&pb),
|
||||||
_has_log(true),
|
_has_log(true),
|
||||||
_ioh_log(log)
|
_ioh_log(log)
|
||||||
{ }
|
{ }
|
||||||
|
|
@ -42,16 +42,29 @@ class eoEvalIOH : public eoEvalFunc<EOT>
|
||||||
sol.fitness( call( sol ) );
|
sol.fitness( call( sol ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Update the problem pointer for a new one.
|
||||||
|
*
|
||||||
|
* This is useful if you assembled a ParadisEO algorithm
|
||||||
|
* and call it several time in an IOHexperimenter's suite loop.
|
||||||
|
* Instead of re-assembling your algorithm,
|
||||||
|
* just update the problem pointer.
|
||||||
|
*/
|
||||||
|
void problem( IOHprofiler_problem<ScalarType> & pb )
|
||||||
|
{
|
||||||
|
assert(_ioh_pb != nullptr );
|
||||||
|
_ioh_pb = &pb;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IOHprofiler_problem<ScalarType> & _ioh_pb;
|
IOHprofiler_problem<ScalarType> * _ioh_pb;
|
||||||
bool _has_log;
|
bool _has_log;
|
||||||
IOHprofiler_csv_logger & _ioh_log;
|
IOHprofiler_csv_logger & _ioh_log;
|
||||||
|
|
||||||
virtual Fitness call(EOT& sol)
|
virtual Fitness call(EOT& sol)
|
||||||
{
|
{
|
||||||
Fitness f = _ioh_pb.evaluate(sol);
|
Fitness f = _ioh_pb->evaluate(sol);
|
||||||
if(_has_log) {
|
if(_has_log) {
|
||||||
_ioh_log.write_line(_ioh_pb.loggerInfo());
|
_ioh_log.write_line(_ioh_pb->loggerInfo());
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue