#include <BCP_problem_core.hpp>
Public Member Functions | |
Constructors and destructor | |
BCP_problem_core_change (BCP_storage_t store=BCP_Storage_WrtCore) | |
BCP_problem_core_change (int bvarnum, BCP_var_set &vars, int bcutnum, BCP_cut_set &cuts) | |
BCP_problem_core_change (BCP_storage_t storage, BCP_problem_core_change &ocore, BCP_problem_core_change &ncore) | |
~BCP_problem_core_change () | |
Query methods | |
BCP_storage_t | storage () const |
size_t | varnum () const |
size_t | cutnum () const |
Modifying methods | |
BCP_problem_core_change & | operator= (const BCP_problem_core &core) |
void | ensure_explicit (const BCP_problem_core_change &expl_core) |
void | make_wrtcore_if_shorter (const BCP_problem_core_change &orig_core) |
void | swap (BCP_problem_core_change &other) |
void | update (const BCP_problem_core_change &expl_core, const BCP_problem_core_change &core_change) |
Packing and unpacking | |
int | pack_size () const |
void | pack (BCP_buffer &buf) const |
void | unpack (BCP_buffer &buf) |
Public Attributes | |
Data members | |
BCP_storage_t | _storage |
BCP_vec< int > | var_pos |
BCP_vec< BCP_obj_change > | var_ch |
BCP_vec< int > | cut_pos |
BCP_vec< BCP_obj_change > | cut_ch |
Private Member Functions | |
Private and disabled methods | |
void | clear () |
BCP_problem_core_change (const BCP_problem_core_change &) | |
BCP_problem_core_change & | operator= (const BCP_problem_core_change &x) |
..._pos
is empty and ..._ch
stores the bounds and stati.
Definition at line 116 of file BCP_problem_core.hpp.
|
The copy constructor is disabled by declaring it private and not defining it. |
|
This constructor creates a core change with the given storage. The other members are empty, i.e., the created object contains NoData; is Explicit and empty; is WrtCore or WrtParent but there's no change. Definition at line 172 of file BCP_problem_core.hpp. References _storage, cut_ch, cut_pos, var_ch, and var_pos.
|
|
This constructor creates an Explicit core change description. The first Definition at line 157 of file BCP_problem_core.cpp. References _storage, BCP_vec< BCP_var * >::begin(), cut_ch, BCP_vec< BCP_var * >::entry(), BCP_var::lb(), BCP_vec< BCP_obj_change >::reserve(), BCP_var::status(), BCP_var::ub(), BCP_vec< BCP_obj_change >::unchecked_push_back(), and var_ch.
00160 : 00161 _storage(BCP_Storage_Explicit), var_pos(), var_ch(), cut_pos(), cut_ch() 00162 { 00163 _storage = BCP_Storage_Explicit; 00164 var_ch.reserve(bvarnum); 00165 #if 0 00166 BCP_var_set::const_iterator vari; 00167 const BCP_var_set::const_iterator lastvari = vars.entry(bvarnum); 00168 for (vari = vars.begin(); vari != lastvari; ++vari) 00169 var_ch.unchecked_push_back(BCP_obj_change((*vari)->lb(), (*vari)->ub(), 00170 (*vari)->status())); 00171 #else 00172 for (int i = 0; i < bvarnum; ++i) { 00173 const BCP_var* v = vars[i]; 00174 var_ch.unchecked_push_back(BCP_obj_change(v->lb(),v->ub(), v->status())); 00175 } 00176 #endif 00177 cut_ch.reserve(bcutnum); 00178 BCP_cut_set::const_iterator cuti; 00179 const BCP_cut_set::const_iterator lastcuti = cuts.entry(bcutnum); 00180 for (cuti = cuts.begin(); cuti != lastcuti; ++cuti) 00181 cut_ch.unchecked_push_back(BCP_obj_change((*cuti)->lb(), (*cuti)->ub(), 00182 (*cuti)->status())); 00183 } |
|
Create a core change describing the changes from Definition at line 188 of file BCP_problem_core.cpp. References cut_ch, cut_pos, BCP_vec< BCP_obj_change >::reserve(), BCP_vec< int >::reserve(), storage(), BCP_vec< BCP_obj_change >::unchecked_push_back(), BCP_vec< int >::unchecked_push_back(), var_ch, and var_pos.
00190 : 00191 _storage(storage), var_pos(), var_ch(), cut_pos(), cut_ch() 00192 { 00193 if (storage != BCP_Storage_WrtParent && storage != BCP_Storage_WrtCore) { 00194 throw BCP_fatal_error("\ 00195 BCP_problem_core_change() : bad proposed storage\n"); 00196 } 00197 00198 if (ocore.storage() != BCP_Storage_Explicit) 00199 throw BCP_fatal_error("BCP_problem_core_change() : bad ocore storage\n"); 00200 if (ncore.storage() != BCP_Storage_Explicit) 00201 throw BCP_fatal_error("BCP_problem_core_change() : bad ncore storage\n"); 00202 00203 int i; 00204 00205 const int bvarnum = ncore.varnum(); 00206 var_pos.reserve(bvarnum); 00207 var_ch.reserve(bvarnum); 00208 for (i = 0; i < bvarnum; ++i) { 00209 if (ocore.var_ch[i] != ncore.var_ch[i]) { 00210 var_pos.unchecked_push_back(i); 00211 var_ch.unchecked_push_back(ncore.var_ch[i]); 00212 } 00213 } 00214 00215 const int bcutnum = ncore.cutnum(); 00216 cut_pos.reserve(bcutnum); 00217 cut_ch.reserve(bcutnum); 00218 for (i = 0; i < bcutnum; ++i) { 00219 if (ocore.cut_ch[i] != ncore.cut_ch[i]) { 00220 cut_pos.unchecked_push_back(i); 00221 cut_ch.unchecked_push_back(ncore.cut_ch[i]); 00222 } 00223 } 00224 } |
|
The destructor deletes all data members. Definition at line 192 of file BCP_problem_core.hpp.
00192 {} |
|
Clear all vector data members. Definition at line 116 of file BCP_problem_core.cpp. References BCP_vec< BCP_obj_change >::clear(), BCP_vec< int >::clear(), cut_ch, cut_pos, var_ch, and var_pos. Referenced by operator=().
|
|
Return the number of changed cuts (the length of the array Definition at line 204 of file BCP_problem_core.hpp. References cut_ch, and BCP_vec< BCP_obj_change >::size(). Referenced by make_wrtcore_if_shorter().
|
|
If the current storage is not already explicit then replace it with an explicit description of the core generated by applying the currently stored changes to Definition at line 229 of file BCP_problem_core.cpp. References _storage, storage(), swap(), and update().
00230 { 00231 if (_storage == BCP_Storage_Explicit) 00232 return; 00233 if (_storage != BCP_Storage_WrtCore) 00234 throw BCP_fatal_error("\ 00235 BCP_problem_core_change::ensure_explicit() : bad current storage\n"); 00236 if (ecore.storage() != BCP_Storage_Explicit) 00237 throw BCP_fatal_error("\ 00238 BCP_problem_core_change::ensure_explicit() : bad ecore storage\n"); 00239 00240 BCP_problem_core_change new_core; 00241 new_core.update(ecore, *this); 00242 swap(new_core); 00243 } |
|
Replace the current explicitly stored core change with one stored with respect to the explicitly stored original core change in Definition at line 249 of file BCP_problem_core.cpp. References _storage, cut_ch, cut_pos, cutnum(), BCP_vec< BCP_obj_change >::keep_by_index(), BCP_vec< T >::reserve(), BCP_vec< T >::size(), BCP_vec< BCP_obj_change >::size(), storage(), BCP_vec< int >::swap(), BCP_vec< T >::unchecked_push_back(), var_ch, var_pos, and varnum().
00250 { 00251 if (_storage != BCP_Storage_Explicit) 00252 throw BCP_fatal_error("\ 00253 BCP_problem_core_change::make_wrtcore_if_shorter() : bad storage\n"); 00254 if (ecore.storage() != BCP_Storage_Explicit) 00255 throw BCP_fatal_error("\ 00256 BCP_problem_core_change::make_wrtcore_if_shorter() : bad ecore storage\n"); 00257 if (varnum() != ecore.varnum()) 00258 throw BCP_fatal_error("\ 00259 BCP_problem_core_change::make_wrtcore_if_shorter() : nonequal sizes\n"); 00260 00261 int i; 00262 00263 // save the positions of the changed vars / cuts 00264 BCP_vec<int> chvar; 00265 chvar.reserve(ecore.varnum()); 00266 00267 const int bvarnum = var_ch.size(); 00268 for (i = 0; i < bvarnum; ++i) 00269 if (var_ch[i] != ecore.var_ch[i]) 00270 chvar.unchecked_push_back(i); 00271 00272 BCP_vec<int> chcut; 00273 chcut.reserve(ecore.cutnum()); 00274 00275 const int bcutnum = cut_ch.size(); 00276 for (i = 0; i < bcutnum; ++i) 00277 if (cut_ch[i] != ecore.cut_ch[i]) 00278 chcut.unchecked_push_back(i); 00279 00280 if ((chvar.size() + chcut.size()) * sizeof(int) < 00281 (ecore.varnum() - chvar.size() + ecore.cutnum() - chcut.size()) * 00282 BCP_obj_change::pack_size()) { 00283 // wrt core is shorter 00284 _storage = BCP_Storage_WrtCore; 00285 var_pos.swap(chvar); 00286 var_ch.keep_by_index(var_pos); 00287 cut_pos.swap(chcut); 00288 cut_ch.keep_by_index(cut_pos); 00289 } 00290 } |
|
Set the core change description to be an explicit description (in the form of a change) of the given Definition at line 136 of file BCP_problem_core.cpp. References _storage, BCP_vec< BCP_cut_core * >::begin(), BCP_vec< BCP_var_core * >::begin(), clear(), cut_ch, BCP_problem_core::cutnum(), BCP_problem_core::cuts, BCP_vec< BCP_cut_core * >::end(), BCP_vec< BCP_var_core * >::end(), BCP_vec< BCP_obj_change >::reserve(), BCP_vec< BCP_obj_change >::unchecked_push_back(), var_ch, BCP_problem_core::varnum(), and BCP_problem_core::vars.
00136 { 00137 clear(); 00138 _storage = BCP_Storage_Explicit; 00139 00140 var_ch.reserve(core.varnum()); 00141 BCP_vec<BCP_var_core*>::const_iterator vi = core.vars.begin(); 00142 const BCP_vec<BCP_var_core*>::const_iterator lastvi = core.vars.end(); 00143 for ( ; vi != lastvi; ++vi) 00144 var_ch.unchecked_push_back(BCP_obj_change((*vi)->lb(), (*vi)->ub(), 00145 BCP_ObjNotRemovable)); 00146 cut_ch.reserve(core.cutnum()); 00147 BCP_vec<BCP_cut_core*>::const_iterator ci = core.cuts.begin(); 00148 const BCP_vec<BCP_cut_core*>::const_iterator lastci = core.cuts.end(); 00149 for ( ; ci != lastci; ++ci) 00150 cut_ch.unchecked_push_back(BCP_obj_change((*ci)->lb(), (*ci)->ub(), 00151 BCP_ObjNotRemovable)); 00152 return *this; 00153 } |
|
The assignment operator is disabled by declaring it private and not defining it. Definition at line 124 of file BCP_problem_core.cpp. References _storage, cut_ch, cut_pos, var_ch, and var_pos. Referenced by update().
|
|
Pack the core change into the buffer. Definition at line 353 of file BCP_problem_core.cpp. References _storage, cut_ch, cut_pos, BCP_buffer::pack(), var_ch, and var_pos.
|
|
Return the buffer size needed to pack the data in the core change. Definition at line 342 of file BCP_problem_core.cpp. References cut_ch, cut_pos, BCP_vec< BCP_obj_change >::size(), BCP_vec< int >::size(), var_ch, and var_pos.
00342 { 00343 int siz = sizeof(BCP_storage_t); 00344 siz += sizeof(int) + sizeof(int) * var_pos.size(); 00345 siz += sizeof(int) + BCP_obj_change::pack_size() * var_ch.size(); 00346 siz += sizeof(int) + sizeof(int) * cut_pos.size(); 00347 siz += sizeof(int) + BCP_obj_change::pack_size() * cut_ch.size(); 00348 return siz; 00349 } |
|
Return the storage type. Definition at line 198 of file BCP_problem_core.hpp. References _storage. Referenced by BCP_problem_core_change(), ensure_explicit(), make_wrtcore_if_shorter(), and update().
00198 { return _storage; } |
|
Swap the contents of the current core change with that of Definition at line 294 of file BCP_problem_core.cpp. References _storage, cut_ch, cut_pos, BCP_vec< BCP_obj_change >::swap(), BCP_vec< int >::swap(), var_ch, and var_pos. Referenced by ensure_explicit().
|
|
Unpack the core change data from the buffer. Definition at line 361 of file BCP_problem_core.cpp. References _storage, cut_ch, cut_pos, BCP_buffer::unpack(), var_ch, and var_pos.
|
|
Update the current change according to
Definition at line 306 of file BCP_problem_core.cpp. References _storage, cut_ch, cut_pos, operator=(), storage(), BCP_vec< BCP_obj_change >::update(), var_ch, and var_pos. Referenced by ensure_explicit().
00308 { 00309 switch (ch_core._storage){ 00310 case BCP_Storage_Explicit: 00311 operator=(ch_core); // _storage becomes Explicit 00312 break; 00313 00314 case BCP_Storage_NoData: 00315 _storage = BCP_Storage_NoData; 00316 break; 00317 00318 case BCP_Storage_WrtCore: 00319 if (expl_core.storage() != BCP_Storage_Explicit) 00320 throw BCP_fatal_error("BCP_problem_core_change::update():\n\ 00321 ch_core's WrtCore, but expl_core's not Explicit\n"); 00322 operator=(expl_core); // _storage becomes Explicit 00323 // deliberate fall-through 00324 00325 case BCP_Storage_WrtParent: 00326 if (_storage != BCP_Storage_Explicit) 00327 throw BCP_fatal_error("BCP_problem_core_change::update():\n\ 00328 _storage isn't Explicit && ch_core's WrtParent\n"); 00329 var_ch.update(ch_core.var_pos, ch_core.var_ch); 00330 cut_ch.update(ch_core.cut_pos, ch_core.cut_ch); 00331 break; 00332 00333 default: 00334 throw BCP_fatal_error("\ 00335 BCP_problem_core_change::update(): bad ch_core storage!\n"); 00336 break; 00337 } 00338 } |
|
Return the number of changed variables (the length of the array Definition at line 201 of file BCP_problem_core.hpp. References BCP_vec< BCP_obj_change >::size(), and var_ch. Referenced by make_wrtcore_if_shorter().
|
|
Describes how the change is stored. The interpretation of the other data members depends on the storage type.
Definition at line 146 of file BCP_problem_core.hpp. Referenced by BCP_problem_core_change(), ensure_explicit(), make_wrtcore_if_shorter(), operator=(), pack(), storage(), swap(), unpack(), and update(). |
|
The new lb/ub/status triplet for each cut for which any of those three have changed. Definition at line 160 of file BCP_problem_core.hpp. Referenced by BCP_problem_core_change(), clear(), cutnum(), make_wrtcore_if_shorter(), operator=(), pack(), pack_size(), swap(), unpack(), and update(). |
|
The positions of the core cuts (in the Definition at line 157 of file BCP_problem_core.hpp. Referenced by BCP_problem_core_change(), clear(), make_wrtcore_if_shorter(), operator=(), pack(), pack_size(), swap(), unpack(), and update(). |
|
The new lb/ub/status triplet for each variable for which any of those three have changed. Definition at line 153 of file BCP_problem_core.hpp. Referenced by BCP_problem_core_change(), clear(), make_wrtcore_if_shorter(), operator=(), pack(), pack_size(), swap(), unpack(), update(), and varnum(). |
|
The positions of the core variables (in the Definition at line 150 of file BCP_problem_core.hpp. Referenced by BCP_problem_core_change(), clear(), make_wrtcore_if_shorter(), operator=(), pack(), pack_size(), swap(), unpack(), and update(). |