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