Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <pseudo_costs.h>
Classes | |
struct | BranchingInfo |
struct | VariableBoundChange |
Public Member Functions | |
PseudoCosts (Model *model) | |
void | BeforeTakingDecision (Literal decision) |
void | AfterTakingDecision (bool conflict=false) |
double | ObjectiveIncrease (bool conflict) |
bool | SaveLpInfo () |
void | SaveBoundChanges (Literal decision, absl::Span< const double > lp_values) |
IntegerVariable | GetBestDecisionVar () |
Returns the variable with best reliable pseudo cost that is not fixed. | |
double | GetCost (IntegerVariable var) const |
Returns the pseudo cost of given variable. Currently used for testing only. | |
int | GetNumRecords (IntegerVariable var) const |
double | CombineScores (double down_branch, double up_branch) const |
Combines the score of the two branch into one score. | |
BranchingInfo | EvaluateVar (IntegerVariable var, absl::Span< const double > lp_values) |
void | UpdateBoolPseudoCosts (absl::Span< const Literal > reason, IntegerValue objective_increase) |
double | BoolPseudoCost (Literal lit, double lp_value) const |
std::vector< VariableBoundChange > | GetBoundChanges (Literal decision, absl::Span< const double > lp_values) |
Pseudo cost of a variable is measured as average observed change in the objective bounds per unit change in the variable bounds.
Definition at line 37 of file pseudo_costs.h.
|
explicit |
If objective_var == kNoIntegerVariable, there is not really any point using this class.
Definition at line 59 of file pseudo_costs.cc.
void operations_research::sat::PseudoCosts::AfterTakingDecision | ( | bool | conflict = false | ) |
Updates the pseudo costs for the given decision given to BeforeTakingDecision().
We store a pseudo cost for this literal. We prefer the pure LP version, but revert to integer version if there is no lp.
We only collect lp increase when the lp is at optimal, otherwise it might just be the "artificial" continuing of the current lp solve that create the increase.
Update the average unit increases.
We also store one for any associated IntegerVariable.
Create space for new variable and its negation.
Definition at line 196 of file pseudo_costs.cc.
void operations_research::sat::PseudoCosts::BeforeTakingDecision | ( | Literal | decision | ) |
This must be called before we are about to branch. It will record the current objective bounds.
Definition at line 106 of file pseudo_costs.cc.
double operations_research::sat::PseudoCosts::BoolPseudoCost | ( | Literal | lit, |
double | lp_value ) const |
Definition at line 168 of file pseudo_costs.cc.
double operations_research::sat::PseudoCosts::CombineScores | ( | double | down_branch, |
double | up_branch ) const |
Combines the score of the two branch into one score.
We prefer the product to combine the cost of two branches.
Definition at line 44 of file pseudo_costs.cc.
PseudoCosts::BranchingInfo operations_research::sat::PseudoCosts::EvaluateVar | ( | IntegerVariable | var, |
absl::Span< const double > | lp_values ) |
Definition at line 112 of file pseudo_costs.cc.
IntegerVariable operations_research::sat::PseudoCosts::GetBestDecisionVar | ( | ) |
Returns the variable with best reliable pseudo cost that is not fixed.
(user): Supports search randomization tolerance.
(user): Implement generic class to choose the randomized solution, and supports sub-linear variable selection.
Pick the direction with best pseudo cost.
Definition at line 259 of file pseudo_costs.cc.
std::vector< PseudoCosts::VariableBoundChange > operations_research::sat::PseudoCosts::GetBoundChanges | ( | Literal | decision, |
absl::Span< const double > | lp_values ) |
Also do the negation.
Definition at line 284 of file pseudo_costs.cc.
|
inline |
Returns the pseudo cost of given variable. Currently used for testing only.
Definition at line 59 of file pseudo_costs.h.
|
inline |
Visible for testing. Returns the number of recordings of given variable.
Definition at line 66 of file pseudo_costs.h.
double operations_research::sat::PseudoCosts::ObjectiveIncrease | ( | bool | conflict | ) |
Advanced usage. Internal functions used by Before/AfterTakingDecision(), that are exposed for strong branching.
We count a conflict as a max increase + 1.0
Definition at line 181 of file pseudo_costs.cc.
void operations_research::sat::PseudoCosts::SaveBoundChanges | ( | Literal | decision, |
absl::Span< const double > | lp_values ) |
Definition at line 101 of file pseudo_costs.cc.
bool operations_research::sat::PseudoCosts::SaveLpInfo | ( | ) |
Definition at line 96 of file pseudo_costs.cc.
void operations_research::sat::PseudoCosts::UpdateBoolPseudoCosts | ( | absl::Span< const Literal > | reason, |
IntegerValue | objective_increase ) |
Experimental alternative pseudo cost based on the explanation for bound increases.
Definition at line 156 of file pseudo_costs.cc.