BCP_lp_colrow.cpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #include <memory>
4 #include <algorithm>
5 #include <numeric>
6 #include <cmath>
7 
8 #include "CoinHelperFunctions.hpp"
9 #include "CoinWarmStartBasis.hpp"
10 
11 #include "BCP_problem_core.hpp"
12 #include "BCP_lp_node.hpp"
13 #include "BCP_lp_result.hpp"
14 #include "BCP_lp_pool.hpp"
15 #include "BCP_lp.hpp"
16 #include "BCP_lp_branch.hpp"
17 #include "BCP_lp_user.hpp"
18 #include "BCP_lp_functions.hpp"
19 
20 //#############################################################################
21 // want to put the most violated constraints (most positive violation) to the
22 // back, so return true if wrow0's violation is smaller than wrow1's, i.e.,
23 // wrow0 is less desirable.
24 
25 inline static int BCP_compare_waiting_row_ptr(const BCP_lp_waiting_row* wrow0,
26  const BCP_lp_waiting_row* wrow1){
27  return wrow0->violation() < wrow1->violation();
28 }
29 
30 //#############################################################################
31 // want to put the most attractive variables (most negative reduced cost) to
32 // the back, so return true if wcol0's red cost is bigger (less negative) than
33 // wcol1's, i.e., wcol0 is less desirable.
34 
35 inline static int BCP_compare_waiting_col_ptr(const BCP_lp_waiting_col* wcol0,
36  const BCP_lp_waiting_col* wcol1){
37  return wcol0->red_cost() > wcol1->red_cost();
38 }
39 
40 //#############################################################################
41 
43 {
44  const BCP_lp_result& lpres = *p.lp_result;
45 
46  BCP_var_set& vars = p.node->vars;
47  const int varnum = vars.size();
48  BCP_cut_set& cuts = p.node->cuts;
49  const int cutnum = cuts.size();
50 
51  int i;
52  int newly_changed = 0;
53 
54  BCP_lp_check_ub(p);
55 
56  if (lpres.dj()) {
57  p.user->reduced_cost_fixing(lpres.dj(), lpres.x(),
58  p.ub() - lpres.objval() - p.granularity(),
59  vars, newly_changed);
60  }
61  if (newly_changed > 0 && p.param(BCP_lp_par::LpVerb_VarTightening)) {
62  printf("LP: Reduced cost fixing has changed the bounds on %i vars\n",
63  newly_changed);
64  }
65 
66  p.var_bound_changes_since_logical_fixing += newly_changed;
67 
68  BCP_vec<BCP_obj_status> var_status;
69  var_status.reserve(varnum);
70  for (i = 0; i < varnum; ++i)
71  var_status.unchecked_push_back(vars[i]->status());
72 
73  BCP_vec<BCP_obj_status> cut_status;
74  cut_status.reserve(cutnum);
75  for (i = 0; i < cutnum; ++i)
76  cut_status.unchecked_push_back(cuts[i]->status());
77 
78  bool lost_primal_feasibility = false;
79 
80  BCP_vec<int> changed_pos;
81  BCP_vec<double> new_bd;
82 
83  p.user->logical_fixing(lpres, vars, cuts, var_status, cut_status,
85  changed_pos, new_bd);
86 
87  if (2 * changed_pos.size() != new_bd.size())
88  throw BCP_fatal_error("logical_fixing() returned uneven vectors\n");
89 
90  const int change_num = changed_pos.size();
91  if (change_num > 0){
92  int bd_changes = 0;
93  const double * x = lpres.x();
94  const double petol = lpres.primalTolerance();
95  for (i = 0; i < change_num; ++i) {
96  // check that the new bounds are not looser than the old ones.
97  // throw an exception if not.
98  const int pos = changed_pos[i];
99  const double old_lb = vars[pos]->lb();
100  const double old_ub = vars[pos]->ub();
101  const double new_lb = new_bd[2*i];
102  const double new_ub = new_bd[2*i+1];
103  if (old_lb > new_lb + petol || old_ub < new_ub - petol) {
104  throw BCP_fatal_error("logical fixing enlarged feas region!\n");
105  }
106  // check that the new bounds are actually tighter than the old
107  // ones. Print a warning if not.
108  if (new_lb < old_lb + petol && new_ub > old_ub - petol) {
109  printf("LP: BCP_lp_fix_vars(): WARNING: no change in bounds.\n");
110  continue;
111  }
112  // otherwise register the bounds for change and check if primal
113  // feasibility is violated (dual feas can't be hurt: bound changes
114  // can hurt dual feasibility).
115  new_bd[2*bd_changes] = new_lb;
116  new_bd[2*bd_changes+1] = new_ub;
117  changed_pos[bd_changes] = pos;
118  ++bd_changes;
119  if ((x[pos] < new_lb - petol) || (x[pos] > new_ub + petol))
120  lost_primal_feasibility = true;
121  }
122  changed_pos.erase(changed_pos.entry(bd_changes), changed_pos.end());
123  new_bd.erase(new_bd.entry(2*bd_changes), new_bd.end());
124 
126 
127  if (bd_changes > 0) {
128  p.lp_solver->setColSetBounds(changed_pos.begin(), changed_pos.end(),
129  new_bd.begin());
130  vars.set_lb_ub(changed_pos, new_bd.begin());
131  if (bd_changes > 0 && p.param(BCP_lp_par::LpVerb_VarTightening)) {
132  printf("LP: Logical fixing has changed the bounds on %i vars\n",
133  bd_changes);
134  }
135  }
136  }
137 
138  return lost_primal_feasibility;
139 }
140 
141 //#############################################################################
142 
143 static void
145  const bool error_if_deletable)
146 {
147  int i, j;
148  const int delnum = deletable.size();
149  const int posnum = pos.size();
150  for (i = 0, j = 0; i < delnum && j < posnum; ) {
151 #ifdef PARANOID
152  if (error_if_deletable && deletable[i] == pos[j])
153  throw BCP_fatal_error("Bad pos in BCP_lp_reset_positions()\n");
154 #endif
155  if (deletable[i] < pos[j]) {
156  ++i;
157  } else {
158  pos[j] -= i;
159  ++j;
160  }
161  }
162  for ( ; j < posnum; ++j) {
163  pos[j] -= delnum;
164  }
165 }
166 
167 //#############################################################################
168 
169 void
170 BCP_delete_unwanted_candidates(const int num, const int added_num,
171  const BCP_vec<int>* pos,
172  BCP_vec<int>& deletable)
173 {
174  deletable.erase(std::lower_bound(deletable.begin(), deletable.end(),
175  num-added_num), deletable.end());
176  for (int i = num - added_num; i < num; ++i) {
177  deletable.push_back(i);
178  }
179  if (pos && !pos->empty()) {
180  BCP_vec<int>::iterator ifirst =
181  std::lower_bound(deletable.begin(), deletable.end(), (*pos)[0]);
182  BCP_vec<int>::iterator ilast =
183  std::upper_bound(ifirst, deletable.end(), pos->back());
184  deletable.erase(ifirst, ilast);
185  }
186 }
187 
188 //#############################################################################
191  const int added_colnum,
192  const int added_rownum,
193  const bool from_fathom,
194  const bool force_delete)
195 {
196  // If can is set then this function is invoked after branching is decided
197  // upon (in this case force_delete will be true, too). In this case we have
198  // to update the various positions in can.
199 
200  int del_num;
201 
202  BCP_lp_result& lpres = *p.lp_result;
203  BCP_var_set& vars = p.node->vars;
204  const size_t varnum = vars.size();
205  BCP_cut_set& cuts = p.node->cuts;
206  const size_t cutnum = cuts.size();
207 
208  OsiSolverInterface* lp = p.lp_solver;
209  CoinWarmStart* ws = lp->getWarmStart();
210  CoinWarmStartBasis* bas = dynamic_cast<CoinWarmStartBasis*>(ws);
211 
212  BCP_vec<int> deletable;
213  deletable.reserve(CoinMax(varnum, cutnum));
214 
215  // find out which columns could be deleted
216  p.user->select_vars_to_delete(lpres, vars, cuts, from_fathom, deletable);
217 
218  // clean up deletable
219  del_num = deletable.size();
220  if (del_num > 0) {
221  // Make sure deletable is sorted and has unique entries
222  std::sort(deletable.begin(), deletable.end());
223  deletable.erase(std::unique(deletable.begin(), deletable.end()),
224  deletable.end());
225  del_num = deletable.size();
226  if (can && added_colnum) {
227  // make sure that all but can's added cols are to be deleted
228  BCP_delete_unwanted_candidates(varnum, added_colnum,
229  can->forced_var_pos, deletable);
230  del_num = deletable.size();
231  }
232  if (bas) {
233  // If there's a basis throw out those from deletable which are in the
234  // basis UNLESS they are unwanted candidates
235  BCP_vec<int> do_not_delete;
236  for (int i = 0; i < del_num; ++i) {
237  const int ind = deletable[i];
238  if (can && ind >= (int)(varnum - added_colnum))
239  continue;
240  const CoinWarmStartBasis::Status stat = bas->getStructStatus(ind);
241  if (stat == CoinWarmStartBasis::basic ||
242  stat == CoinWarmStartBasis::isFree) {
243  // No, this can't be deleted
244  do_not_delete.push_back(i);
245  }
246  }
247  if (! do_not_delete.empty()) {
248  deletable.unchecked_erase_by_index(do_not_delete);
249  del_num = deletable.size();
250  }
251  }
252  }
253 
254  int min_by_frac =
255  static_cast<int>(varnum * p.param(BCP_lp_par::DeletedColToCompress_Frac));
256  int min_to_del = force_delete ?
257  0 : CoinMax(p.param(BCP_lp_par::DeletedColToCompress_Min), min_by_frac);
258 
259  if (del_num > min_to_del) {
261  printf("LP: Deleting %i columns from the matrix.\n", del_num);
262  if (can) {
263  if (can->forced_var_pos)
264  BCP_lp_reset_positions(deletable, *can->forced_var_pos, true);
265  if (can->implied_var_pos)
266  BCP_lp_reset_positions(deletable, *can->implied_var_pos, false);
267  }
268  if (bas) {
269  bas->deleteColumns(del_num, &deletable[0]);
270  }
271  p.lp_solver->deleteCols(del_num, &deletable[0]);
272  purge_ptr_vector_by_index(dynamic_cast< BCP_vec<BCP_var*>& >(vars),
273  deletable.begin(), deletable.end());
274  p.local_cut_pool->rows_are_valid(false);
275  }
276 
277  // Now do the same for rows
278  deletable.clear();
279  p.user->select_cuts_to_delete(lpres, vars, cuts, from_fathom, deletable);
280 
281  // clean up deletable
282  del_num = deletable.size();
283  if (del_num > 0) {
284  // Make sure deletable is sorted and has unique entries
285  std::sort(deletable.begin(), deletable.end());
286  deletable.erase(std::unique(deletable.begin(), deletable.end()),
287  deletable.end());
288  del_num = deletable.size();
289  if (can && added_rownum) {
290  // make sure that all but can's added rows are to be deleted
291  BCP_delete_unwanted_candidates(cutnum, added_rownum,
292  can->forced_cut_pos, deletable);
293  del_num = deletable.size();
294  }
295  if (bas) {
296  // If there's a basis throw out those from deletable which are not in
297  // the basis UNLESS they are unwanted candidates
298  BCP_vec<int> do_not_delete;
299  for (int i = 0; i < del_num; ++i) {
300  const int ind = deletable[i];
301  if (can && ind >= (int)(cutnum - added_rownum))
302  continue;
303  const CoinWarmStartBasis::Status stat = bas->getArtifStatus(ind);
304  if (stat != CoinWarmStartBasis::basic) {
305  // No, this can't be deleted
306  do_not_delete.push_back(i);
307  }
308  }
309  if (! do_not_delete.empty()) {
310  deletable.unchecked_erase_by_index(do_not_delete);
311  del_num = deletable.size();
312  }
313  }
314  }
315 
316  min_by_frac =
317  static_cast<int>(cutnum * p.param(BCP_lp_par::DeletedRowToCompress_Frac));
318  min_to_del = force_delete ?
319  0 : CoinMax(p.param(BCP_lp_par::DeletedRowToCompress_Min), min_by_frac);
320 
321  if (del_num > min_to_del) {
323  printf("LP: Deleting %i rows from the matrix.\n", del_num);
324  if (can) {
325  if (can->forced_cut_pos)
326  BCP_lp_reset_positions(deletable, *can->forced_cut_pos, true);
327  if (can->implied_cut_pos)
328  BCP_lp_reset_positions(deletable, *can->implied_cut_pos, false);
329  } else {
331  p.node->cuts.move_deletable_to_pool(deletable, p.slack_pool);
332  }
333  if (bas) {
334  bas->deleteRows(del_num, &deletable[0]);
335  }
336  p.lp_solver->deleteRows(deletable.size(), &deletable[0]);
337  purge_ptr_vector_by_index(dynamic_cast< BCP_vec<BCP_cut*>& >(cuts),
338  deletable.begin(), deletable.end());
339  p.node->lb_at_cutgen.erase_by_index(deletable);
340  p.local_var_pool->cols_are_valid(false);
341  }
342 
343  if (bas) {
344  if (varnum != vars.size() || cutnum != cuts.size()) {
345  // if anything got deleted set the modified basis
346  lp->setWarmStart(bas);
347  }
348  delete bas;
349  }
350 }
351 
352 //#############################################################################
353 
355 {
357  const BCP_lp_result& lpres = *p.lp_result;
358 
359  BCP_cut_set& cuts = p.node->cuts;
360  int i, ineff = 0;
361  const int cutnum = cuts.size();
362 
365  break;
367  {
368  const double * lhs = p.lp_result->lhs();
369  const double * rlb = p.lp_solver->getRowLower();
370  const double * rub = p.lp_solver->getRowUpper();
371  const double petol = lpres.primalTolerance();
372  for (i = p.core->cutnum(); i < cutnum; ++i) {
373  BCP_cut *cut = cuts[i];
374  if (rlb[i] + petol < lhs[i] && lhs[i] < rub[i] - petol) {
376  if (! cut->is_non_removable())
377  ++ineff;
378  } else {
380  }
381  }
382  }
383  break;
385  {
386  const double * pi = p.lp_result->pi();
387  const double detol = lpres.dualTolerance();
388  for (i = p.core->cutnum(); i < cutnum; ++i) {
389  BCP_cut *cut = cuts[i];
390  if (CoinAbs(pi[i]) < detol) {
392  if (! cut->is_non_removable())
393  ++ineff;
394  } else {
396  }
397  }
398  }
399  break;
400  }
402  printf("LP: Row effectiveness: rownum: %i ineffective: %i\n",
403  static_cast<int>(p.node->cuts.size()), ineff);
404  }
405 }
406 
407 //#############################################################################
408 
410 {
411  // First find out how many do we want to add
413  size_t added_rows =
414  std::min<size_t>(size_t(p.param(BCP_lp_par::MaxCutsAddedPerIteration)),
415  cp.size());
416 
417  if (added_rows == 0)
418  return 0;
419 
420  if (added_rows < cp.size()) {
421  /* The violations in the cut pool are: max(0, max(lb-lhs, lhs-ub)).
422  If the parameter says so then normalize it, so that we get the
423  distance of the fractional point from the cutting planes */
424  switch (p.param(BCP_lp_par::CutViolationNorm)) {
426  break;
428  for (int i = cp.size() - 1; i >= 0; --i) {
429  BCP_lp_waiting_row& cut = *cp[i];
430  if (cut.violation() > 0) {
431  cut.set_violation(cut.violation()/sqrt(cut.row()->normSquare()));
432  }
433  }
434  break;
436  const double* c = p.lp_solver->getObjCoefficients();
437  const int n = p.lp_solver->getNumCols();
438  const double cnorm = sqrt(std::inner_product(c, c+n, c, 0.0));
439  for (int i = cp.size() - 1; i >= 0; --i) {
440  BCP_lp_waiting_row& cut = *cp[i];
441  if (cut.violation() > 0) {
442  cut.set_violation(cut.violation() * cnorm /
443  fabs(cut.row()->dotProduct(c)));
444  }
445  }
446  }
447  break;
448  default:
449  throw BCP_fatal_error("LP: No violation norm specified!\n");
450  }
451  // Sort the waiting rows if we have more than we want to add. The most
452  // violated ones will be at the end with this sort.
453  std::sort(cp.begin(), cp.end(), BCP_compare_waiting_row_ptr);
454  }
455 
456 #ifdef PARANOID
457  if (! cp.rows_are_valid())
458  throw BCP_fatal_error
459  ("BCP_lp_add_from_local_cut_pool() : rows are not valid.\n");
460 #endif
461 
462  // Now collect the rows corresponding to the cuts to be added
463  // (those in [first, last) )
464  BCP_lp_cut_pool::const_iterator first = cp.entry(cp.size() - added_rows);
466  BCP_lp_cut_pool::const_iterator cpi = first - 1;
467 
468  // create the row set
469  const CoinPackedVectorBase** rows =
470  new const CoinPackedVectorBase*[added_rows];
471 
472  BCP_vec<double> rlb;
473  rlb.reserve(added_rows);
474 
475  BCP_vec<double> rub;
476  rub.reserve(added_rows);
477 
478  p.node->cuts.reserve(p.node->cuts.size() + added_rows);
479 
480  cpi = first - 1;
481  while (++cpi != last) {
482  BCP_row * row = (*cpi)->row();
483  BCP_cut * cut = (*cpi)->cut();
484  *rows++ = row;
485  rlb.unchecked_push_back(row->LowerBound());
486  rub.unchecked_push_back(row->UpperBound());
487  cut->set_effective_count(0);
488  p.node->cuts.unchecked_push_back(cut);
489  }
490  rows -= added_rows;
491  p.lp_solver->addRows(added_rows, rows, rlb.begin(), rub.begin());
492  cpi = first - 1;
493  while (++cpi != last) {
494  (*cpi)->clear_cut();
495  }
496 
497  delete[] rows;
498 
499  int leftover = cp.size() - added_rows;
500  const double frac = p.param(BCP_lp_par::MaxLeftoverCutFrac);
501  const int maxnum = p.param(BCP_lp_par::MaxLeftoverCutNum);
502  if (frac < 1.0) {
503  leftover = (frac <= 0.0) ? 0 : static_cast<int>(frac * leftover);
504  }
505  if (leftover > maxnum)
506  leftover = maxnum > 0 ? maxnum : 0;
507 
509  cp.entry(leftover), cp.end());
510 
511  p.node->lb_at_cutgen.insert(p.node->lb_at_cutgen.end(), added_rows,
512  p.lp_result->objval());
513  return added_rows;
514 }
515 
516 //#############################################################################
517 
519 {
520  // First find out how many do we want to add
522  size_t added_cols =
523  std::min<size_t>(size_t(p.param(BCP_lp_par::MaxVarsAddedPerIteration)),
524  vp.size());
525 
526  if (added_cols == 0)
527  return 0;
528 
529  if (added_cols < vp.size()) {
530  // Sort the waiting cols if we have more than we want to add. The most
531  // violated ones will be at the end with this sort.
532  std::sort(vp.begin(), vp.end(), BCP_compare_waiting_col_ptr);
533  }
534 
535 #ifdef PARANOID
536  if (! vp.cols_are_valid())
537  throw BCP_fatal_error
538  ("BCP_lp_add_from_local_var_pool() : cols are not valid.\n");
539 #endif
540 
541  // Now collect the colums corresponding to the variables to be added
542  // (those in [first, last) )
543  BCP_lp_var_pool::const_iterator first = vp.entry(vp.size() - added_cols);
545  BCP_lp_var_pool::const_iterator vpi = first - 1;
546 
547  // create the col set
548  const CoinPackedVectorBase** cols =
549  new const CoinPackedVectorBase*[added_cols];
550 
551  BCP_vec<double> clb;
552  clb.reserve(added_cols);
553 
554  BCP_vec<double> cub;
555  cub.reserve(added_cols);
556 
557  BCP_vec<double> obj;
558  obj.reserve(added_cols);
559 
560  p.node->vars.reserve(p.node->vars.size() + added_cols);
561 
562  vpi = first - 1;
563  while (++vpi != last) {
564  BCP_col* col = (*vpi)->col();
565  BCP_var* var = (*vpi)->var();
566  p.node->vars.unchecked_push_back(var);
567  // make certain that the bounds of integer vars is integer...
568  if (var->var_type() != BCP_ContinuousVar) {
569  var->set_lb(floor(var->lb()+1e-8));
570  var->set_ub(ceil(var->ub()-1e-8));
571  }
572  *cols++ = col;
573  clb.unchecked_push_back(col->LowerBound());
574  cub.unchecked_push_back(col->UpperBound());
575  obj.unchecked_push_back(col->Objective());
576  }
577  cols -= added_cols;
578  p.lp_solver->addCols(added_cols, cols,
579  clb.begin(), cub.begin(), obj.begin());
580  vpi = first - 1;
581  while (++vpi != last) {
582  (*vpi)->clear_var();
583  }
584 
585  delete[] cols;
586 
588  vp.entry(vp.size() - added_cols), vp.end());
589 
590  return added_cols;
591 }
592 
593 //#############################################################################
double LowerBound() const
Return the lower bound.
Definition: BCP_matrix.hpp:167
BCP_vec< int > * implied_var_pos
This class holds a column in a compressed form.
Definition: BCP_matrix.hpp:26
double LowerBound() const
Return the lower bound.
Definition: BCP_matrix.hpp:46
The violation is the distance of the fractional point from the cut.
Definition: BCP_enum.hpp:36
bool empty() const
Test if there are any entries in the object.
Definition: BCP_vector.hpp:121
double UpperBound() const
Return the upper bound.
Definition: BCP_matrix.hpp:48
BCP_lp_node * node
Description he current search tree node.
Definition: BCP_lp.hpp:168
void set_ub(const double ub)
Set the upper bound.
Definition: BCP_var.hpp:150
static void BCP_lp_reset_positions(const BCP_vec< int > &deletable, BCP_vec< int > &pos, const bool error_if_deletable)
How cut violation should be computed.
pos
position where the operator should be printed when printing the expression
void clear()
Delete every entry.
char param(BCP_lp_par::chr_params key) const
Definition: BCP_lp.hpp:275
The maximum fraction of the violated but not added cuts to be kept from one iteration to the next...
void set_effective_count(const int cnt)
Set the effectiveness count to the given value.
Definition: BCP_cut.hpp:115
void reduced_cost_fixing(const double *dj, const double *x, const double gap, BCP_vec< BCP_var * > &vars, int &newly_changed)
Reduced cost fixing.
BCP_var_set vars
double granularity() const
Definition: BCP_lp.hpp:289
Abstract base class that defines members common to all types of cuts.
Definition: BCP_cut.hpp:29
The violation is the directional (in the direction of the objective distance of the fractional point ...
Definition: BCP_enum.hpp:39
void move_deletable_to_pool(const BCP_vec< int > &deletable_cuts, BCP_vec< BCP_cut * > &pool)
Move the cut pointers whose indices are listed in deletable_cuts into the pool.
Definition: BCP_cut.cpp:118
iterator begin()
Return an iterator to the beginning of the object.
Definition: BCP_vector.hpp:99
const double * lhs() const
The number of rows that must be marked for deletion before matrix compression can occur...
const double * x() const
NO OLD DOC.
Definition: BCP_lp.hpp:102
This class is just a collection of pointers to cuts with a number of methods to manipulate these cuts...
Definition: BCP_cut.hpp:279
void reserve(const size_t n)
Reallocate the object to make space for n entries.
static int BCP_compare_waiting_col_ptr(const BCP_lp_waiting_col *wcol0, const BCP_lp_waiting_col *wcol1)
reference back()
Return a reference to the last entry.
Definition: BCP_vector.hpp:133
int BCP_lp_add_from_local_var_pool(BCP_lp_prob &p)
static const CouNumber pi
Definition: exprCos.cpp:23
void push_back(const_reference x)
Append x to the end of the vector.
static char * j
Definition: OSdtoa.cpp:3622
Constraints with dual variables at level zero are considered ineffective.
Definition: BCP_enum.hpp:188
BCP_cut_set cuts
static int BCP_compare_waiting_row_ptr(const BCP_lp_waiting_row *wrow0, const BCP_lp_waiting_row *wrow1)
Indicates which constraints should be considered ineffective.
int decrease_effective_count()
Decrease the effectiveness count by 1 (or to -1 if it was positive).
Definition: BCP_cut.hpp:124
void fint fint fint real fint real real real real real real real real real * e
BCP_vec< int > * implied_cut_pos
bool is_non_removable() const
Return whether the cut marked as NotRemovable.
Definition: BCP_cut.hpp:100
BCP_lp_cut_pool * local_cut_pool
Definition: BCP_lp.hpp:193
double ub() const
Return the upper bound.
Definition: BCP_var.hpp:91
void erase(iterator pos)
Erase the entry pointed to by pos.
double primalTolerance() const
Return the primal tolerance of the solver.
BCP_lp_user * user
A class that holds the methods about how to pack things.
Definition: BCP_lp.hpp:131
BCP_vec< int > * forced_cut_pos
Positions of cuts whose bounds change (&quot;forcibly&quot;, by branching) in the children. ...
void fint fint fint real fint real real real real real real real real real fint real fint * lp
void BCP_lp_adjust_row_effectiveness(BCP_lp_prob &p)
int increase_effective_count()
Increase the effectiveness count by 1 (or to 1 if it was negative).
Definition: BCP_cut.hpp:118
bool rows_are_valid() const
Definition: BCP_lp_pool.hpp:59
OsiSolverInterface * lp_solver
A class that holds the methods about how to pack things.
Definition: BCP_lp.hpp:137
BCP_lp_result * lp_result
Definition: BCP_lp.hpp:185
size_t cutnum() const
Return the number of cuts in the core.
double red_cost() const
void erase_by_index(const BCP_vec< int > &positions)
Erase the entries indexed by indices.
double objval() const
This class describes a generic branching object.
Print the number of variables whose bounds have been changed by reduced cost fixing or logical fixing...
BCP_vec< double > lb_at_cutgen
bool BCP_lp_fix_vars(BCP_lp_prob &p)
double ub() const
Definition: BCP_lp.hpp:300
The maximum number of variables that can be added per iteration.
double Objective() const
Return the objective coefficient.
Definition: BCP_matrix.hpp:44
double violation() const
Definition: BCP_lp_pool.hpp:40
The number of columns that must be marked for deletion before matrix compression can occur...
BCP_lp_var_pool * local_var_pool
Definition: BCP_lp.hpp:191
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real * ws
BCP_var_t var_type() const
Return the integrality type of the variable.
Definition: BCP_var.hpp:85
void insert(iterator position, const void *first, const size_t num)
Insert num entries starting from memory location first into the vector from position pos...
virtual void select_vars_to_delete(const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts, const bool before_fathom, BCP_vec< int > &deletable)
int BCP_lp_add_from_local_cut_pool(BCP_lp_prob &p)
Continuous variable.
Definition: BCP_enum.hpp:167
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< int > * forced_var_pos
Positions of variables whose bounds change (&quot;forcibly&quot;, by branching) in the children.
void set_lb_ub(const BCP_vec< int > &pos, BCP_vec< double >::const_iterator bounds)
Set the lower/upper bound pairs of the entries given by the contents of pos to the values in [bounds...
Definition: BCP_var.cpp:10
Abstract base class that defines members common to all types of variables.
Definition: BCP_var.hpp:28
Currently there isn&#39;t any error handling in BCP.
Definition: BCP_error.hpp:20
double UpperBound() const
Return the upper bound.
Definition: BCP_matrix.hpp:169
void BCP_lp_check_ub(BCP_lp_prob &p)
The maximum number of violated but not added cuts to be kept from one iteration to the next...
The fraction of columns that must be marked for deletion before matrix compression can occur...
The violation is interpreted in the normal sense, i.e., max(0, max(lb-lhs, lhs-ub)) ...
Definition: BCP_enum.hpp:34
virtual void select_cuts_to_delete(const BCP_lp_result &lpres, const BCP_vec< BCP_var * > &vars, const BCP_vec< BCP_cut * > &cuts, const bool before_fathom, BCP_vec< int > &deletable)
size_t size() const
Return the current number of entries.
Definition: BCP_vector.hpp:116
BCP_vec< BCP_cut * > slack_pool
Definition: BCP_lp.hpp:189
iterator end()
Return an iterator to the end of the object.
Definition: BCP_vector.hpp:104
This class is just a collection of pointers to variables with a number of methods to manipulate these...
Definition: BCP_var.hpp:316
void set_violation(double v)
Definition: BCP_lp_pool.hpp:41
The class BCP_vec serves the same purpose as the vector class in the standard template library...
Definition: BCP_vector.hpp:24
const double * pi() const
double dualTolerance() const
Return the dual tolerance of the solver.
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
void purge_ptr_vector_by_index(BCP_vec< T * > &pvec, typename BCP_vec< int >::const_iterator first, typename BCP_vec< int >::const_iterator last)
This function purges the entries indexed by [first,last) from the vector of pointers pvec...
Definition: BCP_vector.hpp:297
Print the number of ineffective rows in the current problem.
BCP_problem_core * core
Definition: BCP_lp.hpp:153
double lb() const
Return the lower bound.
Definition: BCP_var.hpp:89
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
Print the number of columns and rows that were deleted during matrix compression. ...
Constraints with nonzero (primal) slack value are considered ineffective.
Definition: BCP_enum.hpp:183
void set_lb(const double lb)
Set the lower bound.
Definition: BCP_var.hpp:145
The fraction of rows that must be marked for deletion before matrix compression can occur...
void BCP_delete_unwanted_candidates(const int num, const int added_num, const BCP_vec< int > *pos, BCP_vec< int > &deletable)
This class holds the results after solving an LP relaxation.
bool cols_are_valid() const
iterator entry(const int i)
Return an iterator to the i-th entry.
Definition: BCP_vector.hpp:109
void fint * n
real c
void BCP_lp_delete_cols_and_rows(BCP_lp_prob &p, BCP_lp_branching_object *can, const int added_colnum, const int added_rownum, const bool from_fathom, const bool force_delete)
The maximum number of violated valid inequalities that can be added per iteration.
None of the constraints are ever considered ineffective.
Definition: BCP_enum.hpp:180
If true, BCP supports branching on cuts by providing potential branching candidates for the user...
int var_bound_changes_since_logical_fixing
Definition: BCP_lp.hpp:187
void unchecked_erase_by_index(const BCP_vec< int > &positions)
Same as the previous method but without the sanity check.
void fint fint fint real fint real * x
This class holds a row in a compressed form.
Definition: BCP_matrix.hpp:152
const double * dj() const