coin-Bcp
MKC_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 _MKC_LP_H
4 #define _MKC_LP_H
5 
6 #include <cfloat>
7 
8 #include "BCP_parameters.hpp"
9 #include "BCP_lp_user.hpp"
10 
11 #include "MKC_lp_param.hpp"
12 #include "MKC_knapsack.hpp"
13 #include "MKC_var.hpp"
14 
15 //#############################################################################
16 
17 class MKC_lp : public BCP_lp_user {
18 public:
20  double* objhist;
22 
26 
28 
30  double start_time;
31 
32 public:
33  MKC_lp() :
34  objhist(0), ks_fixings(0), enumerated_ks(0), best_lb_in_root(-DBL_MAX) {}
35  ~MKC_lp() {
36  for (int i = 0; i < kss.ks_num; ++i) {
38  }
39  delete[] enumerated_ks;
40  delete[] ks_fixings;
41  delete[] objhist;
43  }
44  //###########################################################################
45  // unpack the initial info for the appropriate process
46  virtual void
48  //---------------------------------------------------------------------------
49  virtual void
50  pack_var_algo(const BCP_var_algo* var, BCP_buffer& buf);
51  //---------------------------------------------------------------------------
52  virtual BCP_var_algo*
54 
55  //---------------------------------------------------------------------------
56  virtual OsiSolverInterface *
58  //---------------------------------------------------------------------------
59  void
60  modify_lp_parameters(OsiSolverInterface* lp, bool in_strong_branching);
61  //---------------------------------------------------------------------------
62  virtual void
64  const BCP_vec<BCP_cut*>& cuts,
65  const BCP_vec<BCP_obj_status>& var_status,
66  const BCP_vec<BCP_obj_status>& cut_status,
67  BCP_vec<int>& var_changed_pos,
68  BCP_vec<double>& var_new_bd,
69  BCP_vec<int>& cut_changed_pos,
70  BCP_vec<double>& cut_new_bd);
71  //---------------------------------------------------------------------------
83  virtual double
84  compute_lower_bound(const double old_lower_bound,
85  const BCP_lp_result& lpres,
86  const BCP_vec<BCP_var*>& vars,
87  const BCP_vec<BCP_cut*>& cuts);
88  //---------------------------------------------------------------------------
89  // override default feasiblity testing.
90  // we want to do heuristics if it's not feasible
91  virtual BCP_solution*
92  test_feasibility(const BCP_lp_result& lp_result,
93  const BCP_vec<BCP_var*>& vars,
94  const BCP_vec<BCP_cut*>& cuts);
95  //---------------------------------------------------------------------------
96  // override default feasible solution packing
97  // since we generate heuristic solutions in test_feasibility, we got to
98  // pack them here.
99  virtual void
101 
102  //---------------------------------------------------------------------------
103  // restoring feasibility
104  // not needed, since the LP formulation is a set packing problem,
105  // thus it'll always be feasible. BCP will abort if any of them is called.
106 
107  //---------------------------------------------------------------------------
108  // Expand the user generated vars into columns
109  virtual void
110  vars_to_cols(const BCP_vec<BCP_cut*>& cuts, // on what to expand
111  BCP_vec<BCP_var*>& vars, // what to expand
112  BCP_vec<BCP_col*>& cols, // the expanded cols
113  // things that the user can use for lifting vars if allowed
114  const BCP_lp_result& lpres,
115  BCP_object_origin origin, bool allow_multiple);
116  // This is NOT AN INHERITED FUNCTION, just a shorter form of the previous
117  void
118  vars_to_cols(const BCP_vec<BCP_cut*>& cuts, // on what to expand
119  BCP_vec<BCP_var*>& vars, // what to expand
120  BCP_vec<BCP_col*>& cols); // the expanded cols
121 
122  //---------------------------------------------------------------------------
123  virtual void
124  generate_vars_in_lp(const BCP_lp_result& lpres,
125  const BCP_vec<BCP_var*>& vars,
126  const BCP_vec<BCP_cut*>& cuts,
127  const bool before_fathom,
128  BCP_vec<BCP_var*>& new_vars,
129  BCP_vec<BCP_col*>& new_cols);
130 
131  void
132  generate_vars(const BCP_lp_result& lpres,
133  const BCP_vec<BCP_var*>& vars,
134  const double rc_bound,
135  BCP_vec<BCP_var*>& new_vars);
136 
137  //---------------------------------------------------------------------------
138  virtual void
139  logical_fixing(const BCP_lp_result& lpres,
140  const BCP_vec<BCP_var*>& vars,
141  const BCP_vec<BCP_cut*>& cuts,
142  const BCP_vec<BCP_obj_status>& var_status,
143  const BCP_vec<BCP_obj_status>& cut_status,
144  const int var_bound_changes_since_logical_fixing,
145  BCP_vec<int>& changed_pos, BCP_vec<double>& new_bd);
146  //---------------------------------------------------------------------------
147  virtual BCP_branching_decision
149  const BCP_vec<BCP_var*>& vars,
150  const BCP_vec<BCP_cut*>& cuts,
151  const BCP_lp_var_pool& local_var_pool,
152  const BCP_lp_cut_pool& local_cut_pool,
154 };
155 
156 #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 pack_var_algo(const BCP_var_algo *var, BCP_buffer &buf)
~MKC_lp()
Definition: MKC_lp.hpp:35
virtual void unpack_module_data(BCP_buffer &buf)
Unpack the initial information sent to the LP process by the Tree Manager.
MKC_knapsack_fixing * ks_fixings
Definition: MKC_lp.hpp:23
MKC_knapsack_set kss
Definition: MKC_lp.hpp:21
BCP_vec< BCP_var * > generated_vars
Definition: MKC_lp.hpp:27
virtual BCP_var_algo * unpack_var_algo(BCP_buffer &buf)
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.
BCP_vec< MKC_var * > input_vars
Definition: MKC_lp.hpp:25
BCP_vec< MKC_var * > * enumerated_ks
Definition: MKC_lp.hpp:24
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 double compute_lower_bound(const double old_lower_bound, const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts)
Compute a true lower bound for the subproblem.
BCP_parameter_set< MKC_lp_par > par
Definition: MKC_lp.hpp:19
double best_lb_in_root
Definition: MKC_lp.hpp:29
double * objhist
Definition: MKC_lp.hpp:20
virtual OsiSolverInterface * initialize_solver_interface()
Create LP solver environment.
double start_time
Definition: MKC_lp.hpp:30
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 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.
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)
MKC_lp()
Definition: MKC_lp.hpp:33
virtual void generate_vars_in_lp(const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts, const bool before_fathom, BCP_vec< BCP_var * > &new_vars, BCP_vec< BCP_col * > &new_cols)
Generate variables within the LP process.
This is the class from which the user should derive her own algorithmic variables.
Definition: BCP_var.hpp:277
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39
virtual void initialize_new_search_tree_node(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, BCP_vec< int > &var_changed_pos, BCP_vec< double > &var_new_bd, BCP_vec< int > &cut_changed_pos, BCP_vec< double > &cut_new_bd)
Initializing a new search tree node.
void purge_ptr_vector(BCP_vec< T * > &pvec, typename BCP_vec< T * >::iterator first, typename BCP_vec< T * >::iterator last)
This function purges the entries [first,last) from the vector of pointers pvec.
Definition: BCP_vector.hpp:266
This class holds the results after solving an LP relaxation.
virtual void pack_feasible_solution(BCP_buffer &buf, const BCP_solution *sol)
Pack a MIP feasible solution into a buffer.
void modify_lp_parameters(OsiSolverInterface *lp, bool in_strong_branching)
virtual void vars_to_cols(const BCP_vec< BCP_cut * > &cuts, BCP_vec< BCP_var * > &vars, BCP_vec< BCP_col * > &cols, const BCP_lp_result &lpres, BCP_object_origin origin, bool allow_multiple)
Convert a set of variables into corresponding columns for the current LP relaxation.
void generate_vars(const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const double rc_bound, BCP_vec< BCP_var * > &new_vars)
This is the abstract base class for a solution to a Mixed Integer Programming problem.