BonIpoptWarmStart.cpp
Go to the documentation of this file.
1 // (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2006
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // Pierre Bonami, Carnegie Mellon University,
7 // Andreas Waechter, International Business Machines Corporation
8 //
9 // Date : 02/15/2006
10 
11 #include "BonIpoptWarmStart.hpp"
12 #include "CoinHelperFunctions.hpp"
13 
14 #include "BonTMINLP2TNLP.hpp"
16 
17 using namespace Ipopt;
18 
19 namespace Bonmin
20 {
22  IpoptWarmStart::IpoptWarmStart
23  (bool empty, int numvars, int numcont):
24  CoinWarmStartPrimalDual(),
25  CoinWarmStartBasis(),
26  warm_starter_(NULL),
27  empty_(empty)
28  {
29  setSize(numvars,numcont);
30  }
32  IpoptWarmStart::IpoptWarmStart(const Ipopt::SmartPtr<TMINLP2TNLP> tnlp,
34  CoinWarmStartPrimalDual(tnlp->num_variables(),
35  2*tnlp->num_variables()+tnlp->num_constraints(),
36  tnlp->x_sol(), tnlp->duals_sol() ),
37  CoinWarmStartBasis(),
38  warm_starter_(warm_starter),
39  empty_(false)
40  {
41  int numcols = tnlp->num_variables();
42  int numrows = tnlp->num_constraints();
43  // initialize the size in the CoinWarmStartBasis part
44  setSize(numcols,numrows);
45  }
46 
48 IpoptWarmStart::IpoptWarmStart(int primal_size, int dual_size,
49  const double * primal, const double * dual):
50  CoinWarmStartPrimalDual(primal_size, dual_size, primal, dual),
51  CoinWarmStartBasis(),
52  warm_starter_(NULL),
53  empty_(false)
54 {
55  setSize(primal_size, dual_size - 2* primal_size);
56 }
58  IpoptWarmStart::IpoptWarmStart( const IpoptWarmStart &other, bool ownValues):
59  CoinWarmStartPrimalDual(other),
60  CoinWarmStartBasis(other),
61  warm_starter_(NULL /*other.warm_starter_*/),
62  empty_(other.empty_)
63  {
64  // if(ownValues_ && other.values_ != NULL)
65  }
66 
68  IpoptWarmStart::IpoptWarmStart(const CoinWarmStartPrimalDual& pdws) :
69  CoinWarmStartPrimalDual(pdws),
70  CoinWarmStartBasis(),
71  warm_starter_(NULL),
72  empty_(false)
73  {
74  }
75 
76  CoinWarmStartDiff*
77  IpoptWarmStart::generateDiff(const CoinWarmStart *const oldCWS) const
78  {
79  const IpoptWarmStart * const ws =
80  dynamic_cast< const IpoptWarmStart * const > (oldCWS);
81  DBG_ASSERT(ws);
82 
83  CoinWarmStartDiff * diff = CoinWarmStartPrimalDual::generateDiff(ws);
84 
85  CoinWarmStartPrimalDualDiff * pdDiff =
86  dynamic_cast<CoinWarmStartPrimalDualDiff*>(diff);
87 
88  CoinWarmStartDiff* retval =
89  new IpoptWarmStartDiff(pdDiff, NULL);//warm_starter_);
90  delete diff;
91 
92  return retval;
93  }
94 
95 
96  void
97  IpoptWarmStart::applyDiff (const CoinWarmStartDiff *const cwsdDiff)
98  {
99  IpoptWarmStartDiff const * const ipoptDiff =
100  dynamic_cast<IpoptWarmStartDiff const * const > (cwsdDiff);
101  DBG_ASSERT(ipoptDiff);
102  CoinWarmStartPrimalDual::applyDiff(ipoptDiff);
103  warm_starter_ = ipoptDiff->warm_starter();
104  }
105 
107  {}
108 
109  void
111  {
112  CoinWarmStartPrimalDual::clear();
113  }
114 
115  void
117  {
118  CoinWarmStartPrimalDualDiff::clear();
119  }
120 }
static Bigint * diff(Bigint *a, Bigint *b)
Definition: OSdtoa.cpp:1120
Class for storing warm start informations for Ipopt.
virtual CoinWarmStartDiff * generateDiff(const CoinWarmStart *const oldCWS) const
Generate the &quot;differences&quot; between two IpoptWarmStart.
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
Apply &#39;differences&#39; to an Ipopt warm start.
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real * ws
Ipopt::SmartPtr< IpoptInteriorWarmStarter > warm_starter() const
Accessor to warm start information obecjt.
virtual ~IpoptWarmStart()
Abstract destructor.
Ipopt::SmartPtr< IpoptInteriorWarmStarter > warm_starter_
warm start information object
Diff class for IpoptWarmStart.
IpoptWarmStart(bool empty=1, int numvars=0, int numcont=0)
Default constructor.
void flushPoint()
flush the starting point