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