00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "BonIpoptWarmStart.hpp"
00012 #include "CoinHelperFunctions.hpp"
00013
00014 #include "BonTMINLP2TNLP.hpp"
00015 #include "BonIpoptInteriorWarmStarter.hpp"
00016
00017
00018 namespace Bonmin
00019 {
00021 IpoptWarmStart::IpoptWarmStart
00022 (bool empty, int numvars, int numcont):
00023 CoinWarmStartPrimalDual(),
00024 CoinWarmStartBasis(),
00025 warm_starter_(NULL),
00026 empty_(empty)
00027 {
00028 setSize(numvars,numcont);
00029 }
00031 IpoptWarmStart::IpoptWarmStart(const Ipopt::SmartPtr<TMINLP2TNLP> tnlp,
00032 SmartPtr<IpoptInteriorWarmStarter> warm_starter):
00033 CoinWarmStartPrimalDual(tnlp->num_variables(),
00034 2*tnlp->num_variables()+tnlp->num_constraints(),
00035 tnlp->x_sol(), tnlp->duals_sol() ),
00036 CoinWarmStartBasis(),
00037 warm_starter_(warm_starter),
00038 empty_(false)
00039 {
00040 int numcols = tnlp->num_variables();
00041 int numrows = tnlp->num_constraints();
00042
00043 setSize(numcols,numrows);
00044 }
00045
00047 IpoptWarmStart::IpoptWarmStart(int primal_size, int dual_size,
00048 const double * primal, const double * dual):
00049 CoinWarmStartPrimalDual(primal_size, dual_size, primal, dual),
00050 CoinWarmStartBasis(),
00051 warm_starter_(NULL),
00052 empty_(false)
00053 {
00054 setSize(primal_size, dual_size - 2* primal_size);
00055 }
00057 IpoptWarmStart::IpoptWarmStart( const IpoptWarmStart &other, bool ownValues):
00058 CoinWarmStartPrimalDual(other),
00059 CoinWarmStartBasis(other),
00060 warm_starter_(NULL ),
00061 empty_(other.empty_)
00062 {
00063
00064 }
00065
00067 IpoptWarmStart::IpoptWarmStart(const CoinWarmStartPrimalDual& pdws) :
00068 CoinWarmStartPrimalDual(pdws),
00069 CoinWarmStartBasis(),
00070 warm_starter_(NULL),
00071 empty_(false)
00072 {
00073 }
00074
00075 CoinWarmStartDiff*
00076 IpoptWarmStart::generateDiff(const CoinWarmStart *const oldCWS) const
00077 {
00078 const IpoptWarmStart * const ws =
00079 dynamic_cast< const IpoptWarmStart * const > (oldCWS);
00080 DBG_ASSERT(ws);
00081
00082 CoinWarmStartDiff * diff = CoinWarmStartPrimalDual::generateDiff(ws);
00083
00084 CoinWarmStartPrimalDualDiff * pdDiff =
00085 dynamic_cast<CoinWarmStartPrimalDualDiff*>(diff);
00086
00087 CoinWarmStartDiff* retval =
00088 new IpoptWarmStartDiff(pdDiff, NULL);
00089 delete diff;
00090
00091 return retval;
00092 }
00093
00094
00095 void
00096 IpoptWarmStart::applyDiff (const CoinWarmStartDiff *const cwsdDiff)
00097 {
00098 IpoptWarmStartDiff const * const ipoptDiff =
00099 dynamic_cast<IpoptWarmStartDiff const * const > (cwsdDiff);
00100 DBG_ASSERT(ipoptDiff);
00101 CoinWarmStartPrimalDual::applyDiff(ipoptDiff);
00102 warm_starter_ = ipoptDiff->warm_starter();
00103 }
00104
00105 IpoptWarmStart::~IpoptWarmStart()
00106 {}
00107
00108 void
00109 IpoptWarmStart::flushPoint()
00110 {
00111 CoinWarmStartPrimalDual::clear();
00112 }
00113
00114 void
00115 IpoptWarmStartDiff::flushPoint()
00116 {
00117 CoinWarmStartPrimalDualDiff::clear();
00118 }
00119 }