Camargue
lp_interface.hpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10 
11 #ifndef CMR_LP_INTERFACE_H
12 #define CMR_LP_INTERFACE_H
13 
14 #include "lp_util.hpp"
15 
16 #include <utility>
17 #include <vector>
18 #include <memory>
19 
20 namespace CMR {
21 
22 namespace Sep {
23 struct MIRgroup;
24 }
25 
26 namespace LP {
27 
33 class Relaxation {
34 public:
36 
38 
39  Relaxation();
40 
41  Relaxation(Relaxation &&lp) noexcept;
42  Relaxation& operator=(Relaxation &&lp) noexcept;
43 
44  Relaxation(const Relaxation &lp) = delete;
45  Relaxation& operator=(const Relaxation &lp) = delete;
46 
47  ~Relaxation();
48 
50 
52 
54  bool primal_feas() const;
55  bool dual_feas() const;
56 
57  int num_rows() const;
58  int num_cols() const;
59 
60  int it_count() const;
61 
62  double get_coeff(int row, int col) const;
63 
65  void get_rhs(std::vector<double> &rhs, int begin, int end) const;
66 
68  std::vector<double> lower_bds(int begin, int end) const;
69 
71  std::vector<double> upper_bds(int begin, int end) const;
72 
74  std::vector<char> senses(int begin, int end) const;
75 
77  void get_col(int col, std::vector<int> &cmatind,
78  std::vector<double> &cmatval) const;
79 
81  void get_row(int row, std::vector<int> &rmatind,
82  std::vector<double> &rmatval) const;
83 
84  SparseRow get_row(int row) const;
85 
87  void get_row_infeas(const std::vector<double> &x,
88  std::vector<double> &feas_stat, int begin,
89  int end) const;
90 
92  void get_col_infeas(const std::vector<double> &x,
93  std::vector<double> &feas_stat, int begin,
94  int end) const;
95 
96  double get_objval() const;
97 
98  SolStat get_stat() const;
99 
100  double condition_num() const;
101 
102  void get_x(std::vector<double> &x) const;
103 
104  std::vector<double> lp_vec() const;
105 
106 
108  void get_base(std::vector<int> &colstat, std::vector<int> &rowstat) const;
109 
110  Basis basis_obj() const;
111 
112  std::vector<int> col_stat() const;
113  std::vector<int> row_stat() const;
114 
116  void get_row_slacks(std::vector<double> &slack, int begin,
117  int end) const;
118 
120  std::vector<double> row_slacks(int begin, int end) const;
121 
123  void get_pi(std::vector<double> &pi, int begin, int end) const;
124 
126  std::vector<double> pi(int begin, int end) const;
127 
129  void get_redcosts(std::vector<double> &redcosts, int begin, int end) const;
130 
132  std::vector<double> redcosts(int begin, int end) const;
133 
135 
137 
140  void primal_strong_branch(const std::vector<double> &tour_vec,
141  const std::vector<int> &colstat,
142  const std::vector<int> &rowstat,
143  const std::vector<int> &indices,
144  std::vector<Estimate> &down_est,
145  std::vector<Estimate> &up_est,
146  std::vector<Basis> &contra_bases,
147  int itlim, double upperbound);
148 
150  void tighten_bound(int index, char sense, double val);
151 
153  void change_obj(int index, double val);
154 
156 
157 
159 
161 
162  void new_row(char sense, double rhs);
163 
164  void new_rows(const std::vector<char> &sense,
165  const std::vector<double> &rhs);
166 
167  void add_cut(double rhs, char sense,
168  const std::vector<int> &rmatind,
169  const std::vector<double> &rmatval);
170 
171  void add_cut(const SparseRow &sp_row);
172 
173  void add_cuts(const std::vector<double> &rhs,
174  const std::vector<char> &sense,
175  const std::vector<int> &rmatbeg,
176  const std::vector<int> &rmatind,
177  const std::vector<double> &rmatval);
178 
180  void del_set_rows(std::vector<int> &delstat);
181 
182  void add_col(const double objval,
183  const std::vector<int> &indices,
184  const std::vector<double> &coeffs,
185  const double lb, const double ub);
186 
188  void del_set_cols(std::vector<int> &delstat);
189 
191 
193 
196  void copy_start(const std::vector<double> &x);
197 
199  void copy_start(const std::vector<double> &x,
200  const std::vector<int> &col_stat,
201  const std::vector<int> &row_stat);
202 
204  void copy_base(const std::vector<int> &col_stat,
205  const std::vector<int> &row_stat);
206 
208  void copy_base(const Basis &base);
209 
210  void factor_basis();
211 
213 
215 
217  void switch_steepest();
218 
219  void primal_opt();
220  void dual_opt();
221  void nondegen_pivot(double upper_bound);
222 
224  void cb_nondegen_pivot(double upper_bound, Basis &base, int bas_freq);
225 
226  void one_primal_pivot();
227  void one_dual_pivot();
228 
229  void primal_recover();
230 
232 
233  void init_mir_data(Sep::MIRgroup &mir_data);
234 
235 private:
236  struct solver_impl;
237  std::unique_ptr<solver_impl> simpl_p;
238 };
239 
242  NDpivotHandle(Relaxation &_rel, double ub, int bfreq)
243  : rel(_rel), tour_base(), upper_bound(ub), basis_freq(bfreq) {}
244 
245  Relaxation &rel;
247 
248  double upper_bound;
249 
255 
256  int pfeas_itcount = 0;
257 };
258 
259 }
260 }
261 
262 #endif
SolStat
Enum class for categorizing solution statuses.
Definition: lp_util.hpp:42
Miscellaneous functions, structs/enums, and constants for LPs.
Definition: lp_interface.cpp:56
int basis_freq
How often to copy a basis.
Definition: lp_interface.hpp:254
Basis tour_base
A new basis for the tour to be set by the callback.
Definition: lp_interface.hpp:246
std::unique_ptr< solver_impl > simpl_p
Implementation hiding for solver.
Definition: lp_interface.hpp:236
Row and column basic statuses corresponding to some LP solution.
Definition: lp_util.hpp:76
Handle for data during a non-degenerate pivot callback.
Definition: lp_interface.hpp:241
LP::SparseRow get_row(const CCtsp_lpcut_in &cc_cut, const std::vector< int > &perm, const Graph::CoreGraph &core_graph)
SparseRow corresponding to Concorde cut.
Definition: process_cuts.cpp:30
double upper_bound
Value of best primal feasible solution.
Definition: lp_interface.hpp:248
Class for storing an lp relaxation via interface to an lp solver.
Definition: lp_interface.hpp:33
The namespace for this project.
Definition: abc_nodesel.hpp:20
Simple struct representing sparse matrix row for passing to LP solver.
Definition: lp_util.hpp:149
Memory-managed access to classes needed during safe GMI separation.
Definition: mirgroup.hpp:59