00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "CouenneChooseStrong.hpp"
00012 #include "CouenneProblem.hpp"
00013 #include "CouenneBranchingObject.hpp"
00014
00015
00016
00018 CouenneChooseStrong::CouenneChooseStrong (Bonmin::BabSetupBase &b,
00019 CouenneProblem* p, JnlstPtr jnlst) :
00020
00021 BonChooseVariable (b, b.continuousSolver()),
00022 problem_ (p),
00023 jnlst_ (jnlst) {
00024
00025 std::string s;
00026 b.options () -> GetStringValue ("pseudocost_mult_lp", s, "couenne.");
00027 pseudoUpdateLP_ = (s == "yes");
00028 }
00029
00031 CouenneChooseStrong::CouenneChooseStrong (const CouenneChooseStrong& rhs) :
00032 BonChooseVariable (rhs),
00033 problem_ (rhs.problem_),
00034 pseudoUpdateLP_ (rhs.pseudoUpdateLP_),
00035 jnlst_ (rhs.jnlst_)
00036 {}
00037
00039 CouenneChooseStrong::~CouenneChooseStrong()
00040 {}
00041
00043 OsiChooseVariable *
00044 CouenneChooseStrong::clone() const
00045 {
00046 return new CouenneChooseStrong(*this);
00047 }
00048
00050 CouenneChooseStrong&
00051 CouenneChooseStrong::operator=(const CouenneChooseStrong & rhs)
00052 {
00053 if (this != &rhs) {
00054 BonChooseVariable::operator=(rhs);
00055 problem_ = rhs.problem_;
00056 }
00057 return *this;
00058 }
00059
00060
00062 int CouenneChooseStrong::chooseVariable (OsiSolverInterface * solver,
00063 OsiBranchingInformation *info,
00064 bool fixVariables) {
00065 problem_ -> domain () -> push
00066 (problem_ -> nVars (),
00067 info -> solution_,
00068 info -> lower_,
00069 info -> upper_);
00070
00071 int retval = BonChooseVariable::chooseVariable (solver, info, fixVariables);
00072
00073 problem_ -> domain () -> pop ();
00074
00075 return retval;
00076 }
00077
00078
00079
00080
00081 int CouenneChooseStrong::setupList (OsiBranchingInformation *info, bool initialize) {
00082
00083 initialize = true;
00084
00085 problem_ -> domain () -> push
00086 (problem_ -> nVars (),
00087 info -> solution_,
00088 info -> lower_,
00089 info -> upper_);
00090
00091 jnlst_ -> Printf (J_ITERSUMMARY, J_BRANCHING,
00092 "----------------- (strong) setup list\n");
00093
00094 if (jnlst_ -> ProduceOutput (J_DETAILED, J_BRANCHING)) {
00095 for (int i=0; i<problem_ -> domain () -> current () -> Dimension (); i++)
00096 printf ("%4d %20.4g [%20.4g %20.4g]\n", i,
00097 info -> solution_ [i], info -> lower_ [i], info -> upper_ [i]);
00098 }
00099
00100
00101 int retval = BonChooseVariable::setupList (info, initialize);
00102
00103 jnlst_ -> Printf (J_ITERSUMMARY, J_BRANCHING,
00104 "----------------- (strong) setup list done - %d infeasibilities\n", retval);
00105
00106 problem_ -> domain () -> pop ();
00107 return retval;
00108 }
00109
00110
00112 void CouenneChooseStrong::registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions) {
00113
00114 roptions -> AddStringOption6
00115 ("pseudocost_mult",
00116 "Multipliers of pseudocosts for estimating and update estimation of bound",
00117 "interval_br_rev",
00118
00119 "infeasibility", "infeasibility returned by object",
00120
00121 "projectDist", "distance between current LP point and resulting branches' LP points",
00122
00123 "interval_lp", "width of the interval between bound and current lp point",
00124 "interval_lp_rev", "similar to interval_lp, reversed",
00125
00126 "interval_br", "width of the interval between bound and branching point",
00127 "interval_br_rev", "similar to interval_br, reversed");
00128
00129 roptions -> AddStringOption2
00130 ("pseudocost_mult_lp",
00131 "Use distance between LP points to update multipliers of pseudocosts "
00132 "after simulating branching",
00133 "no",
00134 "yes", "",
00135 "no", "");
00136 }
00137
00138
00139
00140 bool CouenneChooseStrong::feasibleSolution (const OsiBranchingInformation * info,
00141 const double * solution,
00142 int numberObjects,
00143 const OsiObject ** objects) {
00144
00145 double obj = solution [problem_ -> Obj (0) -> Body () -> Index ()];
00146 return problem_ -> checkNLP (solution, obj);
00147 }
00148