-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
344 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...e/idol/robust/optimizers/column-and-constraint-generation/ColumnAndConstraintGeneration.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Created by henri on 11.12.24. | ||
// | ||
|
||
#ifndef IDOL_COLUMNANDCONSTRAINTGENERATION_H | ||
#define IDOL_COLUMNANDCONSTRAINTGENERATION_H | ||
|
||
#include "idol/general/optimizers/OptimizerFactory.h" | ||
#include "idol/robust/modeling/Description.h" | ||
|
||
namespace idol::Robust { | ||
class ColumnAndConstraintGeneration; | ||
} | ||
|
||
class idol::Robust::ColumnAndConstraintGeneration : public OptimizerFactoryWithDefaultParameters<ColumnAndConstraintGeneration> { | ||
const Robust::Description& m_description; | ||
std::unique_ptr<OptimizerFactory> m_master_optimizer; | ||
public: | ||
explicit ColumnAndConstraintGeneration(const Robust::Description& t_description); | ||
|
||
ColumnAndConstraintGeneration(const ColumnAndConstraintGeneration& t_src); | ||
|
||
Optimizer *operator()(const Model &t_model) const override; | ||
|
||
[[nodiscard]] OptimizerFactory *clone() const override; | ||
|
||
ColumnAndConstraintGeneration& with_master_optimizer(const idol::OptimizerFactory &t_deterministic_optimizer); | ||
}; | ||
|
||
#endif //IDOL_COLUMNANDCONSTRAINTGENERATION_H |
22 changes: 22 additions & 0 deletions
22
lib/include/idol/robust/optimizers/column-and-constraint-generation/Formulation.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Created by henri on 11.12.24. | ||
// | ||
|
||
#ifndef IDOL_CCG_FORMULATION_H | ||
#define IDOL_CCG_FORMULATION_H | ||
|
||
#include "idol/mixed-integer/modeling/models/Model.h" | ||
#include "idol/robust/modeling/Description.h" | ||
|
||
namespace idol::CCG { | ||
class Formulation; | ||
} | ||
|
||
class idol::CCG::Formulation { | ||
const Model& m_parent; | ||
const ::idol::Robust::Description &m_description; | ||
public: | ||
Formulation(const Model& t_parent, const ::idol::Robust::Description &t_description); | ||
}; | ||
|
||
#endif //IDOL_CCG_FORMULATION_H |
89 changes: 89 additions & 0 deletions
89
...st/optimizers/column-and-constraint-generation/Optimizers_ColumnAndConstraintGeneration.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// Created by henri on 11.12.24. | ||
// | ||
|
||
#ifndef IDOL_OPTIMIZERS_COLUMNANDCONSTRAINTGENERATION_H | ||
#define IDOL_OPTIMIZERS_COLUMNANDCONSTRAINTGENERATION_H | ||
|
||
#include "idol/robust/modeling/Description.h" | ||
#include "idol/general/optimizers/Algorithm.h" | ||
#include "idol/general/optimizers/OptimizerFactory.h" | ||
#include "Formulation.h" | ||
|
||
namespace idol::Optimizers::Robust { | ||
class ColumnAndConstraintGeneration; | ||
} | ||
|
||
class idol::Optimizers::Robust::ColumnAndConstraintGeneration : public Algorithm { | ||
const ::idol::Robust::Description &m_description; | ||
std::unique_ptr<OptimizerFactory> m_master_optimizer; | ||
std::unique_ptr<idol::CCG::Formulation> m_formulation; | ||
public: | ||
ColumnAndConstraintGeneration(const Model& t_parent, | ||
const ::idol::Robust::Description &t_description, | ||
const OptimizerFactory &t_master_optimizer); | ||
|
||
[[nodiscard]] std::string name() const override; | ||
|
||
[[nodiscard]] double get_var_primal(const Var &t_var) const override; | ||
|
||
[[nodiscard]] double get_var_reduced_cost(const Var &t_var) const override; | ||
|
||
[[nodiscard]] double get_var_ray(const Var &t_var) const override; | ||
|
||
[[nodiscard]] double get_ctr_dual(const Ctr &t_ctr) const override; | ||
|
||
[[nodiscard]] double get_ctr_farkas(const Ctr &t_ctr) const override; | ||
|
||
[[nodiscard]] unsigned int get_n_solutions() const override; | ||
|
||
[[nodiscard]] unsigned int get_solution_index() const override; | ||
|
||
protected: | ||
void add(const Var &t_var) override; | ||
|
||
void add(const Ctr &t_ctr) override; | ||
|
||
void add(const QCtr &t_ctr) override; | ||
|
||
void remove(const Var &t_var) override; | ||
|
||
void remove(const Ctr &t_ctr) override; | ||
|
||
void remove(const QCtr &t_ctr) override; | ||
|
||
void update() override; | ||
|
||
void write(const std::string &t_name) override; | ||
|
||
void hook_before_optimize() override; | ||
|
||
void hook_optimize() override; | ||
|
||
void set_solution_index(unsigned int t_index) override; | ||
|
||
void update_obj_sense() override; | ||
|
||
void update_obj() override; | ||
|
||
void update_rhs() override; | ||
|
||
void update_obj_constant() override; | ||
|
||
void update_mat_coeff(const Ctr &t_ctr, const Var &t_var) override; | ||
|
||
void update_ctr_type(const Ctr &t_ctr) override; | ||
|
||
void update_ctr_rhs(const Ctr &t_ctr) override; | ||
|
||
void update_var_type(const Var &t_var) override; | ||
|
||
void update_var_lb(const Var &t_var) override; | ||
|
||
void update_var_ub(const Var &t_var) override; | ||
|
||
void update_var_obj(const Var &t_var) override; | ||
}; | ||
|
||
|
||
#endif //IDOL_OPTIMIZERS_COLUMNANDCONSTRAINTGENERATION_H |
47 changes: 47 additions & 0 deletions
47
lib/src/robust/optimizers/column-and-constraint-generation/ColumnAndConstraintGeneration.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Created by henri on 11.12.24. | ||
// | ||
#include "idol/robust/optimizers/column-and-constraint-generation/ColumnAndConstraintGeneration.h" | ||
#include "idol/robust/optimizers/column-and-constraint-generation/Optimizers_ColumnAndConstraintGeneration.h" | ||
|
||
idol::Robust::ColumnAndConstraintGeneration::ColumnAndConstraintGeneration(const Robust::Description &t_description) | ||
: m_description(t_description) { | ||
|
||
} | ||
|
||
idol::Robust::ColumnAndConstraintGeneration::ColumnAndConstraintGeneration( | ||
const idol::Robust::ColumnAndConstraintGeneration &t_src) : m_description(t_src.m_description) { | ||
|
||
} | ||
|
||
idol::OptimizerFactory *idol::Robust::ColumnAndConstraintGeneration::clone() const { | ||
return new ColumnAndConstraintGeneration(*this); | ||
} | ||
|
||
idol::Robust::ColumnAndConstraintGeneration &idol::Robust::ColumnAndConstraintGeneration::with_master_optimizer( | ||
const idol::OptimizerFactory &t_deterministic_optimizer) { | ||
|
||
if (m_master_optimizer) { | ||
throw Exception("Master optimizer already set"); | ||
} | ||
|
||
m_master_optimizer.reset(t_deterministic_optimizer.clone()); | ||
|
||
return *this; | ||
} | ||
|
||
idol::Optimizer *idol::Robust::ColumnAndConstraintGeneration::operator()(const idol::Model &t_model) const { | ||
|
||
if (!m_master_optimizer) { | ||
throw Exception("Master optimizer not set"); | ||
} | ||
|
||
auto* result = new Optimizers::Robust::ColumnAndConstraintGeneration(t_model, | ||
m_description, | ||
*m_master_optimizer); | ||
|
||
handle_default_parameters(result); | ||
|
||
return result; | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
lib/src/robust/optimizers/column-and-constraint-generation/Formulation.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// | ||
// Created by henri on 11.12.24. | ||
// | ||
#include <idol/robust/optimizers/column-and-constraint-generation/Formulation.h> | ||
|
||
|
||
idol::CCG::Formulation::Formulation(const idol::Model &t_parent, const ::idol::Robust::Description &t_description) | ||
: m_parent(t_parent), m_description(t_description) { | ||
|
||
} |
134 changes: 134 additions & 0 deletions
134
.../optimizers/column-and-constraint-generation/Optimizers_ColumnAndConstraintGeneration.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// | ||
// Created by henri on 11.12.24. | ||
// | ||
#include <idol/robust/optimizers/column-and-constraint-generation/Optimizers_ColumnAndConstraintGeneration.h> | ||
|
||
idol::Optimizers::Robust::ColumnAndConstraintGeneration::ColumnAndConstraintGeneration(const idol::Model &t_parent, | ||
const idol::Robust::Description &t_description, | ||
const idol::OptimizerFactory &t_master_optimizer) | ||
: Algorithm(t_parent), | ||
m_description(t_description), | ||
m_master_optimizer(t_master_optimizer.clone()) { | ||
|
||
} | ||
|
||
std::string idol::Optimizers::Robust::ColumnAndConstraintGeneration::name() const { | ||
return "column-and-constraint generation"; | ||
} | ||
|
||
double idol::Optimizers::Robust::ColumnAndConstraintGeneration::get_var_primal(const idol::Var &t_var) const { | ||
throw Exception("Not implemented get_var_primal"); | ||
} | ||
|
||
double idol::Optimizers::Robust::ColumnAndConstraintGeneration::get_var_reduced_cost(const idol::Var &t_var) const { | ||
throw Exception("Not implemented get_var_reduced_cost"); | ||
} | ||
|
||
double idol::Optimizers::Robust::ColumnAndConstraintGeneration::get_var_ray(const idol::Var &t_var) const { | ||
throw Exception("Not implemented get_var_ray"); | ||
} | ||
|
||
double idol::Optimizers::Robust::ColumnAndConstraintGeneration::get_ctr_dual(const idol::Ctr &t_ctr) const { | ||
throw Exception("Not implemented get_ctr_dual"); | ||
} | ||
|
||
double idol::Optimizers::Robust::ColumnAndConstraintGeneration::get_ctr_farkas(const idol::Ctr &t_ctr) const { | ||
throw Exception("Not implemented get_ctr_farkas"); | ||
} | ||
|
||
unsigned int idol::Optimizers::Robust::ColumnAndConstraintGeneration::get_n_solutions() const { | ||
throw Exception("Not implemented get_n_solutions"); | ||
} | ||
|
||
unsigned int idol::Optimizers::Robust::ColumnAndConstraintGeneration::get_solution_index() const { | ||
throw Exception("Not implemented get_solution_index"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::add(const idol::Var &t_var) { | ||
throw Exception("Not implemented add"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::add(const idol::Ctr &t_ctr) { | ||
throw Exception("Not implemented add"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::add(const idol::QCtr &t_ctr) { | ||
throw Exception("Not implemented add"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::remove(const idol::Var &t_var) { | ||
throw Exception("Not implemented remove"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::remove(const idol::Ctr &t_ctr) { | ||
throw Exception("Not implemented remove"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::remove(const idol::QCtr &t_ctr) { | ||
throw Exception("Not implemented remove"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update() { | ||
throw Exception("Not implemented update"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::write(const std::string &t_name) { | ||
throw Exception("Not implemented write"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::hook_before_optimize() { | ||
Optimizer::hook_before_optimize(); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::hook_optimize() { | ||
throw Exception("Not implemented hook_optimize"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::set_solution_index(unsigned int t_index) { | ||
throw Exception("Not implemented set_solution_index"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_obj_sense() { | ||
throw Exception("Not implemented update_obj_sense"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_obj() { | ||
throw Exception("Not implemented update_obj"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_rhs() { | ||
throw Exception("Not implemented update_rhs"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_obj_constant() { | ||
throw Exception("Not implemented update_obj_constant"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_mat_coeff(const idol::Ctr &t_ctr, | ||
const idol::Var &t_var) { | ||
throw Exception("Not implemented update_mat_coeff"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_ctr_type(const idol::Ctr &t_ctr) { | ||
throw Exception("Not implemented update_ctr_type"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_ctr_rhs(const idol::Ctr &t_ctr) { | ||
throw Exception("Not implemented update_ctr_rhs"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_var_type(const idol::Var &t_var) { | ||
throw Exception("Not implemented update_var_type"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_var_lb(const idol::Var &t_var) { | ||
throw Exception("Not implemented update_var_lb"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_var_ub(const idol::Var &t_var) { | ||
throw Exception("Not implemented update_var_ub"); | ||
} | ||
|
||
void idol::Optimizers::Robust::ColumnAndConstraintGeneration::update_var_obj(const idol::Var &t_var) { | ||
throw Exception("Not implemented update_var_obj"); | ||
} |