1// Copyright (C) 2005, International Business Machines
2// Corporation and others. All Rights Reserved.
3// This code is licensed under the terms of the Eclipse Public License (EPL).
4
5#ifndef OsiSolverBranch_H
6#define OsiSolverBranch_H
7
8class OsiSolverInterface;
9#include "CoinWarmStartBasis.hpp"
10
11//#############################################################################
12
13/** Solver Branch Class
14
15 This provides information on a branch as a set of tighter bounds on both ways
16*/
17
18class OsiSolverBranch {
19
20public:
21 ///@name Add and Get methods
22 //@{
23 /// Add a simple branch (i.e. first sets ub of floor(value), second lb of ceil(value))
24 void addBranch(int iColumn, double value);
25
26 /// Add bounds - way =-1 is first , +1 is second
27 void addBranch(int way,int numberTighterLower, const int * whichLower, const double * newLower,
28 int numberTighterUpper, const int * whichUpper, const double * newUpper);
29 /// Add bounds - way =-1 is first , +1 is second
30 void addBranch(int way,int numberColumns,const double * oldLower, const double * newLower,
31 const double * oldUpper, const double * newUpper);
32
33 /// Apply bounds
34 void applyBounds(OsiSolverInterface & solver,int way) const;
35 /// Returns true if current solution satsifies one side of branch
36 bool feasibleOneWay(const OsiSolverInterface & solver) const;
37 /// Starts
38 inline const int * starts() const
39 { return start_;}
40 /// Which variables
41 inline const int * which() const
42 { return indices_;}
43 /// Bounds
44 inline const double * bounds() const
45 { return bound_;}
46 //@}
47
48
49 ///@name Constructors and destructors
50 //@{
51 /// Default Constructor
52 OsiSolverBranch();
53
54 /// Copy constructor
55 OsiSolverBranch(const OsiSolverBranch & rhs);
56
57 /// Assignment operator
58 OsiSolverBranch & operator=(const OsiSolverBranch & rhs);
59
60 /// Destructor
61 ~OsiSolverBranch ();
62
63 //@}
64
65private:
66 ///@name Private member data
67 //@{
68 /// Start of lower first, upper first, lower second, upper second
69 int start_[5];
70 /// Column numbers (if >= numberColumns treat as rows)
71 int * indices_;
72 /// New bounds
73 double * bound_;
74 //@}
75};
76//#############################################################################
77
78/** Solver Result Class
79
80 This provides information on a result as a set of tighter bounds on both ways
81*/
82
83class OsiSolverResult {
84
85public:
86 ///@name Add and Get methods
87 //@{
88 /// Create result
89 void createResult(const OsiSolverInterface & solver,const double * lowerBefore,
90 const double * upperBefore);
91
92 /// Restore result
93 void restoreResult(OsiSolverInterface & solver) const;
94
95 /// Get basis
96 inline const CoinWarmStartBasis & basis() const
97 { return basis_;}
98
99 /// Objective value (as minimization)
100 inline double objectiveValue() const
101 { return objectiveValue_;}
102
103 /// Primal solution
104 inline const double * primalSolution() const
105 { return primalSolution_;}
106
107 /// Dual solution
108 inline const double * dualSolution() const
109 { return dualSolution_;}
110
111 /// Extra fixed
112 inline const OsiSolverBranch & fixed() const
113 { return fixed_;}
114 //@}
115
116
117 ///@name Constructors and destructors
118 //@{
119 /// Default Constructor
120 OsiSolverResult();
121
122 /// Constructor from solver
123 OsiSolverResult(const OsiSolverInterface & solver,const double * lowerBefore,
124 const double * upperBefore);
125
126 /// Copy constructor
127 OsiSolverResult(const OsiSolverResult & rhs);
128
129 /// Assignment operator
130 OsiSolverResult & operator=(const OsiSolverResult & rhs);
131
132 /// Destructor
133 ~OsiSolverResult ();
134
135 //@}
136
137private:
138 ///@name Private member data
139 //@{
140 /// Value of objective (if >= OsiSolverInterface::getInfinity() then infeasible)
141 double objectiveValue_;
142 /// Warm start information
143 CoinWarmStartBasis basis_;
144 /// Primal solution (numberColumns)
145 double * primalSolution_;
146 /// Dual solution (numberRows)
147 double * dualSolution_;
148 /// Which extra variables have been fixed (only way==-1 counts)
149 OsiSolverBranch fixed_;
150 //@}
151};
152#endif
153