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:
22  MC_problem mc;
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
32  bool started_exact;
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  // Override the initializer so that we can choose between vol and simplex
56  // at runtime.
57  virtual OsiSolverInterface *
59 
60  //--------------------------------------------------------------------------
61  // Opportunity to reset things before optimization
62  virtual void
63  modify_lp_parameters(OsiSolverInterface* lp, const int changeType,
64  bool in_strong_branching);
65  //--------------------------------------------------------------------------
66  // Feasibility testing
67  virtual BCP_solution*
68  test_feasibility(const BCP_lp_result& lp_result,
69  const BCP_vec<BCP_var*>& vars,
70  const BCP_vec<BCP_cut*>& cuts);
73  virtual BCP_solution*
75  const BCP_vec<BCP_var*>& vars,
76  const BCP_vec<BCP_cut*>& cuts);
79  mc_generate_heuristic_solution(const double* x,
80  const BCP_vec<BCP_var*>& vars,
81  const BCP_vec<BCP_cut*>& cuts);
82  //--------------------------------------------------------------------------
83  // feasible solution packing
84  virtual void
86  //--------------------------------------------------------------------------
87  // Convert the user generated cuts into rows
88  virtual void
89  cuts_to_rows(const BCP_vec<BCP_var*>& vars, // on what to expand
90  BCP_vec<BCP_cut*>& cuts, // what to expand
91  BCP_vec<BCP_row*>& rows, // the expanded rows
92  // things that the user can use for lifting cuts if allowed
93  const BCP_lp_result& lpres,
94  BCP_object_origin origin, bool allow_multiple);
95  //--------------------------------------------------------------------------
96  virtual void
98  const BCP_vec<BCP_var*>& vars,
99  const BCP_vec<BCP_cut*>& cuts,
100  BCP_vec<BCP_cut*>& new_cuts,
101  BCP_vec<BCP_row*>& new_rows);
102  void
103  generate_cuts_in_lp(const double* x, const double* lhs,
104  const double objval,
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
111  BCP_vec<BCP_row*>& new_rows);
112  void
113  generate_mst_cuts(const double* x, const double* lhs,
114  const double objval,
115  const BCP_vec<BCP_var*>& vars,
116  const BCP_vec<BCP_cut*>& cuts,
117  BCP_vec<BCP_cut*>& new_cuts,
118  BCP_vec<BCP_row*>& new_rows);
119  void
120  generate_sp_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  double
127  getMaxLpViol();
128  //--------------------------------------------------------------------------
130  compare_cuts(const BCP_cut* c0, const BCP_cut* c1);
131  //--------------------------------------------------------------------------
132  virtual void
133  logical_fixing(const BCP_lp_result& lpres,
134  const BCP_vec<BCP_var*>& vars,
135  const BCP_vec<BCP_cut*>& cuts,
136  const BCP_vec<BCP_obj_status>& var_status,
137  const BCP_vec<BCP_obj_status>& cut_status,
138  const int var_bound_changes_since_logical_fixing,
139  BCP_vec<int>& changed_pos, BCP_vec<double>& new_bd);
140  //--------------------------------------------------------------------------
141  // Helper functions to check if there has been a tailing off in the past k
142  // iterations
143  //--------------------------------------------------------------------------
144  bool
145  is_gap_tailoff_rel(const int k, const double minimp,
146  const double objval) const;
147  bool
148  is_lb_tailoff_abs(const int k, const double minimp,
149  const double objval) const;
150  bool
151  is_lb_tailoff_rel(const int k, const double minimp,
152  const double objval) const;
153  void
154  tailoff_test(bool& tailoff_gap_rel, bool& tailoff_lb_abs,
155  bool& tailoff_lb_rel, const double objval) const;
156  //--------------------------------------------------------------------------
159  const BCP_lp_result& lpres,
160  const BCP_vec<BCP_var*>& vars,
161  const BCP_vec<BCP_cut*>& cuts,
162  double& exact_obj);
163  //--------------------------------------------------------------------------
164  virtual BCP_branching_decision
166  const BCP_vec<BCP_var*>& vars,
167  const BCP_vec<BCP_cut*>& cuts,
168  const BCP_lp_var_pool& local_var_pool,
169  const BCP_lp_cut_pool& local_cut_pool,
171  bool force_branch = false);
172  void
174  OsiSolverInterface* exact_solver,
176  void
177  choose_branching_vars(const BCP_vec<BCP_var*>& vars, const double * x,
178  const int cand_num,
180  //--------------------------------------------------------------------------
183  BCP_presolved_lp_brobj* old_presolved);
184  virtual void
186 };
187 
188 #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
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
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
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.