Skip to content

Commit

Permalink
adjust heuristic in random-inc-dec for finite domains
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <[email protected]>
  • Loading branch information
NikolajBjorner committed Jan 12, 2025
1 parent 97acf71 commit 9770c00
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ast/sls/sls_arith_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2578,6 +2578,7 @@ namespace sls {
return 0.0;
auto d = value.get_double();
double score = 1.0 - ((d * d) / ((double)max_value * (double)max_value));
//score = 1.0 - d / max_value;
return score;
}

Expand Down Expand Up @@ -2855,7 +2856,10 @@ namespace sls {
unsigned idx = ctx.rand() % m_updates.size();
auto& [v, delta, score] = m_updates[idx];
m_best_expr = m_vars[v].m_expr;
m_best_value = value(v) + delta;
if (false && !m_vars[v].m_finite_domain.empty())
m_best_value = m_vars[v].m_finite_domain[ctx.rand() % m_vars[v].m_finite_domain.size()];
else
m_best_value = value(v) + delta;
break;
}
case arith_move_type::hillclimb: {
Expand All @@ -2881,7 +2885,10 @@ namespace sls {
m_best_expr = e;
if (a.is_int_real(e)) {
var_t v = mk_term(e);
if (ctx.rand(2) == 0)
auto& vi = m_vars[v];
if (!vi.m_finite_domain.empty())
m_best_value = vi.m_finite_domain[ctx.rand() % vi.m_finite_domain.size()];
else if (ctx.rand(2) == 0)
m_best_value = value(v) + 1;
else
m_best_value = value(v) - 1;
Expand Down

0 comments on commit 9770c00

Please sign in to comment.