00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "CoinHelperFunctions.hpp"
00012
00013 #include "CouenneProblem.hpp"
00014 #include "CouenneVarObject.hpp"
00015
00016 using namespace Ipopt;
00017 using namespace Couenne;
00018
00020 const CouNumber weiMin = 0.8;
00021 const CouNumber weiMax = 1.3;
00022 const CouNumber weiSum = 0.1;
00023 const CouNumber weiAvg = 0.0;
00024
00025
00029 double CouenneVarObject::infeasibility (const OsiBranchingInformation *info, int &way) const {
00030
00031 assert (reference_);
00032 int index = reference_ -> Index ();
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 problem_ -> domain () -> push
00046 (problem_ -> nVars (),
00047 info -> solution_,
00048 info -> lower_,
00049 info -> upper_,
00050 false);
00051
00053
00054 CouNumber retval = checkInfeasibility (info);
00055
00057
00058 if (
00059 (jnlst_ -> ProduceOutput (J_DETAILED, J_BRANCHING))) {
00060
00061 const std::set <int> &dependence = problem_ -> Dependence () [index];
00062
00063 printf ("infeasVar x%d %-10g [", reference_ -> Index (), retval);
00064 reference_ -> print ();
00065 if ((dependence.size () == 0) && (reference_ -> Image ())) {
00066 printf (" := ");
00067 reference_ -> Image () -> print ();
00068 }
00069 printf ("]\n");
00070 }
00071
00072
00073
00074
00075
00076
00077
00078 const CouenneObject *obj_ignored = NULL;
00079
00080 CouNumber brkPt = computeBranchingPoint (info, way, obj_ignored);
00081
00082 if (pseudoMultType_ != PROJECTDIST)
00083 setEstimates (info, &retval, &brkPt);
00084
00085 if (jnlst_ -> ProduceOutput (J_DETAILED, J_BRANCHING)) {
00086 printf("index = %d up = %e down = %e bounds [%e,%e] brpt = %e inf = %e\n",
00087 index, upEstimate_, downEstimate_,
00088 info -> lower_ [index],
00089 info -> upper_ [index], brkPt, retval);
00090 }
00091
00092 problem_ -> domain () -> pop ();
00093
00094 retval = ((retval <= CoinMin (COUENNE_EPS, feas_tolerance_)) ? 0. : retval);
00095
00096 int refInd = reference_ -> Index ();
00097
00098 if (reference_ -> isInteger ()) {
00099 CouNumber intinfeas = intInfeasibility (info -> solution_ [refInd],
00100 info -> lower_ [refInd],
00101 info -> upper_ [refInd]);
00102 if ((intinfeas > retval) &&
00103 (intinfeas > info -> integerTolerance_))
00104 retval = intinfeas;
00105 }
00106
00107
00108
00109
00110
00111 jnlst_ -> Printf (J_DETAILED, J_BRANCHING,
00112 "infVar x%d ==> returning %e\n", reference_ -> Index (), (reference_ -> isInteger ()) ?
00113 CoinMax (retval, intInfeasibility (info -> solution_ [refInd],
00114 info -> lower_ [refInd],
00115 info -> upper_ [refInd])) :
00116 retval);
00117
00118 return retval;
00119
00120
00121
00122
00123 }
00124
00125
00128 double CouenneVarObject::checkInfeasibility (const OsiBranchingInformation * info) const {
00129
00130 int index = reference_ -> Index ();
00131
00132 const std::set <int> &dependence = problem_ -> Dependence () [index];
00133
00134 if (dependence.size () == 0) {
00135
00136
00137
00138 if (fabs (info -> upper_ [index] -
00139 info -> lower_ [index]) /
00140 (1. + fabs (info -> solution_ [index])) < COUENNE_EPS)
00141 return 0.;
00142
00143
00144
00145 const CouenneObject *obj = problem_ -> Objects () [reference_ -> Index ()];
00146
00147 double retval = (obj -> Reference ()) ?
00148 (1. - 1. / (1. + info -> upper_ [index] - info -> lower_ [index])) *
00149 weiSum * obj -> checkInfeasibility (info) : 0.;
00150
00151 return retval;
00152
00153
00154
00155
00156
00157 } else {
00158
00159 CouNumber
00160 infsum = 0.,
00161 infmax = 0.,
00162 infmin = COIN_DBL_MAX;
00163
00164 for (std::set <int>::const_iterator i = dependence.begin ();
00165 i != dependence.end (); ++i) {
00166
00167
00168
00169 const CouenneObject *obj = problem_ -> Objects () [*i];
00170 CouNumber infeas = (obj -> Reference ()) ? obj -> checkInfeasibility (info) : 0.;
00171
00172 if (infeas > infmax) infmax = infeas;
00173 if (infeas < infmin) infmin = infeas;
00174 infsum += infeas;
00175 }
00176
00177 double retval =
00178 ((infmax < 1.e20) ?
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 (1. - 1. / (1. + info -> upper_ [index] - info -> lower_ [index])) : 1.) *
00190
00191 (weiSum * infsum +
00192 weiAvg * (infsum / CoinMax (1., (CouNumber) dependence.size ())) +
00193 weiMin * infmin +
00194 weiMax * infmax);
00195
00196 return retval;
00197
00198
00199
00200
00201 }
00202 }