source: branches/devel/Bonmin/src/CbcBonmin/BonCbcNode.cpp @ 58

Last change on this file since 58 was 58, checked in by pbonami, 13 years ago

Finish renaming

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 4.3 KB
Line 
1// (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2006
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// Authors :
6// John J. Forrest, International Business Machines Corporation
7// P. Bonami, Carnegie Mellon University,
8//
9// Date : 03/15/2006
10
11
12#if defined(_MSC_VER)
13// Turn off compiler warning about long names
14#  pragma warning(disable:4786)
15#endif
16#include <string>
17#include <cassert>
18#include <cfloat>
19#include "OsiSolverInterface.hpp"
20#include "CoinWarmStartBasis.hpp"
21#include "CbcModel.hpp"
22#include "BonCbcNode.hpp"
23#include "BonOsiTMINLPInterface.hpp"
24#include "BonIpoptWarmStart.hpp"
25#include "BonIpoptInterface.hpp"
26
27using namespace std;
28
29
30namespace Bonmin{
31//Default constructor
32BonCbcFullNodeInfo::BonCbcFullNodeInfo()
33    :
34    CbcFullNodeInfo(),
35    sequenceOfInfeasiblesSize_(0),
36    sequenceOfUnsolvedSize_(0)
37{}
38
39BonCbcFullNodeInfo::BonCbcFullNodeInfo(CbcModel * model,
40    int numberRowsAtContinuous) :
41    CbcFullNodeInfo(model, numberRowsAtContinuous),
42    sequenceOfInfeasiblesSize_(0),
43    sequenceOfUnsolvedSize_(0)
44{
45}
46
47// Copy constructor
48BonCbcFullNodeInfo::BonCbcFullNodeInfo ( const BonCbcFullNodeInfo &other):
49    CbcFullNodeInfo(other),
50    sequenceOfInfeasiblesSize_(other.sequenceOfInfeasiblesSize_),
51    sequenceOfUnsolvedSize_(other.sequenceOfUnsolvedSize_)
52
53{}
54
55
56void
57BonCbcFullNodeInfo::allBranchesGone()
58{
59  IpoptWarmStart * ipws = dynamic_cast<IpoptWarmStart *>(basis_);
60  if(ipws)
61    ipws->flushPoint();
62}
63
64BonCbcFullNodeInfo::~BonCbcFullNodeInfo()
65{}
66
67CbcNodeInfo *
68BonCbcFullNodeInfo::clone() const
69{
70  return new BonCbcFullNodeInfo(*this);
71}
72/****************************************************************************************************/
73
74// Default constructor
75BonCbcPartialNodeInfo::BonCbcPartialNodeInfo ()
76    : CbcPartialNodeInfo(),
77    sequenceOfInfeasiblesSize_(0),
78    sequenceOfUnsolvedSize_(0)
79{
80}
81// Constructor from current state
82BonCbcPartialNodeInfo::BonCbcPartialNodeInfo (CbcModel * model,CbcNodeInfo *parent, CbcNode *owner,
83    int numberChangedBounds,
84    const int *variables,
85    const double *boundChanges,
86    const CoinWarmStartDiff *basisDiff)
87    : CbcPartialNodeInfo(parent,owner,numberChangedBounds,variables,
88        boundChanges,basisDiff),
89    sequenceOfInfeasiblesSize_(0),
90    sequenceOfUnsolvedSize_(0)
91{
92  IpoptInterface * ipopt = dynamic_cast<IpoptInterface *>(model->solver());
93  assert (ipopt);
94  Ipopt::ApplicationReturnStatus optimization_status
95  = ipopt->getOptStatus();
96  BonCbcPartialNodeInfo * nlpParent = dynamic_cast<BonCbcPartialNodeInfo *> (parent);
97  int numberInfeasible = 0;
98  int numberUnsolved = 0;
99  if(nlpParent)//father is not root
100  {
101    numberInfeasible = nlpParent->getSequenceOfInfeasiblesSize();
102    numberUnsolved =  nlpParent->getSequenceOfUnsolvedSize();
103//       if(!nlpParent->numberBranchesLeft_){
104//      IpoptWarmStartDiff * ipws = dynamic_cast<IpoptWarmStartDiff *>(nlpParent->basisDiff_);
105//      ipws->flushPoint();
106//       }
107  }
108  else {
109    BonCbcFullNodeInfo * nlpRoot = dynamic_cast<BonCbcFullNodeInfo *> (parent);
110    if(nlpRoot) {
111      numberInfeasible = nlpRoot->getSequenceOfInfeasiblesSize();
112      numberUnsolved =  nlpRoot->getSequenceOfUnsolvedSize();
113    }
114  }
115  if((optimization_status==Ipopt::Unrecoverable_Exception)||
116      (optimization_status==Ipopt::NonIpopt_Exception_Thrown)||
117      (optimization_status==Ipopt::Insufficient_Memory)||
118      (optimization_status==Ipopt::Restoration_Failed)||
119      (optimization_status==Ipopt::Internal_Error)||
120      (optimization_status==Ipopt::Maximum_Iterations_Exceeded))
121    sequenceOfUnsolvedSize_ = numberUnsolved + 1;
122
123  if(optimization_status==Ipopt::Infeasible_Problem_Detected)
124    sequenceOfInfeasiblesSize_ = numberInfeasible + 1;
125}
126
127BonCbcPartialNodeInfo::BonCbcPartialNodeInfo (const BonCbcPartialNodeInfo & rhs)
128
129    : CbcPartialNodeInfo(rhs),
130    sequenceOfInfeasiblesSize_(rhs.sequenceOfInfeasiblesSize_),
131    sequenceOfUnsolvedSize_(rhs.sequenceOfUnsolvedSize_)
132
133{}
134
135CbcNodeInfo *
136BonCbcPartialNodeInfo::clone() const
137{
138  return (new BonCbcPartialNodeInfo(*this));
139}
140
141void
142BonCbcPartialNodeInfo::allBranchesGone()
143{
144  IpoptWarmStartDiff * ipws = dynamic_cast<IpoptWarmStartDiff *>(basisDiff_);
145  if(ipws)
146    ipws->flushPoint();
147}
148
149BonCbcPartialNodeInfo::~BonCbcPartialNodeInfo ()
150{}
151}
Note: See TracBrowser for help on using the repository browser.