Skip to content

Commit 008e922

Browse files
committed
use std_vector more and getting NOT_IMPLEMENTING in C:\dev\z3\src\math\lp\dioph_eq.cpp
Signed-off-by: Lev Nachmanson <[email protected]>
1 parent 57b665d commit 008e922

15 files changed

+33
-37
lines changed

src/math/lp/dioph_eq.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ namespace lp {
328328
public:
329329
imp(int_solver& lia, lar_solver& lra) : lia(lia), lra(lra) {
330330
lra.register_add_term_delegate([this](const lar_term*t){add_term_delegate(t);});
331+
lra.register_add_column_bound_delegate([this](unsigned j) {add_column_bound_delegate(j);});
331332
}
332333
term_o get_term_from_entry(unsigned i) const {
333334
term_o t;
@@ -395,15 +396,10 @@ namespace lp {
395396
}
396397

397398
void init() {
398-
m_e_matrix = static_matrix<mpq, mpq>();
399399
m_report_branch = false;
400-
m_k2s.clear();
401-
m_fresh_definitions.clear();
402400
m_conflict_index = -1;
403401
m_infeas_explanation.clear();
404402
lia.get_term().clear();
405-
m_entries.clear();
406-
m_var_register.clear();
407403
m_number_of_iterations = 0;
408404
m_branch_stack.clear();
409405
m_lra_level = 0;
@@ -1071,7 +1067,6 @@ namespace lp {
10711067
if (m_branch_stack.size() == 0) {
10721068
lra.stats().m_dio_branching_infeasibles++;
10731069
transfer_explanations_from_closed_branches();
1074-
enable_trace("dioph_eq");
10751070
return lia_move::conflict;
10761071
}
10771072
TRACE("dio_br", tout << lp_status_to_string(lra.get_status()) << std::endl;
@@ -1393,7 +1388,7 @@ namespace lp {
13931388
m_e_matrix.add_new_element(fresh_row, i, q);
13941389
}
13951390

1396-
m_k2s.resize(std::max(k + 1, xt + 1), -1);
1391+
m_k2s.resize(k + 1, -1);
13971392
m_k2s[k] = fresh_row;
13981393
m_fresh_definitions.resize(xt + 1, -1);
13991394
m_fresh_definitions[xt] = fresh_row;

src/math/lp/int_solver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ namespace lp {
668668
return display_row(out, row);
669669
}
670670

671-
std::ostream & int_solver::display_row(std::ostream & out, vector<row_cell<rational>> const & row) const {
671+
std::ostream & int_solver::display_row(std::ostream & out, std_vector<row_cell<rational>> const & row) const {
672672
return m_imp->display_row(out, row);
673673
}
674674

src/math/lp/int_solver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class int_solver {
8989

9090
bool shift_var(unsigned j, unsigned range);
9191
std::ostream& display_row_info(std::ostream & out, unsigned row_index) const;
92-
std::ostream & display_row(std::ostream & out, vector<row_cell<rational>> const & row) const;
92+
std::ostream & display_row(std::ostream & out, std_vector<row_cell<rational>> const & row) const;
9393
bool is_term(unsigned j) const;
9494
unsigned column_count() const;
9595
int select_int_infeasible_var();

src/math/lp/lar_core_solver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class lar_core_solver {
3434
stacked_vector<unsigned> m_r_pushed_basis;
3535
vector<unsigned> m_r_basis;
3636
vector<unsigned> m_r_nbasis;
37-
vector<int> m_r_heading;
37+
std_vector<int> m_r_heading;
3838

3939

4040
lp_primal_core_solver<mpq, numeric_pair<mpq>> m_r_solver; // solver in rational numbers

src/math/lp/lar_solver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ class lar_solver : public column_namer {
684684
bool ax_is_correct() const;
685685
bool get_equality_and_right_side_for_term_on_current_x(lpvar j, mpq& rs, u_dependency*& ci, bool& upper_bound) const;
686686
bool var_is_int(lpvar v) const;
687-
inline const vector<int>& r_heading() const { return m_mpq_lar_core_solver.m_r_heading; }
687+
inline const std_vector<int>& r_heading() const { return m_mpq_lar_core_solver.m_r_heading; }
688688
inline const vector<unsigned>& r_basis() const { return m_mpq_lar_core_solver.r_basis(); }
689689
inline const vector<unsigned>& r_nbasis() const { return m_mpq_lar_core_solver.r_nbasis(); }
690690
inline bool column_is_real(unsigned j) const { return !column_is_int(j); }

src/math/lp/lp_core_solver_base.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::init
3030
template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::init_basis_heading_and_non_basic_columns_vector();
3131
template lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::lp_core_solver_base(lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&,
3232
// vector<lp::numeric_pair<lp::mpq> >&,
33-
vector<unsigned int >&, vector<unsigned> &, vector<int> &, vector<lp::numeric_pair<lp::mpq> >&, vector<lp::mpq>&, lp::lp_settings&, const column_namer&, const vector<lp::column_type >&,
33+
vector<unsigned int >&, vector<unsigned> &, std_vector<int> &, vector<lp::numeric_pair<lp::mpq> >&, vector<lp::mpq>&, lp::lp_settings&, const column_namer&, const vector<lp::column_type >&,
3434
const vector<lp::numeric_pair<lp::mpq> >&,
3535
const vector<lp::numeric_pair<lp::mpq> >&);
3636

@@ -39,7 +39,8 @@ template lp::lp_core_solver_base<lp::mpq, lp::mpq>::lp_core_solver_base(
3939
lp::static_matrix<lp::mpq, lp::mpq>&,
4040
//vector<lp::mpq>&,
4141
vector<unsigned int >&,
42-
vector<unsigned> &, vector<int> &,
42+
vector<unsigned> &,
43+
std_vector<int> &,
4344
vector<lp::mpq>&,
4445
vector<lp::mpq>&,
4546
lp::lp_settings&,

src/math/lp/lp_core_solver_base.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class lp_core_solver_base {
7979
// vector<X> const & m_b; // the right side
8080
vector<unsigned> & m_basis;
8181
vector<unsigned>& m_nbasis;
82-
vector<int>& m_basis_heading;
82+
std_vector<int>& m_basis_heading;
8383
vector<X> & m_x; // a feasible solution, the first time set in the constructor
8484
vector<T> & m_costs;
8585
lp_settings & m_settings;
@@ -124,7 +124,7 @@ class lp_core_solver_base {
124124
//vector<X> & b, // the right side vector
125125
vector<unsigned> & basis,
126126
vector<unsigned> & nbasis,
127-
vector<int> & heading,
127+
std_vector<int> & heading,
128128
vector<X> & x,
129129
vector<T> & costs,
130130
lp_settings & settings,
@@ -516,8 +516,8 @@ class lp_core_solver_base {
516516
}
517517

518518

519-
template <typename K>
520-
static void swap(vector<K> &v, unsigned i, unsigned j) noexcept {
519+
template <typename T>
520+
void swap(T &v, unsigned i, unsigned j) noexcept {
521521
auto t = v[i];
522522
v[i] = v[j];
523523
v[j] = t;

src/math/lp/lp_core_solver_base_def.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ lp_core_solver_base(static_matrix<T, X> & A,
3131
// vector<X> & b, // the right side vector
3232
vector<unsigned> & basis,
3333
vector<unsigned> & nbasis,
34-
vector<int> & heading,
34+
std_vector<int> & heading,
3535
vector<X> & x,
3636
vector<T> & costs,
3737
lp_settings & settings,

src/math/lp/lp_primal_core_solver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ namespace lp {
640640
vector<X> &b, // the right side vector
641641
vector<X> &x, // the number of elements in x needs to be at least as large
642642
// as the number of columns in A
643-
vector<unsigned> &basis, vector<unsigned> &nbasis, vector<int> &heading,
643+
vector<unsigned> &basis, vector<unsigned> &nbasis, std_vector<int> &heading,
644644
vector<T> &costs, const vector<column_type> &column_type_array,
645645
const vector<X> &lower_bound_values, const vector<X> &upper_bound_values,
646646
lp_settings &settings, const column_namer &column_names)

src/math/lp/nla_common.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ template <typename T> void common::create_sum_from_row(const T& row,
127127

128128

129129
}
130-
template void nla::common::create_sum_from_row<vector<lp::row_cell<rational>, true, unsigned int> >(vector<lp::row_cell<rational>, true, unsigned int> const&, nla::nex_creator&, nla::nex_creator::sum_factory&, u_dependency*&);
130+
template void nla::common::create_sum_from_row<std_vector<lp::row_cell<rational>> >(std_vector<lp::row_cell<rational>> const&, nla::nex_creator&, nla::nex_creator::sum_factory&, u_dependency*&);

src/math/lp/nla_grobner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ namespace nla {
558558
add_eq(r, dep);
559559
}
560560

561-
void grobner::add_row(const vector<lp::row_cell<rational>> & row) {
561+
void grobner::add_row(const std_vector<lp::row_cell<rational>> & row) {
562562
u_dependency *dep = nullptr;
563563
rational val;
564564
dd::pdd sum = m_pdd_manager.mk_val(rational(0));

src/math/lp/nla_grobner.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace nla {
6060
void find_nl_cluster();
6161
void prepare_rows_and_active_vars();
6262
void add_var_and_its_factors_to_q_and_collect_new_rows(lpvar j, svector<lpvar>& q);
63-
void add_row(const vector<lp::row_cell<rational>>& row);
63+
void add_row(const std_vector<lp::row_cell<rational>>& row);
6464
void add_fixed_monic(unsigned j);
6565
bool is_solved(dd::pdd const& p, unsigned& v, dd::pdd& r);
6666
void add_eq(dd::pdd& p, u_dependency* dep);

src/math/lp/static_matrix.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ template void static_matrix<mpq, numeric_pair<mpq> >::set(unsigned int, unsigned
5454
template bool lp::static_matrix<lp::mpq, lp::mpq>::pivot_row_to_row_given_cell(unsigned int, column_cell& , unsigned int);
5555
template bool lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::pivot_row_to_row_given_cell(unsigned int, column_cell&, unsigned int);
5656
template void lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::pivot_row_to_row_given_cell_with_sign(unsigned int, column_cell&, unsigned int, int);
57-
template void lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::remove_element(vector<lp::row_cell<lp::mpq>, true, unsigned int>&, lp::row_cell<lp::mpq>&);
5857
template void lp::static_matrix<mpq, mpq>::pivot_row_to_row_given_cell_with_sign(unsigned int, lp::row_cell<lp::empty_struct>&, unsigned int, int);
5958
template void lp::static_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::add_rows(mpq const&, unsigned int, unsigned int);
6059
template void lp::static_matrix<lp::mpq,lp::mpq>::add_rows(class rational const &,unsigned int,unsigned int);

src/math/lp/static_matrix.h

+14-13
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ std::ostream& operator<<(std::ostream& out, const row_cell<T>& rc) {
4141
}
4242
struct empty_struct {};
4343
typedef row_cell<empty_struct> column_cell;
44-
typedef vector<column_cell> column_strip;
44+
typedef std_vector<column_cell> column_strip;
4545

4646
template <typename T>
47-
using row_strip = vector<row_cell<T>>;
47+
using row_strip = std_vector<row_cell<T>>;
4848
template <typename K> mpq get_denominators_lcm(const K & row) {
4949
SASSERT(row.size() > 0);
5050
mpq r = mpq(1);
@@ -79,8 +79,8 @@ class static_matrix
7979

8080
vector<int> m_work_vector_of_row_offsets;
8181
indexed_vector<T> m_work_vector;
82-
vector<row_strip<T>> m_rows;
83-
vector<column_strip> m_columns;
82+
std_vector<row_strip<T>> m_rows;
83+
std_vector<column_strip> m_columns;
8484
// starting inner classes
8585
class ref {
8686
static_matrix & m_matrix;
@@ -153,7 +153,7 @@ class static_matrix
153153

154154
void remove_last_column(unsigned j);
155155

156-
void remove_element(vector<row_cell<T>> & row, row_cell<T> & elem_to_remove);
156+
void remove_element(std_vector<row_cell<T>> & row, row_cell<T> & elem_to_remove);
157157

158158
void multiply_column(unsigned column, T const & alpha) {
159159
for (auto & t : m_columns[column]) {
@@ -245,7 +245,7 @@ class static_matrix
245245
m_stack.push(d);
246246
}
247247

248-
void pop_row_columns(const vector<row_cell<T>> & row) {
248+
void pop_row_columns(const std_vector<row_cell<T>> & row) {
249249
for (auto & c : row) {
250250
unsigned j = c.var();
251251
auto & col = m_columns[j];
@@ -291,7 +291,7 @@ class static_matrix
291291
}
292292
}
293293

294-
T dot_product_with_column(const vector<T> & y, unsigned j) const {
294+
T dot_product_with_column(const std_vector<T> & y, unsigned j) const {
295295
lp_assert(j < column_count());
296296
T ret = numeric_traits<T>::zero();
297297
for (auto & it : m_columns[j]) {
@@ -320,7 +320,7 @@ class static_matrix
320320
}
321321

322322
}
323-
void fill_last_row_with_pivoting_loop_block(unsigned j, const vector<int> & basis_heading) {
323+
void fill_last_row_with_pivoting_loop_block(unsigned j, const std_vector<int> & basis_heading) {
324324
int row_index = basis_heading[j];
325325
if (row_index < 0)
326326
return;
@@ -352,7 +352,7 @@ class static_matrix
352352
template <typename term>
353353
void fill_last_row_with_pivoting(const term& row,
354354
unsigned bj, // the index of the basis column
355-
const vector<int> & basis_heading) {
355+
const std_vector<int> & basis_heading) {
356356
lp_assert(row_count() > 0);
357357
m_work_vector.resize(column_count());
358358
T a;
@@ -377,7 +377,7 @@ class static_matrix
377377
set(last_row, column_count() - 1, one_of_type<T>());
378378
}
379379

380-
void copy_column_to_vector (unsigned j, vector<T> & v) const {
380+
void copy_column_to_vector (unsigned j, std_vector<T> & v) const {
381381
v.resize(row_count(), numeric_traits<T>::zero());
382382
for (auto & it : m_columns[j]) {
383383
const T& val = get_val(it);
@@ -387,7 +387,7 @@ class static_matrix
387387
}
388388

389389
template <typename L>
390-
L dot_product_with_row(unsigned row, const vector<L> & w) const {
390+
L dot_product_with_row(unsigned row, const std_vector<L> & w) const {
391391
L ret = zero_of_type<L>();
392392
lp_assert(row < m_rows.size());
393393
for (auto & it : m_rows[row]) {
@@ -444,11 +444,12 @@ class static_matrix
444444
};
445445

446446
const_iterator begin() const {
447-
return const_iterator(m_A.m_columns[m_j].begin(), m_A);
447+
return const_iterator(m_A.m_columns[m_j].data(), m_A);
448448
}
449449

450450
const_iterator end() const {
451-
return const_iterator(m_A.m_columns[m_j].end(), m_A);
451+
const auto & column = m_A.m_columns[m_j];
452+
return const_iterator(column.data() + column.size(), m_A);
452453
}
453454
};
454455

src/math/lp/static_matrix_def.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ template <typename T, typename X> bool static_matrix<T, X>::is_correct() const {
421421
}
422422

423423
template <typename T, typename X>
424-
void static_matrix<T, X>::remove_element(vector<row_cell<T>> & row_vals, row_cell<T> & row_el_iv) {
424+
void static_matrix<T, X>::remove_element(std_vector<row_cell<T>> & row_vals, row_cell<T> & row_el_iv) {
425425
unsigned column_offset = row_el_iv.offset();
426426
auto & column_vals = m_columns[row_el_iv.var()];
427427
column_cell& cs = m_columns[row_el_iv.var()][column_offset];

0 commit comments

Comments
 (0)