Skip to content

Commit

Permalink
rm lu
Browse files Browse the repository at this point in the history
  • Loading branch information
levnach committed Mar 8, 2023
1 parent 6132bf9 commit 377ceba
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 1,151 deletions.
1 change: 0 additions & 1 deletion src/math/lp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ z3_add_component(lp
lp_core_solver_base.cpp
lp_primal_core_solver.cpp
lp_settings.cpp
lu.cpp
lp_utils.cpp
matrix.cpp
mon_eq.cpp
Expand Down
14 changes: 13 additions & 1 deletion src/math/lp/lp_core_solver_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@ Revision History:
#include "math/lp/core_solver_pretty_printer.h"
#include "math/lp/numeric_pair.h"
#include "math/lp/static_matrix.h"
#include "math/lp/lu.h"
#include "math/lp/permutation_matrix.h"
#include "math/lp/column_namer.h"
#include "math/lp/u_set.h"


namespace lp {
template <typename T, typename X>
X dot_product(const vector<T> & a, const vector<X> & b) {
lp_assert(a.size() == b.size());
auto r = zero_of_type<X>();
for (unsigned i = 0; i < a.size(); i++) {
r += a[i] * b[i];
}
return r;
}

template <typename T, typename X> // X represents the type of the x variable and the bounds
class lp_core_solver_base {
Expand Down Expand Up @@ -156,6 +166,8 @@ class lp_core_solver_base {

void pretty_print(std::ostream & out);



X get_cost() const {
return dot_product(m_costs, m_x);
}
Expand Down
4 changes: 0 additions & 4 deletions src/math/lp/lp_primal_core_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Revision History:
#include <math.h>
#include <cstdlib>
#include <algorithm>
#include "math/lp/lu.h"
#include "math/lp/static_matrix.h"
#include "math/lp/core_solver_pretty_printer.h"
#include "math/lp/lp_core_solver_base.h"
Expand Down Expand Up @@ -418,9 +417,6 @@ class lp_primal_core_solver:public lp_core_solver_base<T, X> {
// returns the number of iterations
unsigned solve();

lu<static_matrix<T, X>> * factorization() {return nullptr;}

void delete_factorization();

// according to Swietanowski, " A new steepest edge approximation for the simplex method for linear programming"
void init_column_norms();
Expand Down
13 changes: 4 additions & 9 deletions src/math/lp/lp_primal_core_solver_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Revision History:
#include <set>
#include <string>
#include "math/lp/lp_primal_core_solver.h"
#include "math/lp/dense_matrix.h"
namespace lp {
// This core solver solves (Ax=b, lower_bound_values \leq x \leq upper_bound_values, maximize costs*x )
// The right side b is given implicitly by x and the basis
Expand Down Expand Up @@ -733,8 +734,7 @@ template <typename T, typename X> unsigned lp_primal_core_solver<T, X>::solve()
default:
break; // do nothing
}
} while (this->get_status() != lp_status::FLOATING_POINT_ERROR
&&
} while (
this->get_status() != lp_status::UNBOUNDED
&&
this->get_status() != lp_status::OPTIMAL
Expand All @@ -745,18 +745,13 @@ template <typename T, typename X> unsigned lp_primal_core_solver<T, X>::solve()
&&
!(this->current_x_is_feasible() && this->m_look_for_feasible_solution_only));

lp_assert(this->get_status() == lp_status::FLOATING_POINT_ERROR
||
lp_assert(
this->current_x_is_feasible() == false
||
this->calc_current_x_is_feasible_include_non_basis());
return this->total_iterations();
}

template <typename T, typename X> void lp_primal_core_solver<T, X>::delete_factorization() {
lp_assert(false);
}

// according to Swietanowski, " A new steepest edge approximation for the simplex method for linear programming"
template <typename T, typename X> void lp_primal_core_solver<T, X>::init_column_norms() {
lp_assert(numeric_traits<T>::precise() == false);
Expand Down Expand Up @@ -860,7 +855,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::fill_breakpo


template <typename T, typename X> bool lp_primal_core_solver<T, X>::done() {
if (this->get_status() == lp_status::OPTIMAL || this->get_status() == lp_status::FLOATING_POINT_ERROR) return true;
if (this->get_status() == lp_status::OPTIMAL) return true;
if (this->get_status() == lp_status::INFEASIBLE) {
return true;
}
Expand Down
6 changes: 2 additions & 4 deletions src/math/lp/lp_primal_core_solver_tableau_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ unsigned lp_primal_core_solver<T, X>::solve_with_tableau() {
this->set_status(lp_status::CANCELLED);
break; // from the loop
}
} while (this->get_status() != lp_status::FLOATING_POINT_ERROR
&&
} while (
this->get_status() != lp_status::UNBOUNDED
&&
this->get_status() != lp_status::OPTIMAL
Expand All @@ -168,8 +167,7 @@ unsigned lp_primal_core_solver<T, X>::solve_with_tableau() {
!(this->current_x_is_feasible() && this->m_look_for_feasible_solution_only)
);

lp_assert(this->get_status() == lp_status::FLOATING_POINT_ERROR
||
lp_assert(
this->get_status() == lp_status::CANCELLED
||
this->current_x_is_feasible() == false
Expand Down
1 change: 0 additions & 1 deletion src/math/lp/lp_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ enum class lp_status {
DUAL_UNBOUNDED,
OPTIMAL,
FEASIBLE,
FLOATING_POINT_ERROR,
TIME_EXHAUSTED,
EMPTY,
UNSTABLE,
Expand Down
2 changes: 0 additions & 2 deletions src/math/lp/lp_settings_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const char* lp_status_to_string(lp_status status) {
case lp_status::DUAL_UNBOUNDED: return "DUAL_UNBOUNDED";
case lp_status::OPTIMAL: return "OPTIMAL";
case lp_status::FEASIBLE: return "FEASIBLE";
case lp_status::FLOATING_POINT_ERROR: return "FLOATING_POINT_ERROR";
case lp_status::TIME_EXHAUSTED: return "TIME_EXHAUSTED";
case lp_status::EMPTY: return "EMPTY";
case lp_status::UNSTABLE: return "UNSTABLE";
Expand All @@ -62,7 +61,6 @@ lp_status lp_status_from_string(std::string status) {
if (status == "UNBOUNDED") return lp_status::UNBOUNDED;
if (status == "OPTIMAL") return lp_status::OPTIMAL;
if (status == "FEASIBLE") return lp_status::FEASIBLE;
if (status == "FLOATING_POINT_ERROR") return lp_status::FLOATING_POINT_ERROR;
if (status == "TIME_EXHAUSTED") return lp_status::TIME_EXHAUSTED;
if (status == "EMPTY") return lp_status::EMPTY;
lp_unreachable();
Expand Down
81 changes: 0 additions & 81 deletions src/math/lp/lu.cpp

This file was deleted.

Loading

0 comments on commit 377ceba

Please sign in to comment.