# source:trunk/Couenne/src/heuristics/CouenneFPSolveNLP.cpp@618

Last change on this file since 618 was 618, checked in by pbelotti, 3 years ago

fixed Hessian. Now on minlplib/gear Couenne goes "Cbc0012I Integer solution of 2.7264506e-08 found by Couenne Feasibility Pump after 30 iterations and 1 nodes (0.13 seconds)"

• Property svn:eol-style set to `native`
• Property svn:keywords set to `Author Date Id Revision`
File size: 2.8 KB
Line
1/* \$Id\$
2 *
3 * Name:    CouenneFPSolveNLP.cpp
4 * Authors: Pietro Belotti
5 *          Timo Berthold, ZIB Berlin
6 * Purpose: Implement the NLP solution method for the Feasibility Pump
7 *
9 */
10
11#include "CbcModel.hpp"
12#include "CoinTime.hpp"
13#include "CoinHelperFunctions.hpp"
14
15#include "CouenneFeasPump.hpp"
16#include "CouenneMINLPInterface.hpp"
17#include "CouenneProblem.hpp"
18#include "CouenneProblemElem.hpp"
19#include "CouenneCutGenerator.hpp"
20
21#include "CouenneTNLP.hpp"
22
23using namespace Couenne;
24
25/// obtain continuous (if fractional) solution
26CouNumber CouenneFeasPump::solveNLP (CouNumber *iSol, CouNumber *&nSol) {
27
28  // Solve the continuous nonlinear programming problem
29  //
30  // min  f(x)
31  // s.t. g(x) <= 0
32  //
33  // where g(x) are the original constraints and f(x) is one of the
34  // following:
35  //
36  // 1) sum {i in Vars} (x_i - x_i^0)^2
37  // 2) sum {i in I}    (x_i - x_i^0)^2
38  // 3) sum {i in Vars} (P^i (x - x^0))^2
39  // 4) sum {i in I}    (P^i (x - x^0))^2
40  //
41  // where is x^0 is the optimal solution of a MILP problem. P should
42  // be a PSD matrix, but the Hessian is, in general, indefinite at
43  // the IP point we are starting from. A cheap convexification
44  // consists of computing the minimum eigenvalue lambda_min of H and,
45  // if lambda_min < 0, replace H with
46  //
47  // H - lambda_min I
48  //
49  // Similarly to the MILP case, we have
50  //
51  // P = beta I + (1-beta) (H + lambda_min I)
52  //   = (beta + lambda_min (1 - beta)) I + (1-beta) H
53
54  bool firstNLP = (nlp_ == NULL);
55
56  if (!nlp_) // first call (in this call to FP). Create NLP
57    nlp_ = new CouenneTNLP (problem_);
58
59  problem_ -> domain () -> push (problem_ -> nVars (),
60                                 iSol,
61                                 NULL, // replaces problem_ -> domain () -> lb (),
62                                 NULL, // replaces problem_ -> domain () -> ub (),
63                                 false);
64
65  // set new objective
66  expression
67    *newObj = updateNLPObj (iSol),
68    *oldObj = problem_ -> Obj (0) -> Body ();
69
70  problem_ -> setObjective (0, newObj);
71  nlp_     -> setObjective (newObj);
72
73  // compute H_2-closest NLP feasible solution
74  nlp_ -> setInitSol (iSol);
75
76  /////////////////////////////////////////////////////////
77
78  // shamelessly copied from hs071_main.cpp (it's Open Source too!)
79
80  ApplicationReturnStatus status = firstNLP ?
81    app_ -> OptimizeTNLP   (nlp_) :
82    app_ -> ReOptimizeTNLP (nlp_);
83
84  problem_ -> domain () -> pop ();
85
86  if (status != Solve_Succeeded)
87    printf ("FP: Error solving problem\n");
88
89  /////////////////////////////////////////////////////////
90
91  if (nlp_ -> getSolution ()) // check if non-NULL
92    nSol = CoinCopyOfArray (nlp_ -> getSolution (),
93                            problem_ -> nVars ());
94
95  // integer solution with nlp cuts
96  // until MINLP feasible
97
98  delete newObj;
99
100  problem_ -> setObjective (0, oldObj);
101  nlp_     -> setObjective (oldObj);
102
103  return nlp_ -> getSolValue ();
104}
Note: See TracBrowser for help on using the repository browser.