Debian Codegraph @

Bonmin/src/Interfaces/BonAuxInfos.hpp

raw
1 // (C) Copyright International Business Machines Corporation 2007
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // Pierre Bonami, International Business Machines Corporation
7 //
8 // Date : 04/23/2007
9
10 #ifndef BonAuxInfos_H
11 #define BonAuxInfos_H
12 #include <cstdlib>
13 #include <vector>
14 #include "OsiAuxInfo.hpp"
15 #include "CoinSmartPtr.hpp"
16 #include "BonTypes.hpp"
17
18
19 namespace Bonmin {
20
21
22 /** Bonmin class for passing info between components of branch-and-cuts.*/
23 class AuxInfo : public OsiBabSolver {
24 public:
25 /** Default constructor.*/
26 AuxInfo(int type);
27
28 /** Constructor from OsiBabSolver.*/
29 AuxInfo(const OsiBabSolver &other);
30
31 /** Copy constructor.*/
32 AuxInfo(const AuxInfo &other);
33
34 /** Destructor.*/
35 virtual ~AuxInfo();
36
37 /** Virtual copy constructor.*/
38 virtual OsiAuxInfo * clone() const;
39
40 /** Declare the node to be feasible.*/
41 void setFeasibleNode(){
42 infeasibleNode_ = false;}
43
44 /** Declare the node to be infeasible.*/
45 void setInfeasibleNode(){
46 infeasibleNode_ = true;}
47
48 /** Say if current node is found feasible by cut generators.*/
49 bool infeasibleNode(){
50 return infeasibleNode_;}
51
52 /** Get solution found by nlp solver (or NULL if none found).*/
53 const double * nlpSolution(){
54
55 if(hasNlpSolution_)
56 return nlpSolution_;
57 else
58 return NULL;
59 }
60
61 /** Get objective value of nlp solution found, or +infinity if none exists */
62 double nlpObjValue ();
63
64 /** Pass a solution found by an nlp solver.*/
65 void setNlpSolution(const double * sol, int numcols, double objValue);
66
67 /** Say if has an nlp solution*/
68 void setHasNlpSolution(bool b){
69 hasNlpSolution_ = b;}
70 /** get the best solution computed with alternative objective function.*/
71 const std::vector<double>& bestSolution2() const
72 {
73 return (*bestSolution2_)();
74 }
75 /** return objective value of the best solution computed with alternative
76 objective function.*/
77 double bestObj2() const
78 {
79 return (*bestObj2_)();
80 }
81 /** Set an alternate objective value.*/
82 void setBestObj2(double o)
83 {
84 (*bestObj2_)() = o;
85 }
86 void setBestSolution2(int n, double * d)
87 {
88 (*bestSolution2_)().clear();
89 (*bestSolution2_)().insert((*bestSolution2_)().end(),d, d+n);
90 }
91 protected:
92 /** Say if current node was found infeasible during cut generation*/
93 bool infeasibleNode_;
94 /** value of the objective function of this nlp solution */
95 double objValue_;
96 /** nlp solution found by heuristic if any.*/
97 double * nlpSolution_;
98 /** numcols_ gives the size of nlpSolution_.*/
99 int numcols_;
100 /** say if has a solution.*/
101 bool hasNlpSolution_;
102 /** Stores the solution with alternate objective.*/
103 Coin::SmartPtr< SimpleReferenced<std::vector<double> > > bestSolution2_;
104 /** Alternate solution objective value.*/
105 Coin::SmartPtr< SimpleReferenced<double> > bestObj2_;
106 };
107 }/* End namespace.*/
108
109 #endif
110