00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "CoinHelperFunctions.hpp"
00012
00013 #include "CouenneProblem.hpp"
00014 #include "CouenneExprVar.hpp"
00015
00016 using namespace Couenne;
00017
00019
00020 int CouenneProblem::impliedBounds (t_chg_bounds *chg_bds) const {
00021
00022 int nchg = 0;
00023
00024 CouNumber *knownOptimum = optimum_;
00025
00026 if (optimum_) {
00027
00028 for (int i=nVars(); i--; knownOptimum++)
00029
00030 if (*knownOptimum < Lb (i) ||
00031 *knownOptimum > Ub (i)) {
00032
00033 knownOptimum = NULL;
00034 break;
00035 }
00036
00037 if (knownOptimum)
00038 knownOptimum -= nVars ();
00039 }
00040
00041 if (Jnlst()->ProduceOutput(Ipopt::J_DETAILED, J_BOUNDTIGHTENING)) {
00042 Jnlst()->Printf(Ipopt::J_DETAILED, J_BOUNDTIGHTENING," backward =====================\n ");
00043 int j=0;
00044 for (int i=0; i < nVars (); i++)
00045 if (variables_ [i] -> Multiplicity () >= 0) {
00046 Jnlst()->Printf(Ipopt::J_MOREVECTOR, J_BOUNDTIGHTENING,
00047 "x_%03d [%+10g %+10g] ", i,
00048 domain_.lb (i),
00049 domain_.ub (i));
00050 if (!(++j % 6)) Jnlst()->Printf(Ipopt::J_MOREVECTOR, J_BOUNDTIGHTENING,"\n ");
00051 }
00052 if (j % 6) Jnlst()->Printf(Ipopt::J_MOREVECTOR, J_BOUNDTIGHTENING,"\n");
00053 }
00054
00055 for (int ii = nVars (); ii--;) {
00056
00057 int i = numbering_ [ii];
00058
00059 if (Lb (i) > Ub (i) &&
00060 (Lb (i) < Ub (i) + COUENNE_BOUND_PREC * (1 + CoinMin (fabs (Lb (i)), fabs (Ub (i)))))) {
00061
00062
00063
00064
00065
00066 CouNumber tmp = Lb (i);
00067 Lb (i) = Ub (i);
00068 Ub (i) = tmp;
00069 }
00070
00071 if ((variables_ [i] -> Type () == AUX) &&
00072 (variables_ [i] -> Multiplicity () > 0)) {
00073
00074 if (Lb (i) > Ub (i) + COUENNE_BOUND_PREC * (1 + CoinMin (fabs (Lb (i)), fabs (Ub (i))))) {
00075 Jnlst () -> Printf (Ipopt::J_DETAILED, J_BOUNDTIGHTENING,
00076 " implied bounds: w_%d has infeasible bounds [%g,%g]\n",
00077 i, Lb (i), Ub (i));
00078 return -1;
00079 }
00080
00081
00082
00083
00084 CouNumber
00085 l0 = Lb (i),
00086 u0 = Ub (i);
00087
00088 if (variables_ [i] -> Image () -> impliedBound
00089 (variables_ [i] -> Index (), Lb (), Ub (), chg_bds, variables_ [i] -> sign ())) {
00090
00091
00092
00093
00094
00095
00096
00097 if (Jnlst()->ProduceOutput(Ipopt::J_VECTOR, J_BOUNDTIGHTENING)) {
00098
00099 Jnlst()->Printf(Ipopt::J_VECTOR, J_BOUNDTIGHTENING,
00100 " impli %2d [%15.8g, %15.8g] -> [%15.8g, %15.8g]: ",
00101 i, l0, u0, Lb (i), Ub (i));
00102
00103 variables_ [i] -> print (std::cout);
00104
00105 if (Jnlst()->ProduceOutput(Ipopt::J_MOREVECTOR, J_BOUNDTIGHTENING)) {
00106 Jnlst()->Printf(Ipopt::J_MOREVECTOR, J_BOUNDTIGHTENING," := ");
00107 variables_ [i] -> Image () -> print (std::cout);
00108 }
00109
00110 Jnlst()->Printf(Ipopt::J_VECTOR, J_BOUNDTIGHTENING,"\n");
00111 }
00112
00113 if (knownOptimum &&
00114 ((knownOptimum [i] < Lb (i) - COUENNE_EPS) ||
00115 (knownOptimum [i] > Ub (i) + COUENNE_EPS)))
00116
00117 Jnlst () -> Printf (Ipopt::J_DETAILED, J_BOUNDTIGHTENING,
00118 "#### implied b_%d [%g,%g] cuts optimum %g\n",
00119 i, Lb (i), Ub (i),
00120 knownOptimum [i]);
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 nchg++;
00156 }
00157 }
00158 }
00159
00160 if (nchg)
00161 Jnlst () -> Printf (Ipopt::J_DETAILED, J_BOUNDTIGHTENING, " implied bounds: %d changes\n", nchg);
00162
00163 return nchg;
00164 }