coin-Bcp
MC_lp.hpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #ifndef _MC_LP_H
4 #define _MC_LP_H
5 
6 #include "BCP_lp_user.hpp"
7 #include "BCP_parameters.hpp"
8 
9 #include "MC.hpp"
10 #include "MC_solution.hpp"
11 #include "MC_lp_param.hpp"
12 
14 class OsiSolverInterface;
15 
16 class MC_lp : public BCP_lp_user {
17 private:
18  MC_lp(const MC_lp&);
19  MC_lp& operator=(const MC_lp&);
20 public:
23 
24  // hold a history of objective values (for tailing off, until it's
25  // implemented in BCP
26  int hist_len;
27  double* objhist;
28  // hold the solution generated during cycle cut generation and return it in
29  // generate_heuristic_solution()
31  // Whether we have started to solve the problems to optimality
34 
35  // When using the volume alg in general, but solving to optimality with
36  // simplex using the reduced costs wrt. the duals of the volume, obj_shift
37  // is constant term after the cost transformation
38  double obj_shift;
39  // the presolved best candidate
41 
42 public:
43  MC_lp() : par(), mc(), objhist(0), soln(0), started_exact(false),
45  ~MC_lp() {
46  delete[] objhist;
47  delete soln;
48  }
49 
50  //--------------------------------------------------------------------------
51  // unpack the module data for the appropriate process
52  virtual void
54  //--------------------------------------------------------------------------
55  // Pack an algorithmic cut
56  virtual void
58  //--------------------------------------------------------------------------
59  // Unpack an algorithmic cut
60  virtual BCP_cut_algo*
62  //--------------------------------------------------------------------------
63  // Override the initializer so that we can choose between vol and simplex
64  // at runtime.
65  virtual OsiSolverInterface *
67 
68  //--------------------------------------------------------------------------
69  // Opportunity to reset things before optimization
70  virtual void
71  modify_lp_parameters(OsiSolverInterface* lp, bool in_strong_branching);
72  //--------------------------------------------------------------------------
73  // Feasibility testing
74  virtual BCP_solution*
75  test_feasibility(const BCP_lp_result& lp_result,
76  const BCP_vec<BCP_var*>& vars,
77  const BCP_vec<BCP_cut*>& cuts);
80  virtual BCP_solution*
82  const BCP_vec<BCP_var*>& vars,
83  const BCP_vec<BCP_cut*>& cuts);
86  mc_generate_heuristic_solution(const double* x,
87  const BCP_vec<BCP_var*>& vars,
88  const BCP_vec<BCP_cut*>& cuts);
89  //--------------------------------------------------------------------------
90  // feasible solution packing
91  virtual void
93  //--------------------------------------------------------------------------
94  // Convert the user generated cuts into rows
95  virtual void
96  cuts_to_rows(const BCP_vec<BCP_var*>& vars, // on what to expand
97  BCP_vec<BCP_cut*>& cuts, // what to expand
98  BCP_vec<BCP_row*>& rows, // the expanded rows
99  // things that the user can use for lifting cuts if allowed
100  const BCP_lp_result& lpres,
101  BCP_object_origin origin, bool allow_multiple);
102  //--------------------------------------------------------------------------
103  virtual void
104  generate_cuts_in_lp(const BCP_lp_result& lpres,
105  const BCP_vec<BCP_var*>& vars,
106  const BCP_vec<BCP_cut*>& cuts,
107  BCP_vec<BCP_cut*>& new_cuts,
108  BCP_vec<BCP_row*>& new_rows);
109  void
110  generate_cuts_in_lp(const double* x, const double* lhs,
111  const double objval,
112  const BCP_vec<BCP_var*>& vars,
113  const BCP_vec<BCP_cut*>& cuts,
114  BCP_vec<BCP_cut*>& new_cuts,
115  BCP_vec<BCP_row*>& new_rows);
116  void
118  BCP_vec<BCP_row*>& new_rows);
119  void
120  generate_mst_cuts(const double* x, const double* lhs,
121  const double objval,
122  const BCP_vec<BCP_var*>& vars,
123  const BCP_vec<BCP_cut*>& cuts,
124  BCP_vec<BCP_cut*>& new_cuts,
125  BCP_vec<BCP_row*>& new_rows);
126  void
127  generate_sp_cuts(const double* x, const double* lhs,
128  const double objval,
129  const BCP_vec<BCP_var*>& vars,
130  const BCP_vec<BCP_cut*>& cuts,
131  BCP_vec<BCP_cut*>& new_cuts,
132  BCP_vec<BCP_row*>& new_rows);
133  double
134  getMaxLpViol();
135  //--------------------------------------------------------------------------
137  compare_cuts(const BCP_cut* c0, const BCP_cut* c1);
138  //--------------------------------------------------------------------------
139  virtual void
140  logical_fixing(const BCP_lp_result& lpres,
141  const BCP_vec<BCP_var*>& vars,
142  const BCP_vec<BCP_cut*>& cuts,
143  const BCP_vec<BCP_obj_status>& var_status,
144  const BCP_vec<BCP_obj_status>& cut_status,
145  const int var_bound_changes_since_logical_fixing,
146  BCP_vec<int>& changed_pos, BCP_vec<double>& new_bd);
147  //--------------------------------------------------------------------------
148  // Helper functions to check if there has been a tailing off in the past k
149  // iterations
150  //--------------------------------------------------------------------------
151  bool
152  is_gap_tailoff_rel(const int k, const double minimp,
153  const double objval) const;
154  bool
155  is_lb_tailoff_abs(const int k, const double minimp,
156  const double objval) const;
157  bool
158  is_lb_tailoff_rel(const int k, const double minimp,
159  const double objval) const;
160  void
161  tailoff_test(bool& tailoff_gap_rel, bool& tailoff_lb_abs,
162  bool& tailoff_lb_rel, const double objval) const;
163  //--------------------------------------------------------------------------
166  const BCP_lp_result& lpres,
167  const BCP_vec<BCP_var*>& vars,
168  const BCP_vec<BCP_cut*>& cuts,
169  double& exact_obj);
170  //--------------------------------------------------------------------------
171  virtual BCP_branching_decision
173  const BCP_vec<BCP_var*>& vars,
174  const BCP_vec<BCP_cut*>& cuts,
175  const BCP_lp_var_pool& local_var_pool,
176  const BCP_lp_cut_pool& local_cut_pool,
178  void
180  OsiSolverInterface* exact_solver,
182  void
183  choose_branching_vars(const BCP_vec<BCP_var*>& vars, const double * x,
184  const int cand_num,
186  //--------------------------------------------------------------------------
189  BCP_presolved_lp_brobj* old_presolved);
190  virtual void
192 };
193 
194 #endif
BCP_object_origin
This enumerative constant describes the origin (originating process) of an object (variable or cut)...
Definition: BCP_enum.hpp:249
virtual void cuts_to_rows(const BCP_vec< BCP_var * > &vars, BCP_vec< BCP_cut * > &cuts, BCP_vec< BCP_row * > &rows, const BCP_lp_result &lpres, BCP_object_origin origin, bool allow_multiple)
Convert (and possibly lift) a set of cuts into corresponding rows for the current LP relaxation...
Definition: MC_lp.hpp:16
bool tried_hard_cuts_in_prev_major_iter
Definition: MC_lp.hpp:33
virtual void set_actions_for_children(BCP_presolved_lp_brobj *best)
Decide what to do with the children of the selected branching object.
BCP_presolved_lp_brobj * best_presolved
Definition: MC_lp.hpp:40
virtual void pack_cut_algo(const BCP_cut_algo *cut, BCP_buffer &buf)
bool is_lb_tailoff_rel(const int k, const double minimp, const double objval) const
Abstract base class that defines members common to all types of cuts.
Definition: BCP_cut.hpp:29
This is the class from which the user should derive her own algorithmic cuts.
Definition: BCP_cut.hpp:242
virtual void unpack_module_data(BCP_buffer &buf)
Unpack the initial information sent to the LP process by the Tree Manager.
void perform_strong_branching(const BCP_lp_result &lpres, OsiSolverInterface *exact_solver, BCP_vec< BCP_lp_branching_object * > &cands)
virtual BCP_branching_decision select_branching_candidates(const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts, const BCP_lp_var_pool &local_var_pool, const BCP_lp_cut_pool &local_cut_pool, BCP_vec< BCP_lp_branching_object * > &candidates)
MC_solution * soln
Definition: MC_lp.hpp:30
bool started_exact
Definition: MC_lp.hpp:32
virtual BCP_branching_object_relation compare_branching_candidates(BCP_presolved_lp_brobj *new_presolved, BCP_presolved_lp_brobj *old_presolved)
Decide which branching object is preferred for branching.
double getMaxLpViol()
The BCP_lp_user class is the base class from which the user can derive a problem specific class to be...
Definition: BCP_lp_user.hpp:75
virtual BCP_solution * test_feasibility(const BCP_lp_result &lp_result, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts)
Evaluate and return MIP feasibility of the current solution.
double obj_shift
Definition: MC_lp.hpp:38
virtual void logical_fixing(const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts, const BCP_vec< BCP_obj_status > &var_status, const BCP_vec< BCP_obj_status > &cut_status, const int var_bound_changes_since_logical_fixing, BCP_vec< int > &changed_pos, BCP_vec< double > &new_bd)
This method provides an opportunity for the user to tighten the bounds of variables.
~MC_lp()
Definition: MC_lp.hpp:45
virtual BCP_cut_algo * unpack_cut_algo(BCP_buffer &buf)
void generate_mst_cuts(const double *x, const double *lhs, const double objval, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts, BCP_vec< BCP_cut * > &new_cuts, BCP_vec< BCP_row * > &new_rows)
virtual BCP_solution * generate_heuristic_solution(const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts)
Try to generate a heuristic solution (or return one generated during cut/variable generation...
OsiSolverInterface * solveToOpt(OsiVolSolverInterface *vollp, const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts, double &exact_obj)
void unique_cycle_cuts(BCP_vec< BCP_cut * > &new_cuts, BCP_vec< BCP_row * > &new_rows)
void tailoff_test(bool &tailoff_gap_rel, bool &tailoff_lb_abs, bool &tailoff_lb_rel, const double objval) const
BCP_branching_decision
This enumerative constant is the return value of the select_branching_candidates() method in [BCP_lp_...
Abstract Base Class for describing an interface to a solver.
virtual void generate_cuts_in_lp(const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts, BCP_vec< BCP_cut * > &new_cuts, BCP_vec< BCP_row * > &new_rows)
Generate cuts within the LP process.
int hist_len
Definition: MC_lp.hpp:26
A presolved branching object candidate.
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39
void generate_sp_cuts(const double *x, const double *lhs, const double objval, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts, BCP_vec< BCP_cut * > &new_cuts, BCP_vec< BCP_row * > &new_rows)
bool is_lb_tailoff_abs(const int k, const double minimp, const double objval) const
MC_lp()
Definition: MC_lp.hpp:43
BCP_branching_object_relation
This enumerative constant is the return value of the compare_presolved_branching_objects() method in ...
virtual void pack_feasible_solution(BCP_buffer &buf, const BCP_solution *sol)
Pack a MIP feasible solution into a buffer.
double * objhist
Definition: MC_lp.hpp:27
This class holds the results after solving an LP relaxation.
MC_lp & operator=(const MC_lp &)
void choose_branching_vars(const BCP_vec< BCP_var * > &vars, const double *x, const int cand_num, BCP_vec< BCP_lp_branching_object * > &cands)
MC_problem mc
Definition: MC_lp.hpp:22
virtual void modify_lp_parameters(OsiSolverInterface *lp, bool in_strong_branching)
BCP_object_compare_result
This enumerative constant describes the possible outcomes when comparing two objects (variables or cu...
Definition: BCP_enum.hpp:276
BCP_parameter_set< MC_lp_par > par
Definition: MC_lp.hpp:21
MC_solution * mc_generate_heuristic_solution(const double *x, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts)
A local helper function.
virtual OsiSolverInterface * initialize_solver_interface()
Create LP solver environment.
bool is_gap_tailoff_rel(const int k, const double minimp, const double objval) const
virtual BCP_object_compare_result compare_cuts(const BCP_cut *c0, const BCP_cut *c1)
Compare two generated cuts.
Vol(ume) Solver Interface.
This is the abstract base class for a solution to a Mixed Integer Programming problem.