/home/coin/SVN-release/OS-2.0.0/Couenne/src/branch/CouenneChooseVariable.cpp

Go to the documentation of this file.
00001 /* $Id: CouenneChooseVariable.cpp 141 2009-06-03 04:19:19Z pbelotti $ */
00002 /*
00003  * Name:    CouenneChooseVariable.cpp
00004  * Authors: Pierre Bonami, IBM Corp.
00005  *          Pietro Belotti, Carnegie Mellon University
00006  * Purpose: Branching object for choosing branching auxiliary variable
00007  *
00008  * (C) Carnegie-Mellon University, 2006-08.
00009  * This file is licensed under the Common Public License (CPL)
00010  */
00011 
00012 #include "CouenneChooseVariable.hpp"
00013 #include "CouenneProblem.hpp"
00014 
00015 
00017 CouenneChooseVariable::CouenneChooseVariable (): 
00018   OsiChooseVariable (),
00019   problem_ (NULL) {}
00020 
00021 
00023 CouenneChooseVariable::CouenneChooseVariable (const OsiSolverInterface *si,
00024                                               CouenneProblem *p,
00025                                               JnlstPtr jnlst):
00026   OsiChooseVariable (si),
00027   problem_ (p),
00028   jnlst_   (jnlst) {}
00029 
00030 
00032 CouenneChooseVariable::CouenneChooseVariable (const CouenneChooseVariable &source):
00033   OsiChooseVariable (source),
00034   problem_ (source.problem_),
00035   jnlst_   (source.jnlst_) {}
00036 
00037 
00039 CouenneChooseVariable & CouenneChooseVariable::operator= (const CouenneChooseVariable& rhs) {
00040   problem_ = rhs.problem_; 
00041   jnlst_   = rhs.jnlst_;
00042   return *this;
00043 }
00044 
00045 
00049 int CouenneChooseVariable::setupList (OsiBranchingInformation *info, bool initialize) {
00050 
00051   problem_ -> domain () -> push 
00052     (problem_ -> nVars (),
00053      info -> solution_, 
00054      info -> lower_, 
00055      info -> upper_);
00056 
00057   jnlst_ -> Printf (J_ITERSUMMARY, J_BRANCHING, "----------------- setup list\n");
00058 
00059   if (jnlst_ -> ProduceOutput (J_DETAILED, J_BRANCHING)) {
00060 
00061     printf ("----------------- setup list\n");
00062 
00063     for (int i=0; i<problem_ -> domain () -> current () -> Dimension (); i++) 
00064 
00065       if (problem_ -> Var (i) -> Multiplicity () > 0) {
00066         printf ("%4d %20.4g [%20.4g %20.4g]", i,
00067                 info -> solution_ [i],
00068                 info -> lower_ [i],
00069                 info -> upper_ [i]);
00070 
00071         if (problem_ -> Var (i) -> Type () == AUX) {
00072           printf (" expr. %20.4g [%+e] ", 
00073                   (*(problem_ -> Var (i) -> Image ())) (), 
00074                   (*(problem_ -> Var (i) -> Image ())) () - info -> solution_ [i]);
00075           problem_ -> Var (i) -> Image () -> print ();
00076         }
00077 
00078         printf ("\n");
00079       }
00080   }
00081 
00082   // Make it stable, in OsiChooseVariable::setupList() numberObjects must be 0.
00083   int retval = (solver_ -> numberObjects ()) ? 
00084     OsiChooseVariable::setupList (info, initialize) : 0;
00085 
00086   problem_ -> domain () -> pop ();
00087 
00088   jnlst_ -> Printf (J_ITERSUMMARY, J_BRANCHING, "----------------- setup list done, %d objects\n", 
00089                     retval);
00090 
00091   return retval;
00092 }
00093 
00094 
00096 // int CouenneChooseVariable::chooseVariable (OsiSolverInterface * solver, 
00097 //                                         OsiBranchingInformation *info, 
00098 //                                         bool fixVariables) {
00099 
00100 //   // !!!should go -- just choose the first element
00101 //   problem_ -> domain () -> push 
00102 //     (problem_ -> nVars (),
00103 //      info -> solution_, 
00104 //      info -> lower_, 
00105 //      info -> upper_);
00106 
00107 //   int retval = OsiChooseVariable::chooseVariable (solver, info, fixVariables);
00108 
00109 //   problem_ -> domain () -> pop ();
00110 
00111 //   return retval;
00112 // }
00113 
00114 
00115 // Returns true if solution looks feasible against given objects
00116 bool CouenneChooseVariable::feasibleSolution (const OsiBranchingInformation * info,
00117                                               const double * solution,
00118                                               int numberObjects,
00119                                               const OsiObject ** objects) {
00120 
00121   double obj = solution [problem_ -> Obj (0) -> Body () -> Index ()];
00122   return problem_ -> checkNLP (solution, obj);
00123 }
00124 
00125 
00127 void CouenneChooseVariable::registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions) {
00128 
00129   roptions -> AddStringOption2 
00130     ("enable_sos",
00131      "Use Special Ordered Sets (SOS) as indicated in the MINLP model",
00132      "no",
00133      "no","",
00134      "yes","");
00135 
00136   roptions -> AddStringOption2
00137     ("branch_fbbt",
00138      "Apply bound tightening before branching",
00139      "yes",
00140      "no","",
00141      "yes","");
00142 
00143   roptions -> AddStringOption2
00144     ("branch_conv_cuts",
00145      "Apply convexification cuts before branching (for now only within strong branching)",
00146      "yes",
00147      "no","",
00148      "yes","");
00149 
00150   roptions -> AddStringOption6
00151     ("branch_pt_select",
00152      "Chooses branching point selection strategy",
00153      "mid-point",
00154      "lp-clamped", "LP point clamped in [k,1-k] of the bound intervals (k defined by lp_clamp)",
00155      "lp-central", "LP point if within [k,1-k] of the bound intervals, middle point otherwise" 
00156      "(k defined by branch_lp_clamp)",
00157      "balanced", "minimizes max distance from curve to convexification",
00158      "min-area", "minimizes total area of the two convexifications",
00159      "mid-point", "convex combination of current point and mid point",
00160      "no-branch", "do not branch, return null infeasibility; for testing purposes only",
00161      "");
00162 
00163   std::string br_ops [] = {"prod", "div", "exp", "log", "trig", 
00164                            "pow",  "negpow", "sqr", "cube", ""};
00165 
00166   for (int i=0; br_ops [i] != ""; i++) {
00167 
00168     char optname [40], optname2 [40], description [90];
00169     sprintf (optname,  "branch_pt_select_%s", br_ops [i].c_str ());
00170     sprintf (optname2, "branch_lp_clamp_%s",  br_ops [i].c_str ());
00171     sprintf (description, "Chooses branching point selection strategy for operator %s", 
00172              br_ops [i].c_str ());
00173 
00174     roptions -> AddStringOption7
00175       (optname,
00176        description,
00177        "common",
00178        "common",    "use strategy defined for generic operators",
00179        "lp-clamped", "LP point clamped in [k,1-k] of the bound intervals "
00180        "(k defined by lp_clamp_${this operator})",
00181        "lp-central", "LP point if within [k,1-k] of the bound intervals, middle point otherwise" 
00182        "(k defined by branch_lp_clamp_${this operator})",
00183        "balanced",  "minimizes max distance from curve to convexification",
00184        "min-area",  "minimizes total area of the two convexifications",
00185        "mid-point", "convex combination of current point and mid point",
00186        "no-branch", "do not branch, return null infeasibility; for testing purposes only",
00187        "");
00188 
00189     roptions -> AddBoundedNumberOption
00190       (optname2,
00191        "Defines safe interval percentage [0,0.5] for using LP point as a branching point",
00192        0.,false,
00193        0.5,false,
00194        0.2,
00195        "Default value is 0.2.");
00196   }
00197 
00198   roptions -> AddBoundedNumberOption
00199     ("branch_midpoint_alpha",
00200      "Defines convex combination of mid point and current LP point: "
00201      "b = alpha x_lp + (1-alpha) (lb+ub)/2.",
00202      0.,false,
00203      1.,false,
00204      0.25,
00205      "Default value is 0.25.");
00206 
00207   roptions -> AddBoundedNumberOption
00208     ("branch_lp_clamp",
00209      "Defines safe interval percentage for using LP point as a branching point",
00210      0.,false,
00211      1.,false,
00212      0.2,
00213      "Default value is 0.2.");
00214 
00215   roptions -> AddLowerBoundedIntegerOption
00216     ("cont_var_priority",
00217      "Priority of continuous variable branching",
00218      1, 2000, "Default value is 2000 (it is 1000 for integers and 10 for SOS).");
00219 
00220   roptions -> AddStringOption2
00221     ("red_cost_branching",
00222      "Apply Reduced Cost Branching (instead of the Violation Transfer) -- MUST have vt_obj enabled",
00223      "no",
00224      "no", "Use Violation Transfer with $\\sum |\\pi_i a_{ij}|$",
00225      "yes","Use Reduced cost branching with $|\\sum \\pi_i a_{ij}|$");
00226 }

Generated on Mon Aug 3 03:02:19 2009 by  doxygen 1.4.7