3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-10-07 19:24:30 +01:00
commit c1b243a8e3
45 changed files with 1345 additions and 699 deletions

View file

@ -33,6 +33,7 @@ template void indexed_vector<unsigned>::resize(unsigned int);
template void indexed_vector<mpq>::set_value(const mpq&, unsigned int);
template void indexed_vector<unsigned>::set_value(const unsigned&, unsigned int);
#ifdef Z3DEBUG
template bool indexed_vector<unsigned>::is_OK() const;
template bool indexed_vector<double>::is_OK() const;
template bool indexed_vector<mpq>::is_OK() const;
template bool indexed_vector<lp::numeric_pair<mpq> >::is_OK() const;

View file

@ -417,6 +417,8 @@ public:
for (unsigned i : m_rows_with_changed_bounds.m_index) {
calculate_implied_bounds_for_row(i, bp);
if (settings().get_cancel_flag())
return;
}
m_rows_with_changed_bounds.clear();
if (!use_tableau()) {

View file

@ -176,25 +176,34 @@ unsigned lp_primal_core_solver<T, X>::solve_with_tableau() {
default:
break; // do nothing
}
} while (this->get_status() != FLOATING_POINT_ERROR
&&
this->get_status() != UNBOUNDED
&&
this->get_status() != OPTIMAL
&&
this->get_status() != INFEASIBLE
&&
this->iters_with_no_cost_growing() <= this->m_settings.max_number_of_iterations_with_no_improvements
&&
this->total_iterations() <= this->m_settings.max_total_number_of_iterations
&&
!(this->current_x_is_feasible() && this->m_look_for_feasible_solution_only));
} while (this->get_status() != FLOATING_POINT_ERROR
&&
this->get_status() != UNBOUNDED
&&
this->get_status() != OPTIMAL
&&
this->get_status() != INFEASIBLE
&&
this->iters_with_no_cost_growing() <= this->m_settings.max_number_of_iterations_with_no_improvements
&&
this->total_iterations() <= this->m_settings.max_total_number_of_iterations
&&
!(this->current_x_is_feasible() && this->m_look_for_feasible_solution_only)
&&
this->m_settings.get_cancel_flag() == false);
if (this->m_settings.get_cancel_flag()) {
this->set_status(CANCELLED);
}
SASSERT(this->get_status() == FLOATING_POINT_ERROR
||
this->current_x_is_feasible() == false
||
this->calc_current_x_is_feasible_include_non_basis());
SASSERT(
this->get_status() == FLOATING_POINT_ERROR
||
this->get_status() == CANCELLED
||
this->current_x_is_feasible() == false
||
this->calc_current_x_is_feasible_include_non_basis());
return this->total_iterations();
}

View file

@ -61,7 +61,8 @@ enum lp_status {
TIME_EXHAUSTED,
ITERATIONS_EXHAUSTED,
EMPTY,
UNSTABLE
UNSTABLE,
CANCELLED
};
// when the ratio of the vector lenth to domain size to is greater than the return value we switch to solve_By_for_T_indexed_only

View file

@ -21,6 +21,7 @@ Revision History:
reslimit::reslimit():
m_cancel(0),
m_suspend(false),
m_count(0),
m_limit(0) {
}
@ -31,12 +32,12 @@ uint64 reslimit::count() const {
bool reslimit::inc() {
++m_count;
return m_cancel == 0 && (m_limit == 0 || m_count <= m_limit);
return (m_cancel == 0 && (m_limit == 0 || m_count <= m_limit)) || m_suspend;
}
bool reslimit::inc(unsigned offset) {
m_count += offset;
return m_cancel == 0 && (m_limit == 0 || m_count <= m_limit);
return (m_cancel == 0 && (m_limit == 0 || m_count <= m_limit)) || m_suspend;
}
void reslimit::push(unsigned delta_limit) {

View file

@ -23,12 +23,14 @@ Revision History:
class reslimit {
volatile unsigned m_cancel;
bool m_suspend;
uint64 m_count;
uint64 m_limit;
svector<uint64> m_limits;
ptr_vector<reslimit> m_children;
void set_cancel(unsigned f);
friend class scoped_suspend_rlimit;
public:
reslimit();
@ -42,7 +44,7 @@ public:
uint64 count() const;
bool get_cancel_flag() const { return m_cancel > 0; }
bool get_cancel_flag() const { return m_cancel > 0 && !m_suspend; }
char const* get_cancel_msg() const;
void cancel();
void reset_cancel();
@ -61,6 +63,17 @@ public:
};
class scoped_suspend_rlimit {
reslimit & m_limit;
public:
scoped_suspend_rlimit(reslimit& r): m_limit(r) {
r.m_suspend = true;
}
~scoped_suspend_rlimit() {
m_limit.m_suspend = false;
}
};
struct scoped_limits {
reslimit& m_limit;
unsigned m_sz;