mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 03:15:50 +00:00
* replace u_set by indexed_uint_set * replace u_set by indexed_uint_set * create insert-fresh and insert for indexed_uint_set to make use cases with non-fresh inserts easier Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * update nightly to pull arm Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * update nightly to pull arm Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * fixing the build of lp_tst * update nightly to pull arm Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * replace u_set by indexed_uint_set * replace u_set by indexed_uint_set * fixing the build of lp_tst * remove unnecessery call to contains() before insert to indexed_uint_set * formatting, no check for contains() in indexed_uint_set, always init m_touched_rows to nullptr --------- Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com>
84 lines
2.1 KiB
C++
84 lines
2.1 KiB
C++
/*++
|
|
Copyright (c) 2017 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
<name>
|
|
|
|
Abstract:
|
|
|
|
<abstract>
|
|
|
|
Author:
|
|
|
|
Lev Nachmanson (levnach)
|
|
|
|
Revision History:
|
|
|
|
|
|
--*/
|
|
#pragma once
|
|
|
|
#include "math/lp/random_updater.h"
|
|
#include "math/lp/static_matrix.h"
|
|
#include "math/lp/lar_solver.h"
|
|
#include "util/vector.h"
|
|
namespace lp {
|
|
|
|
|
|
|
|
random_updater::random_updater(
|
|
lar_solver & lar_solver,
|
|
const vector<unsigned> & column_indices) :
|
|
m_lar_solver(lar_solver),
|
|
m_range(100000) {
|
|
for (unsigned j : column_indices)
|
|
m_var_set.insert(j);
|
|
TRACE("lar_solver_rand", tout << "size = " << m_var_set.size() << "\n";);
|
|
}
|
|
|
|
|
|
bool random_updater::shift_var(unsigned j) {
|
|
SASSERT(!m_lar_solver.column_is_fixed(j) && !m_lar_solver.is_base(j));
|
|
bool ret = m_lar_solver.get_int_solver()->shift_var(j, m_range);
|
|
if (ret) {
|
|
const auto & A = m_lar_solver.A_r();
|
|
for (const auto& c : A.m_columns[j]) {
|
|
unsigned k = m_lar_solver.r_basis()[c.var()];
|
|
if (m_var_set.contains(k))
|
|
m_var_set.remove(k);
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
|
|
void random_updater::update() {
|
|
// VERIFY(m_lar_solver.check_feasible());
|
|
unsigned_vector columns;
|
|
// m_var_set is going to change during the loop, make a copy
|
|
for (unsigned j : m_var_set) {
|
|
columns.push_back(j);
|
|
}
|
|
for (auto j : columns) {
|
|
if (!m_var_set.contains(j)) {
|
|
TRACE("lar_solver_rand", tout << "skipped " << j << "\n";);
|
|
continue;
|
|
}
|
|
if (!m_lar_solver.is_base(j))
|
|
shift_var(j);
|
|
else {
|
|
unsigned row_index = m_lar_solver.r_heading()[j];
|
|
for (auto & row_c : m_lar_solver.get_row(row_index)) {
|
|
unsigned cj = row_c.var();
|
|
if (!m_lar_solver.is_base(cj) &&
|
|
!m_lar_solver.column_is_fixed(cj) &&
|
|
shift_var(cj))
|
|
break; // done with the basic var j
|
|
}
|
|
}
|
|
}
|
|
TRACE("lar_solver_rand", tout << "m_var_set.size() = " << m_var_set.size() << "\n";);
|
|
}
|
|
|
|
}
|