mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 20:18:18 +00:00
get rid of timeb dependencies, pull request #1040
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
edb164587f
commit
23ff580a67
|
@ -55,10 +55,6 @@ public:
|
||||||
|
|
||||||
void set_core_solver_bounds();
|
void set_core_solver_bounds();
|
||||||
|
|
||||||
void update_time_limit_from_starting_time(int start_time) {
|
|
||||||
this->m_settings.time_limit -= (get_millisecond_span(start_time) / 1000.);
|
|
||||||
}
|
|
||||||
|
|
||||||
void find_maximal_solution();
|
void find_maximal_solution();
|
||||||
|
|
||||||
void fill_A_x_and_basis_for_stage_one_total_inf();
|
void fill_A_x_and_basis_for_stage_one_total_inf();
|
||||||
|
|
|
@ -152,7 +152,6 @@ template <typename T, typename X> void lp_primal_simplex<T, X>::set_core_solver_
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename X> void lp_primal_simplex<T, X>::find_maximal_solution() {
|
template <typename T, typename X> void lp_primal_simplex<T, X>::find_maximal_solution() {
|
||||||
int preprocessing_start_time = get_millisecond_count();
|
|
||||||
if (this->problem_is_empty()) {
|
if (this->problem_is_empty()) {
|
||||||
this->m_status = lp_status::EMPTY;
|
this->m_status = lp_status::EMPTY;
|
||||||
return;
|
return;
|
||||||
|
@ -169,7 +168,6 @@ template <typename T, typename X> void lp_primal_simplex<T, X>::find_maximal_sol
|
||||||
fill_acceptable_values_for_x();
|
fill_acceptable_values_for_x();
|
||||||
this->count_slacks_and_artificials();
|
this->count_slacks_and_artificials();
|
||||||
set_core_solver_bounds();
|
set_core_solver_bounds();
|
||||||
update_time_limit_from_starting_time(preprocessing_start_time);
|
|
||||||
solve_with_total_inf();
|
solve_with_total_inf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <sys/timeb.h>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include "util/lp/lp_utils.h"
|
#include "util/lp/lp_utils.h"
|
||||||
|
#include "util/stopwatch.h"
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
typedef unsigned var_index;
|
typedef unsigned var_index;
|
||||||
|
@ -69,10 +69,6 @@ enum non_basic_column_value_position { at_low_bound, at_upper_bound, at_fixed, f
|
||||||
|
|
||||||
template <typename X> bool is_epsilon_small(const X & v, const double& eps); // forward definition
|
template <typename X> bool is_epsilon_small(const X & v, const double& eps); // forward definition
|
||||||
|
|
||||||
int get_millisecond_count();
|
|
||||||
int get_millisecond_span(int start_time);
|
|
||||||
|
|
||||||
|
|
||||||
class lp_resource_limit {
|
class lp_resource_limit {
|
||||||
public:
|
public:
|
||||||
virtual bool get_cancel_flag() = 0;
|
virtual bool get_cancel_flag() = 0;
|
||||||
|
@ -92,12 +88,13 @@ struct lp_settings {
|
||||||
private:
|
private:
|
||||||
class default_lp_resource_limit : public lp_resource_limit {
|
class default_lp_resource_limit : public lp_resource_limit {
|
||||||
lp_settings& m_settings;
|
lp_settings& m_settings;
|
||||||
int m_start_time;
|
stopwatch m_sw;
|
||||||
public:
|
public:
|
||||||
default_lp_resource_limit(lp_settings& s): m_settings(s), m_start_time(get_millisecond_count()) {}
|
default_lp_resource_limit(lp_settings& s): m_settings(s) {
|
||||||
|
m_sw.start();
|
||||||
|
}
|
||||||
virtual bool get_cancel_flag() {
|
virtual bool get_cancel_flag() {
|
||||||
int span_in_mills = get_millisecond_span(m_start_time);
|
return (m_sw.get_current_seconds() > m_settings.time_limit);
|
||||||
return (span_in_mills / 1000.0 > m_settings.time_limit);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,19 +52,6 @@ lp_status lp_status_from_string(std::string status) {
|
||||||
lean_unreachable();
|
lean_unreachable();
|
||||||
return lp_status::UNKNOWN; // it is unreachable
|
return lp_status::UNKNOWN; // it is unreachable
|
||||||
}
|
}
|
||||||
int get_millisecond_count() {
|
|
||||||
timeb tb;
|
|
||||||
ftime(&tb);
|
|
||||||
return tb.millitm + (tb.time & 0xfffff) * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_millisecond_span(int start_time) {
|
|
||||||
int span = get_millisecond_count() - start_time;
|
|
||||||
if (span < 0)
|
|
||||||
span += 0x100000 * 1000;
|
|
||||||
return span;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -1050,8 +1050,8 @@ bool sparse_matrix<T, X>::get_pivot_for_column(unsigned &i, unsigned &j, int c_p
|
||||||
if (i_inv < k) continue;
|
if (i_inv < k) continue;
|
||||||
unsigned j_inv = adjust_column_inverse(j);
|
unsigned j_inv = adjust_column_inverse(j);
|
||||||
if (j_inv < k) continue;
|
if (j_inv < k) continue;
|
||||||
int small = elem_is_too_small(i, j, c_partial_pivoting);
|
int _small = elem_is_too_small(i, j, c_partial_pivoting);
|
||||||
if (!small) {
|
if (!_small) {
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef LEAN_DEBUG
|
||||||
// if (!really_best_pivot(i, j, c_partial_pivoting, k)) {
|
// if (!really_best_pivot(i, j, c_partial_pivoting, k)) {
|
||||||
// print_active_matrix(k);
|
// print_active_matrix(k);
|
||||||
|
@ -1063,7 +1063,7 @@ bool sparse_matrix<T, X>::get_pivot_for_column(unsigned &i, unsigned &j, int c_p
|
||||||
j = j_inv;
|
j = j_inv;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (small != 2) { // 2 means that the pair is not in the matrix
|
if (_small != 2) { // 2 means that the pair is not in the matrix
|
||||||
pivots_candidates_that_are_too_small.push_back(std::make_pair(i, j));
|
pivots_candidates_that_are_too_small.push_back(std::make_pair(i, j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue