00001 // Copyright (C) 2000, International Business Machines 00002 // Corporation and others. All Rights Reserved. 00003 #include "BCP_lp_pool.hpp" 00004 00005 void 00006 BCP_lp_waiting_row::compute_violation(const BCP_lp_result& lpres){ 00007 const double lhs = _row->dotProduct(lpres.x()); 00008 _violation = std::max<double>( 0.0, 00009 std::max<double>(_row->LowerBound()-lhs, 00010 lhs-_row->UpperBound())); 00011 } 00012 00013 int 00014 BCP_lp_cut_pool::remove_nonviolated(const double etol) 00015 { 00016 iterator waiting_row = begin(); 00017 int cnt = 0; 00018 00019 while (waiting_row != end()) { 00020 if ((*waiting_row)->violation() <= etol) { 00021 delete *waiting_row; 00022 *waiting_row = back(); 00023 pop_back(); 00024 ++cnt; 00025 } else { 00026 ++waiting_row; 00027 } 00028 } 00029 return cnt; 00030 } 00031 00032 //############################################################################# 00033 00034 void 00035 BCP_lp_waiting_col::compute_red_cost(const BCP_lp_result& lpres) 00036 { 00037 _red_cost = _col->Objective() - _col->dotProduct(lpres.pi()); 00038 } 00039 00040 int 00041 BCP_lp_var_pool::remove_positives(const double etol) 00042 { 00043 iterator waiting_col = begin(); 00044 int cnt = 0; 00045 00046 while (waiting_col != end()) { 00047 const double rc = (*waiting_col)->red_cost(); 00048 if (rc >= -etol) { 00049 // printf("LP: removing col with rc: %e (etol: %e)\n", rc, etol); 00050 delete *waiting_col; 00051 *waiting_col = back(); 00052 pop_back(); 00053 ++cnt; 00054 } else { 00055 ++waiting_col; 00056 } 00057 } 00058 return cnt; 00059 } 00060 00061 00062 //############################################################################# 00063 00064 bool BCP_lp_cut_pool::_rows_are_valid = true; 00065 00066 //############################################################################# 00067 00068 bool BCP_lp_var_pool::_cols_are_valid = true; 00069 00070 //############################################################################# 00071