Skip to content

Commit

Permalink
Clean subproblem cut data structures (#731)
Browse files Browse the repository at this point in the history
* Clean subproblem cut data structures

* Remove deleted file from CMakeLists

---------

Co-authored-by: Thomas Bittar <[email protected]>
  • Loading branch information
tbittar and tbittar authored Dec 13, 2023
1 parent 51cb0ad commit 0d841b9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 186 deletions.
1 change: 0 additions & 1 deletion src/cpp/benders/benders_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ add_library (benders_core STATIC
${CMAKE_CURRENT_SOURCE_DIR}/SimulationOptions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/BendersBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/WorkerMaster.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SubproblemCut.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/BendersStructsDatas.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Worker.cpp
Expand Down
123 changes: 0 additions & 123 deletions src/cpp/benders/benders_core/SubproblemCut.cpp

This file was deleted.

3 changes: 2 additions & 1 deletion src/cpp/benders/benders_core/WorkerMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ void WorkerMaster::define_matval_mclind_for_index(
// TODO : Refactor this with add_cut and define_matval_mclind(_for_index)
void WorkerMaster::addSubproblemCut(int i, Point const &s, Point const &x_cut,
double const &rhs) const {
// cut is -rhs >= overall_subpb_cost_under_approx + s^(x-x_cut)
// cut is -theta_i + s.x <= -subproblem_cost + s.x_cut (in the solver)
// i.e. theta_i >= subproblem_cost + s.(x - x_cut) (human form)
int ncoeffs(1 + (int)s.size());
std::vector<char> rowtype(1, 'L');
std::vector<double> rowrhs(1, 0);
Expand Down
62 changes: 1 addition & 61 deletions src/cpp/benders/benders_core/include/SubproblemCut.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,4 @@ struct SubProblemData {
ar &lpstatus;
}
};
using SubProblemDataMap = std::map<std::string, SubProblemData>;

typedef std::pair<Point, IntVector> SubproblemCutData1;
typedef std::pair<SubproblemCutData1, DblVector> SubproblemCutData2;
typedef std::pair<SubproblemCutData2, StrVector> SubproblemCutData3;
typedef SubproblemCutData3 SubproblemCutData;

typedef std::shared_ptr<SubproblemCutData> SubproblemCutDataPtr;

typedef std::map<std::string, SubproblemCutData> SubproblemCutPackage;
typedef std::vector<SubproblemCutPackage> AllCutPackage;

class SubproblemCutTrimmer;

class SubproblemCutDataHandler;
typedef std::shared_ptr<SubproblemCutDataHandler> SubproblemCutDataHandlerPtr;

typedef std::vector<std::tuple<Point, double, double>> DynamicAggregateCuts;

typedef std::set<SubproblemCutDataHandlerPtr, Predicate>
SubproblemCutDataHandlerPtrSet;

void BuildSubproblemCutData(SubproblemCutData &);

const int MAXINTEGER = 2;
enum SubproblemCutInt { SIMPLEXITER = 0, LPSTATUS };

const int MAXDBL = 2;
enum SubproblemCutDbl { SUBPROBLEM_COST = 0, ALPHA_I, SUBPROBLEM_TIMER };
enum SubproblemCutStr { MAXSTR = 0 };

class SubproblemCutDataHandler {
public:
Point &get_subgradient();
IntVector &get_int();
DblVector &get_dbl();
StrVector &get_str();

int &get_int(SubproblemCutInt);
double &get_dbl(SubproblemCutDbl);
std::string &get_str(SubproblemCutStr);

int get_int(SubproblemCutInt) const;
double get_dbl(SubproblemCutDbl) const;
std::string const &get_str(SubproblemCutStr) const;

Point const &get_subgradient() const;
IntVector const &get_int() const;
DblVector const &get_dbl() const;
StrVector const &get_str() const;
void print(std::ostream &stream) const;

public:
explicit SubproblemCutDataHandler(SubproblemCutDataPtr const &data);
explicit SubproblemCutDataHandler(SubproblemCutDataPtr &data);
virtual ~SubproblemCutDataHandler() = default;

SubproblemCutDataPtr _data;
};

std::ostream &operator<<(std::ostream &stream, SubproblemCutData const &rhs);
using SubProblemDataMap = std::map<std::string, SubProblemData>;

0 comments on commit 0d841b9

Please sign in to comment.