mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
review comments by Elffers
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
e593b5b2c8
commit
a9a26e5f2e
4 changed files with 54 additions and 2 deletions
|
@ -1400,6 +1400,12 @@ namespace sat {
|
|||
unsigned ci = ineq.coeff(i);
|
||||
unsigned q = ci % c;
|
||||
if (q != 0 && !is_false(ineq.lit(i))) {
|
||||
#if 1
|
||||
// code review by Elffers:
|
||||
ineq.weaken(i);
|
||||
--i;
|
||||
--sz;
|
||||
#else
|
||||
if (q == ci) {
|
||||
ineq.weaken(i);
|
||||
--i;
|
||||
|
@ -1409,6 +1415,7 @@ namespace sat {
|
|||
ineq.m_wlits[i].first -= q;
|
||||
ineq.m_k -= q;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ineq.divide(c);
|
||||
|
|
|
@ -48,6 +48,7 @@ def_module_params('sat',
|
|||
('drat.check_sat', BOOL, False, 'build up internal trace, check satisfying model'),
|
||||
('cardinality.solver', BOOL, True, 'use cardinality solver'),
|
||||
('pb.solver', SYMBOL, 'solver', 'method for handling Pseudo-Boolean constraints: circuit (arithmetical circuit), sorting (sorting circuit), totalizer (use totalizer encoding), binary_merge, segmented, solver (use native solver)'),
|
||||
('pb.min_arity', UINT, 9, 'minimal arity to compile pb/cardinality constraints to CNF'),
|
||||
('xor.solver', BOOL, False, 'use xor solver'),
|
||||
('cardinality.encoding', SYMBOL, 'grouped', 'encoding used for at-most-k constraints: grouped, bimander, ordered, unate, circuit'),
|
||||
('pb.resolve', SYMBOL, 'cardinality', 'resolution strategy for boolean algebra solver: cardinality, rounding'),
|
||||
|
|
|
@ -3161,12 +3161,42 @@ namespace sat {
|
|||
m_activity_inc = 128;
|
||||
svector<bool_var> vars;
|
||||
for (bool_var v = num_vars(); v-- > 0; ) {
|
||||
vars.push_back(v);
|
||||
if (!was_eliminated(v) && value(v) == l_undef) {
|
||||
vars.push_back(v);
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
//
|
||||
// exp(logits[i]) / sum(exp(logits))
|
||||
// =
|
||||
// exp(log(exp(logits[i]) / sum(exp(logits))))
|
||||
// =
|
||||
// exp(log(exp(logits[i])) - log(sum(exp(logits))))
|
||||
// =
|
||||
// exp(logits[i] - lse)
|
||||
svector<float> logits(vars.size(), 0.0);
|
||||
float itau = 4.0;
|
||||
float lse = 0;
|
||||
float mid = m_rand.max_value()/2;
|
||||
float max = 0;
|
||||
for (float& f : logits) {
|
||||
f = itau * (m_rand() - mid)/mid;
|
||||
if (f > max) max = f;
|
||||
}
|
||||
for (float f : logits) {
|
||||
lse += log(f - max);
|
||||
}
|
||||
lse = max + exp(lse);
|
||||
|
||||
for (unsigned i = 0; i < vars.size(); ++i) {
|
||||
update_activity(vars[i], exp(logits[i] - lse));
|
||||
}
|
||||
#else
|
||||
shuffle(vars.size(), vars.c_ptr(), m_rand);
|
||||
for (bool_var v : vars) {
|
||||
update_activity(v, m_rand(10));
|
||||
update_activity(v, m_rand(10)/10.0);
|
||||
}
|
||||
#endif
|
||||
m_reorder_inc += m_config.m_reorder_base;
|
||||
m_reorder_lim += m_reorder_inc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue