/home/coin/SVN-release/OS-2.4.1/Couenne/src/heuristics/CouenneFPSolveNLP.cpp

Go to the documentation of this file.
00001 /* $Id: CouenneFPSolveNLP.cpp 720 2011-06-27 13:31:26Z pbelotti $
00002  *
00003  * Name:    CouenneFPSolveNLP.cpp
00004  * Authors: Pietro Belotti
00005  *          Timo Berthold, ZIB Berlin
00006  * Purpose: Implement the NLP solution method for the Feasibility Pump 
00007  * 
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #include "CbcModel.hpp"
00012 #include "CoinTime.hpp"
00013 #include "CoinHelperFunctions.hpp"
00014 
00015 #include "CouenneFeasPump.hpp"
00016 #include "CouenneMINLPInterface.hpp"
00017 #include "CouenneProblem.hpp"
00018 #include "CouenneProblemElem.hpp"
00019 #include "CouenneCutGenerator.hpp"
00020 
00021 #include "CouenneTNLP.hpp"
00022 
00023 using namespace Ipopt;
00024 using namespace Couenne;
00025 
00027 CouNumber CouenneFeasPump::solveNLP (CouNumber *iSol, CouNumber *&nSol) {
00028 
00029   // Solve the continuous nonlinear programming problem
00030   //
00031   // min  f(x)
00032   // s.t. g(x) <= 0
00033   //
00034   // where g(x) are the original constraints and f(x) is one of the
00035   // following:
00036   //
00037   // 1) sum {i in Vars} (x_i - x_i^0)^2
00038   // 2) sum {i in I}    (x_i - x_i^0)^2
00039   // 3) sum {i in Vars} (P^i (x - x^0))^2
00040   // 4) sum {i in I}    (P^i (x - x^0))^2
00041   //
00042   // where is x^0 is the optimal solution of a MILP problem. P should
00043   // be a PSD matrix, but the Hessian is, in general, indefinite at
00044   // the IP point we are starting from. A cheap convexification
00045   // consists of computing the minimum eigenvalue lambda_min of H and,
00046   // if lambda_min < 0, replace H with
00047   //
00048   // H - lambda_min I
00049   //
00050   // Similarly to the MILP case, we have
00051   //
00052   // P = beta I + (1-beta) (H + lambda_min I) 
00053   //   = (beta + lambda_min (1 - beta)) I + (1-beta) H
00054 
00055   bool firstNLP = (nlp_ == NULL);
00056 
00057   if (firstNLP) // first call (in this call to FP). Create NLP
00058     nlp_ = new CouenneTNLP (problem_);
00059 
00060   problem_ -> domain () -> push (problem_ -> nVars (),
00061                                  iSol,
00062                                  NULL, // replaces problem_ -> domain () -> lb (),
00063                                  NULL); // replaces problem_ -> domain () -> ub (),
00064                                  //false); // to avoid overlapping with nsol within NLP
00065 
00066   // set new objective
00067   expression
00068     *oldObj = problem_ -> Obj (0) -> Body (),
00069     *newObj = updateNLPObj (iSol);
00070 
00071   newObj   -> realign (problem_);
00072   problem_ -> setObjective (0, newObj);
00073   nlp_     -> setObjective (newObj);
00074 
00075   if (problem_ -> Jnlst () -> ProduceOutput (J_STRONGWARNING, J_NLPHEURISTIC)) {
00076     printf ("now solving NLP:\n");
00077     problem_ -> print ();
00078     printf ("-----------------------\n");
00079   }
00080 
00081   // FIXME: probably the previous NLP optimum is a better starting point
00082 
00083   // compute H_2-closest NLP feasible solution
00084   nlp_ -> setInitSol (iSol);
00085 
00087 
00088   ApplicationReturnStatus status = firstNLP ? 
00089     app_ -> OptimizeTNLP   (nlp_) :
00090     app_ -> ReOptimizeTNLP (nlp_);
00091 
00093 
00094   if (nlp_ -> getSolution ()) // check if non-NULL
00095 
00096     if  (nSol)  CoinCopyN       (nlp_ -> getSolution (), problem_ -> nVars (), nSol);
00097     else nSol = CoinCopyOfArray (nlp_ -> getSolution (), problem_ -> nVars ());
00098 
00099   else problem_ -> Jnlst () -> Printf 
00100       (J_ERROR, J_NLPHEURISTIC, "FP: warning, NLP returns a NULL solution\n");
00101 
00102   delete newObj;
00103 
00104   CouNumber retval;
00105 
00106   problem_ -> setObjective (0, oldObj);
00107 
00108   if ((status != Solve_Succeeded) &&
00109       (status != Solved_To_Acceptable_Level))
00110 
00111     problem_ -> Jnlst () -> Printf 
00112       (J_ERROR, J_NLPHEURISTIC, "Feasibility Pump: Error solving NLP problem\n");
00113 
00114   retval = nlp_ -> getSolValue ();
00115 
00116   problem_ -> domain () -> pop ();
00117 
00118   return retval;
00119 }

Generated on Thu Nov 10 03:05:45 2011 by  doxygen 1.4.7