Skip to content

Commit

Permalink
remove AbstractSolution and Solution::
Browse files Browse the repository at this point in the history
  • Loading branch information
hlefebvr committed Oct 24, 2024
1 parent e3869eb commit 66e8b83
Show file tree
Hide file tree
Showing 53 changed files with 264 additions and 567 deletions.
3 changes: 1 addition & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ add_library(idol STATIC
include/idol/modeling/constraints/TempCtr.h
src/modeling/constraints/TempCtr.cpp
include/idol/containers/IteratorForward.h
include/idol/modeling/solutions/AbstractSolution.h
include/idol/modeling/solutions/Solution.h
include/idol/modeling/variables/TempVar.h
include/idol/containers/Set.h
include/idol/errors/NotImplemented.h
Expand Down Expand Up @@ -241,6 +239,7 @@ add_library(idol STATIC
src/optimizers/mixed-integer-optimization/callbacks/watchers/Plots_OptimalityGap.cpp
include/idol/modeling/sparse-matrix/SparseVector.h
include/idol/containers/sort.h
include/idol/modeling/solutions/Point.h
)

find_package(OpenMP REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions lib/include/idol/containers/GeneratorPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#ifndef IDOL_GENERATORPOOL_H
#define IDOL_GENERATORPOOL_H

#include "idol/modeling/solutions/Solution.h"
#include "idol/modeling/solutions/Point.h"
#include <list>

namespace idol {
template<class KeyT, class ValueT> class GeneratorPool;
}

template<class KeyT, class ValueT = idol::Solution::Primal>
template<class KeyT, class ValueT = idol::PrimalPoint>
class idol::GeneratorPool {
std::list<std::pair<KeyT, ValueT>> m_values;
public:
Expand Down
2 changes: 1 addition & 1 deletion lib/include/idol/modeling/constraints/TempCtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class idol::TempCtr {
* Returns true if the temporary constraint is violated by the given solution, false otherwise.
* @param t_solution The solution to check.
*/
[[nodiscard]] bool is_violated(const Solution::Primal& t_solution) const;
[[nodiscard]] bool is_violated(const PrimalPoint& t_solution) const;
};

idol::TempCtr operator<=(idol::Expr<idol::Var, idol::Var>&& t_lhs, idol::Expr<idol::Var, idol::Var>&& t_rhs);
Expand Down
4 changes: 2 additions & 2 deletions lib/include/idol/modeling/expressions/AbstractExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class idol::impl::AbstractExpr {
virtual void set(const Key& t_key, double t_coefficient);
virtual double get(const Key& t_key) const;
virtual void remove(const Key& t_key);
void internal_fix(const Solution::Primal& t_primals);
void internal_fix(const PrimalPoint& t_primals);

class References;
References refs();
Expand Down Expand Up @@ -169,7 +169,7 @@ class idol::impl::AbstractExpr {
};

template<class Key, class IteratorOutputT, class Hash, class EqualTo>
void idol::impl::AbstractExpr<Key, IteratorOutputT, Hash, EqualTo>::internal_fix(const idol::Solution::Primal &t_primals) {
void idol::impl::AbstractExpr<Key, IteratorOutputT, Hash, EqualTo>::internal_fix(const idol::PrimalPoint &t_primals) {

for (auto& [key, ptr_to_value] : m_map) {
ptr_to_value->value() = ptr_to_value->value().fix(t_primals);
Expand Down
5 changes: 3 additions & 2 deletions lib/include/idol/modeling/expressions/Constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "idol/modeling/parameters/Param.h"
#include "idol/modeling/numericals.h"
#include "idol/containers/IteratorForward.h"
#include "idol/modeling/solutions/Point.h"

namespace idol {

Expand Down Expand Up @@ -274,14 +275,14 @@ class idol::Constant {
* @param t_primals Primal values associated to the stored `Param`
* @return the resulting numerical
*/
double fix(const Solution::Primal& t_primals) const;
double fix(const PrimalPoint& t_primals) const;

/**
* Computes the resulting numerical by replacing each `Param` by their corresponding values in `t_duals`.
* @param t_primals Dual values associated to the stored `Param`
* @return the resulting numerical
*/
double fix(const Solution::Dual& t_duals) const;
double fix(const DualPoint& t_duals) const;

void round();

Expand Down
6 changes: 3 additions & 3 deletions lib/include/idol/modeling/expressions/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class idol::impl::Expr {

References refs() { return References(this); }

void internal_fix(const Solution::Primal& t_primals);
void internal_fix(const PrimalPoint& t_primals);
public:
Expr();
Expr(double t_num); // NOLINT(google-explicit-constructor)
Expand Down Expand Up @@ -229,11 +229,11 @@ class idol::Expr : public impl::Expr<Key1, Key2> {
Expr& operator=(const Expr& t_rhs) = default;
Expr& operator=(Expr&&) noexcept = default;

Expr fix(const Solution::Primal& t_primals) const;
Expr fix(const PrimalPoint& t_primals) const;
};

template<class Key1, class Key2>
idol::Expr<Key1, Key2> idol::Expr<Key1, Key2>::fix(const Solution::Primal& t_primals) const {
idol::Expr<Key1, Key2> idol::Expr<Key1, Key2>::fix(const PrimalPoint& t_primals) const {
auto result = *this;
result.internal_fix(t_primals);
return result;
Expand Down
4 changes: 2 additions & 2 deletions lib/include/idol/modeling/expressions/LinExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ class idol::LinExpr : public AbstractExpr<Key, LinTerm<Key>> {
*/
void remove(const Key& t_key) override;

LinExpr fix(const Solution::Primal& t_primals) const;
LinExpr fix(const PrimalPoint& t_primals) const;
};

template<class Key>
idol::LinExpr<Key> idol::LinExpr<Key>::fix(const idol::Solution::Primal &t_primals) const {
idol::LinExpr<Key> idol::LinExpr<Key>::fix(const idol::PrimalPoint &t_primals) const {
auto result = *this;
result.internal_fix(t_primals);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "operators_utils.h"

namespace idol {
double evaluate(const Expr<Var, Var>& t_expr, const Solution::Primal& t_values);
double evaluate(const Expr<Var, Var>& t_expr, const PrimalPoint& t_values);
}

#endif //IDOL_OPERATORS_H
4 changes: 2 additions & 2 deletions lib/include/idol/modeling/matrix/Row.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class idol::Row : public impl::Row {
* @param t_primals The primal values.
* @return The value of the row.
*/
double value(const Solution::Primal& t_primals) const;
double value(const PrimalPoint& t_primals) const;

/**
* Returns true if the point stored in `t_primals` violates the constraint formed by the row and a constraint type
Expand All @@ -226,7 +226,7 @@ class idol::Row : public impl::Row {
* @param t_tolerance The tolerance for feasibility.
* @return True if the given point violates the row.
*/
bool is_violated(const Solution::Primal& t_primals, CtrType t_type, double t_tolerance = Tolerance::Feasibility) const;
bool is_violated(const PrimalPoint& t_primals, CtrType t_type, double t_tolerance = Tolerance::Feasibility) const;

/**
* Represents an empty row.
Expand Down
10 changes: 5 additions & 5 deletions lib/include/idol/modeling/models/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "idol/modeling/constraints/CtrVersion.h"
#include "idol/modeling/variables/VarVersion.h"
#include "idol/modeling/expressions/Expr.h"
#include "idol/modeling/solutions/Solution.h"
#include "idol/modeling/solutions/Point.h"

#include "Model.h"

Expand Down Expand Up @@ -1224,7 +1224,7 @@ namespace idol {

static auto save_primal(const Model &t_original_model, const Model &t_model) {

Solution::Primal result;
PrimalPoint result;

const auto status = t_model.get_status();
const auto reason = t_model.get_reason();
Expand Down Expand Up @@ -1252,7 +1252,7 @@ namespace idol {

static auto save_ray(const Model &t_original_model, const Model &t_model) {

Solution::Primal result;
PrimalPoint result;

const auto status = t_model.get_status();
const auto reason = t_model.get_reason();
Expand Down Expand Up @@ -1280,7 +1280,7 @@ namespace idol {

static auto save_dual(const Model &t_original_model, const Model &t_model) {

Solution::Dual result;
DualPoint result;

const auto status = t_model.get_status();
const auto reason = t_model.get_reason();
Expand Down Expand Up @@ -1308,7 +1308,7 @@ namespace idol {

static auto save_farkas(const Model &t_original_model, const Model &t_model) {

Solution::Dual result;
DualPoint result;

const auto status = t_model.get_status();
const auto reason = t_model.get_reason();
Expand Down
Loading

0 comments on commit 66e8b83

Please sign in to comment.