Bcp 1.4.4
Loading...
Searching...
No Matches
BCP_lp_pool.hpp
Go to the documentation of this file.
1// Copyright (C) 2000, International Business Machines
2// Corporation and others. All Rights Reserved.
3#ifndef _BCP_LP_POOL_H
4#define _BCP_LP_POOL_H
5
6#include "BCP_error.hpp"
7#include "BCP_vector.hpp"
8#include "BCP_lp_result.hpp"
9#include "BCP_matrix.hpp"
10#include "BCP_var.hpp"
11#include "BCP_cut.hpp"
12
13//#############################################################################
14
16private:
18 BCP_lp_waiting_row& operator=(const BCP_lp_waiting_row&);
19private:
20 BCP_cut* _cut;
21 BCP_row* _row;
22 double _violation;
23public:
24 BCP_lp_waiting_row(BCP_cut* cut, BCP_row* row=0, double viol=-1) :
25 _cut(cut), _row(row), _violation(viol) {}
27 delete _row;
28 delete _cut;
29 }
30
31 inline BCP_cut* cut() { return _cut; }
32 inline BCP_row* row() { return _row; }
33 inline const BCP_cut* cut() const { return _cut; }
34 inline const BCP_row* row() const { return _row; }
35
36 inline void clear_cut() { _cut = 0; }
37 inline void delete_row() { delete _row; _row = 0; _violation = -1;}
38 inline void set_row(BCP_row*& row) { _row = row; row = 0; }
39
40 inline double violation() const { return _violation; }
41 inline void set_violation(double v) { _violation = v; }
42 void compute_violation(const BCP_lp_result& lpres);
43};
44
45//-----------------------------------------------------------------------------
46
47class BCP_lp_cut_pool : public BCP_vec<BCP_lp_waiting_row*> {
48private:
49 static bool _rows_are_valid;
50 // disable the default copy constructor and assignment operator
52 BCP_lp_cut_pool& operator=(const BCP_lp_cut_pool&);
53public:
56 purge_ptr_vector(dynamic_cast< BCP_vec<BCP_lp_waiting_row*>& >(*this));
57 }
58
59 inline bool rows_are_valid() const { return _rows_are_valid; }
60 inline void rows_are_valid(bool status) { _rows_are_valid = status; }
61
62 inline void compute_violations(const BCP_lp_result& lpres,
65 if (! _rows_are_valid)
66 throw BCP_fatal_error("\
67BCP_lp_cut_pool::compute_violations() : rows are not valid\n");
68 while (first != last) {
69 (*first)->compute_violation(lpres);
70 ++first;
71 }
72 }
73 int remove_nonviolated(const double etol);
74};
75
76//#############################################################################
77
79private:
81 BCP_lp_waiting_col& operator=(const BCP_lp_waiting_col&);
82private:
83 BCP_var* _var;
84 BCP_col* _col;
85 double _red_cost;
86public:
88 _var(var), _col(col), _red_cost(rc) {}
90 delete _col;
91 delete _var;
92 }
93
94 inline BCP_var* var() { return _var; }
95 inline BCP_col* col() { return _col; }
96 inline const BCP_var* var() const { return _var; }
97 inline const BCP_col* col() const { return _col; }
98
99 inline void clear_var() { _var = 0; }
100 inline void delete_col() { delete _col; _col = 0; _red_cost = 0; }
101 inline void set_col(BCP_col*& col) { _col = col; col = 0; }
102
103 inline double red_cost() const { return _red_cost; }
104 void compute_red_cost(const BCP_lp_result& lpres);
105};
106
107//-----------------------------------------------------------------------------
108
109class BCP_lp_var_pool : public BCP_vec<BCP_lp_waiting_col*> {
110private:
111 static bool _cols_are_valid;
112 // disable the default copy constructor and assignment operator
114 BCP_lp_var_pool& operator=(const BCP_lp_var_pool&);
115public:
118 purge_ptr_vector(*(dynamic_cast<BCP_vec<BCP_lp_waiting_col*>*>(this)));
119 }
120
121 inline bool cols_are_valid() const { return _cols_are_valid; }
122 inline void cols_are_valid(bool status) { _cols_are_valid = status; }
123
124 inline void compute_red_costs(const BCP_lp_result& lpres,
127 if (! _cols_are_valid)
128 throw BCP_fatal_error("\
129BCP_lp_var_pool::compute_red_costs() : cols are not valid\n");
130 while (first != last) {
131 (*first)->compute_red_cost(lpres);
132 ++first;
133 }
134 }
135 int remove_positives(const double etol);
136};
137
138#endif
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.
This class holds a column in a compressed form.
Abstract base class that defines members common to all types of cuts.
Definition BCP_cut.hpp:29
Currently there isn't any error handling in BCP.
Definition BCP_error.hpp:20
int remove_nonviolated(const double etol)
void compute_violations(const BCP_lp_result &lpres, BCP_lp_cut_pool::iterator first, BCP_lp_cut_pool::iterator last)
void rows_are_valid(bool status)
bool rows_are_valid() const
This class holds the results after solving an LP relaxation.
int remove_positives(const double etol)
bool cols_are_valid() const
void cols_are_valid(bool status)
void compute_red_costs(const BCP_lp_result &lpres, BCP_lp_var_pool::iterator first, BCP_lp_var_pool::iterator last)
BCP_lp_waiting_col(BCP_var *var, BCP_col *col=0, double rc=0)
void set_col(BCP_col *&col)
const BCP_var * var() const
void compute_red_cost(const BCP_lp_result &lpres)
const BCP_col * col() const
double red_cost() const
void set_violation(double v)
double violation() const
void set_row(BCP_row *&row)
const BCP_cut * cut() const
const BCP_row * row() const
BCP_lp_waiting_row(BCP_cut *cut, BCP_row *row=0, double viol=-1)
void compute_violation(const BCP_lp_result &lpres)
This class holds a row in a compressed form.
Abstract base class that defines members common to all types of variables.
Definition BCP_var.hpp:28
The class BCP_vec serves the same purpose as the vector class in the standard template library.