13#if !defined(ULTRA_EVALUATOR_PROXY_H)
14# error "Don't include this file directly, include the specific .h instead"
17#if !defined(ULTRA_EVALUATOR_PROXY_TCC)
18#define ULTRA_EVALUATOR_PROXY_TCC
28evaluator_proxy<E>::evaluator_proxy(E eva, bitwidth ts) : eva_(
std::move(eva)),
31 static_assert(!std::derived_from<E, evaluator_proxy>);
34 ultraWARNING(
"Evaluator proxy cache is disabled");
48evaluator_fitness_t<E> evaluator_proxy<E>::operator()(
49 const evaluator_individual_t<E> &prg)
const
54 if (
const auto cached_fit(cache_.find(prg.signature())); cached_fit)
58 const auto effective_fit(eva_(prg));
60 if (!almost_equal(*cached_fit, effective_fit)) [[unlikely]]
62 ultraERROR(
"COLLISION [{} != {}]",
63 internal::streamed(*cached_fit),
64 internal::streamed(effective_fit));
89 const auto effective_fit(eva_(prg));
90 cache_.insert(prg.signature(), effective_fit);
105evaluator_fitness_t<E> evaluator_proxy<E>::fast(
106 const evaluator_individual_t<E> &prg)
const
108 if constexpr (
requires { eva_.fast(prg); })
109 return eva_.fast(prg);
111 return operator()(prg);
125bool evaluator_proxy<E>::load_cache(std::istream &in)
const
127 return cache_.load(in);
143bool evaluator_proxy<E>::load(std::istream &in)
145 return load_eva(in, &eva_) && load_cache(in);
155bool evaluator_proxy<E>::save_cache(std::ostream &
out)
const
157 return cache_.save(
out);
171bool evaluator_proxy<E>::save(std::ostream &
out)
const
183void evaluator_proxy<E>::clear() const noexcept
195void evaluator_proxy<E>::clear(
const hash_t &h)
const
213bool evaluator_proxy<E>::set_parallel_evaluation(
unsigned helpers,
214 std::size_t min_samples)
216 if constexpr (
requires {eva_.set_parallel_evaluation(helpers, min_samples);})
217 return eva_.set_parallel_evaluation(helpers, min_samples);
228const E &evaluator_proxy<E>::core() const noexcept
bool save_eva(std::ostream &out, const E &e)
Definition evaluator.tcc:121
bool load_eva(std::istream &in, E *e)
Definition evaluator.tcc:93