00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "CoinHelperFunctions.hpp"
00013
00014 #include "CouenneProblem.hpp"
00015 #include "CouenneObject.hpp"
00016 #include "CouenneBranchingObject.hpp"
00017 #include "CouenneThreeWayBranchObj.hpp"
00018
00019 #include "CouenneExprGroup.hpp"
00020 #include "CouenneExprQuad.hpp"
00021 #include "CouenneLQelems.hpp"
00022
00023 using namespace Couenne;
00024
00025 #define TOL 0.
00026
00028 double CouenneObject::feasibleRegion (OsiSolverInterface *solver,
00029 const OsiBranchingInformation *info) const {
00030 int index = reference_ -> Index ();
00031
00032 assert (index >= 0);
00033
00034 double val = info -> solution_ [index];
00035
00036
00037 solver -> setColLower (index, val-TOL);
00038 solver -> setColUpper (index, val+TOL);
00039
00040 expression *expr = reference_ -> Image ();
00041
00042 if (!expr) return 0.;
00043
00044
00045
00046
00047
00048
00049 if (expr -> Type () == UNARY) {
00050
00051 index = expr -> Argument () -> Index ();
00052
00053 if (index >= 0) {
00054 val = info -> solution_ [index];
00055 solver -> setColLower (index, val-TOL);
00056 solver -> setColUpper (index, val+TOL);
00057 }
00058 }
00059 else
00060
00061 if (expr -> Type () == N_ARY) {
00062
00063 expression ** args = expr -> ArgList ();
00064 int nargs = expr -> nArgs ();
00065
00066 for (register int i=0; i < nargs; i++) {
00067
00068 if ((index = args [i] -> Index()) >= 0) {
00069 val = info -> solution_ [index];
00070 solver -> setColLower (index, val-TOL);
00071 solver -> setColUpper (index, val+TOL);
00072 }
00073 }
00074 }
00075
00076
00077 if ((expr -> code () == COU_EXPRGROUP) ||
00078 (expr -> code () == COU_EXPRQUAD)) {
00079
00080 exprGroup *e = dynamic_cast <exprGroup *> (expr -> isaCopy () ?
00081 expr -> Copy () :
00082 expr);
00083
00084 exprGroup::lincoeff &lcoe = e -> lcoeff ();
00085
00086 for (exprGroup::lincoeff::iterator el = lcoe.begin (); el != lcoe.end (); ++el) {
00087 int index = el -> first -> Index ();
00088 val = info -> solution_ [index];
00089 solver -> setColLower (index, val-TOL);
00090 solver -> setColUpper (index, val+TOL);
00091 }
00092
00093
00094 if (expr -> code () == COU_EXPRQUAD) {
00095
00096 exprQuad *e = dynamic_cast <exprQuad *> (expr -> isaCopy () ?
00097 expr -> Copy () :
00098 expr);
00099
00100 exprQuad::sparseQ q = e -> getQ ();
00101
00102 for (exprQuad::sparseQ::iterator row = q.begin ();
00103 row != q.end (); ++row) {
00104
00105 int xind = row -> first -> Index ();
00106
00107 val = info -> solution_ [xind];
00108 solver -> setColLower (xind, val-TOL);
00109 solver -> setColUpper (xind, val+TOL);
00110
00111 for (exprQuad::sparseQcol::iterator col = row -> second.begin ();
00112 col != row -> second.end (); ++col) {
00113
00114 int yind = col -> first -> Index ();
00115
00116 val = info -> solution_ [yind];
00117 solver -> setColLower (yind, val-TOL);
00118 solver -> setColUpper (yind, val+TOL);
00119 }
00120 }
00121 }
00122 }
00123
00124 return 0.;
00125 }