00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <vector>
00011
00012 #include "CoinHelperFunctions.hpp"
00013 #include "CoinTime.hpp"
00014
00015 #include "CouenneTypes.hpp"
00016
00017 #include "exprVar.hpp"
00018
00019 #include "CouenneProblem.hpp"
00020 #include "depGraph.hpp"
00021 #include "lqelems.hpp"
00022
00023
00025 void CouenneProblem::reformulate () {
00026
00027 double now = CoinCpuTime ();
00028
00029 if (domain_.current () == NULL) {
00030
00031
00032 CouNumber
00033 *x = (CouNumber *) malloc ((nVars()) * sizeof (CouNumber)),
00034 *lb = (CouNumber *) malloc ((nVars()) * sizeof (CouNumber)),
00035 *ub = (CouNumber *) malloc ((nVars()) * sizeof (CouNumber));
00036
00037 for (int i = nVars(); i--;) {
00038 x [i] = 0.;
00039 lb [i] = -COUENNE_INFINITY;
00040 ub [i] = COUENNE_INFINITY;
00041 }
00042
00043 domain_.push (nVars (), x, lb, ub);
00044 }
00045
00046
00047 for (std::vector <exprVar *>::iterator i = variables_.begin ();
00048 i != variables_.end (); ++i)
00049 (*i) -> linkDomain (&domain_);
00050
00051 if (jnlst_ -> ProduceOutput(Ipopt::J_SUMMARY, J_PROBLEM))
00052 print (std::cout);
00053
00054
00055
00056
00057 nOrigCons_ = constraints_. size ();
00058 nOrigIntVars_ = nIntVars ();
00059
00060 jnlst_->Printf (Ipopt::J_SUMMARY, J_PROBLEM,
00061 "Problem size before reformulation: %d variables (%d integer), %d constraints.\n",
00062 nOrigVars_, nOrigIntVars_, nOrigCons_);
00063
00064
00065 if (!standardize ()) {
00066
00067 jnlst_->Printf(Ipopt::J_WARNING, J_PROBLEM,
00068 "Couenne: problem infeasible after reformulation\n");
00069
00070 for (int i = nVars (); i--;)
00071 Ub (i) = - (Lb (i) = 1.);
00072 }
00073
00074
00075 realign ();
00076
00077
00078
00079 initAuxs ();
00080
00081
00082 fillDependence (bonBase_);
00083
00084
00085 fillQuadIndices ();
00086
00087 if ((now = (CoinCpuTime () - now)) > 10.)
00088 jnlst_->Printf(Ipopt::J_WARNING, J_PROBLEM,
00089 "Couenne: reformulation time %.3fs\n", now);
00090
00091
00092 initAuxs ();
00093
00094 int nActualVars = nIntVars_ = 0;
00095
00096
00097 for (int i=0; i<nVars(); i++)
00098 if (variables_ [i] -> Multiplicity () > 0) {
00099
00100 nActualVars++;
00101 if (variables_ [i] -> isDefinedInteger ())
00102 nIntVars_++;
00103 }
00104
00105 jnlst_->Printf(Ipopt::J_SUMMARY, J_PROBLEM,
00106 "Problem size after reformulation: %d variables (%d integer), %d constraints.\n",
00107 nActualVars, nIntVars_, nCons());
00108
00109
00110 readOptimum ();
00111
00112 if (bonBase_) {
00113
00114 CouNumber
00115 art_cutoff = COIN_DBL_MAX,
00116 art_lower = -COIN_DBL_MAX;
00117
00118 bonBase_ -> options() -> GetNumericValue ("art_cutoff", art_cutoff, "couenne.");
00119 bonBase_ -> options() -> GetNumericValue ("art_lower", art_lower, "couenne.");
00120
00121 if (art_cutoff < 1.e50) setCutOff (art_cutoff);
00122 if (art_lower > -1.e50) {
00123 int indobj = objectives_ [0] -> Body () -> Index ();
00124 if (indobj >= 0)
00125 domain_.lb (indobj) = art_lower;
00126 }
00127 }
00128
00129 if (jnlst_->ProduceOutput(Ipopt::J_DETAILED, J_PROBLEM)) {
00130
00131 print (std::cout);
00132 }
00133
00134 createUnusedOriginals ();
00135
00136
00137
00138 }