-
-
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
12 changed files
with
125 additions
and
56 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
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
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
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
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
59 changes: 59 additions & 0 deletions
59
lib/include/idol/mixed-integer/optimizers/callbacks/ReducedCostFixing.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,59 @@ | ||
// | ||
// Created by henri on 24.11.24. | ||
// | ||
|
||
#ifndef IDOL_REDUCEDCOSTFIXING_H | ||
#define IDOL_REDUCEDCOSTFIXING_H | ||
|
||
#include "idol/mixed-integer/optimizers/branch-and-bound/callbacks/BranchAndBoundCallback.h" | ||
|
||
namespace idol { | ||
template<class> class ReducedCostFixing; | ||
} | ||
|
||
template<class NodeInfoT = idol::DefaultNodeInfo> | ||
class idol::ReducedCostFixing : public BranchAndBoundCallbackFactory<NodeInfoT> { | ||
public: | ||
class Strategy : public BranchAndBoundCallback<NodeInfoT> { | ||
public: | ||
protected: | ||
void operator()(CallbackEvent t_event) override { | ||
|
||
if (t_event != InvalidSolution) { | ||
return; | ||
} | ||
|
||
const auto& original_model = this->original_model(); | ||
const auto& relaxation = this->relaxation(); | ||
const double best_obj = this->best_obj(); | ||
const double current_obj = this->relaxation().get_best_obj(); | ||
|
||
for (const auto &var : original_model.vars()) { | ||
|
||
double reduced_cost = relaxation.get_var_reduced_cost(var); | ||
|
||
if (current_obj + reduced_cost > best_obj + Tolerance::MIPAbsoluteGap) { | ||
const double relaxation_lb = original_model.get_var_lb(var); | ||
this->add_local_variable_branching(var, LessOrEqual, relaxation_lb); | ||
} | ||
|
||
if (current_obj - reduced_cost > best_obj + Tolerance::MIPAbsoluteGap) { | ||
const double relaxation_ub = original_model.get_var_ub(var); | ||
this->add_local_variable_branching(var, GreaterOrEqual, relaxation_ub); | ||
} | ||
|
||
} | ||
|
||
} | ||
}; | ||
|
||
BranchAndBoundCallback<NodeInfoT> *operator()() override { | ||
return new Strategy(); | ||
} | ||
|
||
BranchAndBoundCallbackFactory<NodeInfoT> *clone() const override { | ||
return new ReducedCostFixing(); | ||
} | ||
}; | ||
|
||
#endif //IDOL_REDUCEDCOSTFIXING_H |
Oops, something went wrong.