BCP_warmstart_primaldual.cpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #include "CoinWarmStartPrimalDual.hpp"
5 
6 //#############################################################################
7 
8 CoinWarmStart*
10 {
12  return NULL;
13 
14  const BCP_vec<double>& primal = _primal.explicit_vector();
15  const BCP_vec<double>& dual = _dual.explicit_vector();
16  return new CoinWarmStartPrimalDual(primal.size(), dual.size(),
17  &primal[0], &dual[0]);
18 }
19 
20 //#############################################################################
21 
22 void
24 {
25  const BCP_warmstart_primaldual* const pdch =
26  dynamic_cast<const BCP_warmstart_primaldual* const>(change);
27  if (!pdch)
28  throw BCP_fatal_error("BCP_warmstart_primaldual::update\n \
29 Trying to update a BCP_warmstart_primaldual with a different warmstart!\n");
30 
31  _primal.update(pdch->_primal);
32  _dual.update(pdch->_dual);
33 }
34 
35 
36 //#############################################################################
37 
40  const BCP_vec<int>& del_vars,
41  const BCP_vec<int>& del_cuts,
42  const double petol,
43  const double detol) const
44 {
45  const BCP_warmstart_primaldual* const ows =
46  dynamic_cast<const BCP_warmstart_primaldual* const>(old_ws);
47  if (!ows)
48  throw BCP_fatal_error("\
49 Trying to describe a BCP_warmstart_primaldual as a change to a different ws!\n");
50 
52  throw BCP_fatal_error("\
53 BCP_warmstart_primaldual::as_change : current data is not explicit!\n");
54 
55  if (ows->storage() == BCP_Storage_WrtParent)
56  throw BCP_fatal_error("\
57 BCP_warmstart_primaldual::as_change : old_ws is WrtParent!\n");
58 
59  if (ows->storage() == BCP_Storage_NoData)
60  return new BCP_warmstart_primaldual(*this);
61 
62  // Both are explicit
65  del_vars, petol);
67  ws->_primal = _primal;
68 
69  new (&ws->_dual) BCP_vec_change<double>(ows->_dual, _dual, del_cuts, detol);
70  if (ws->_dual.storage_size() >= _dual.storage_size())
71  ws->_dual = _dual;
72 
73  return ws;
74 }
int storage_size() const
Return how much memory it&#39;ll take to pack this info.
const BCP_vec< T > & explicit_vector() const
Return a const reference to the vector if it is explicitly stored, otherwise throw an exception...
No data is stored.
Definition: BCP_enum.hpp:86
Warmstarting information for the LP solver.
The data stored is an explicit listing of values.
Definition: BCP_enum.hpp:88
virtual BCP_warmstart * as_change(const BCP_warmstart *const old_ws, const BCP_vec< int > &del_vars, const BCP_vec< int > &del_cuts, const double petol, const double detol) const
Return a pointer to a warmstart info describing the currently stored data as a change with respect to...
BCP_vec_change< double > _dual
The dual vector stored as a vector change.
BCP_warmstart_primaldual()
The default constructor creates an empty WrtParent warmstart info (i.e., no change wrt the parent)...
The data stored is with respect to the same kind of data in the parent of the search tree node...
Definition: BCP_enum.hpp:91
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real * ws
void update(const BCP_vec_change< T > &change)
Update the current vector with the argument vector.
Currently there isn&#39;t any error handling in BCP.
Definition: BCP_error.hpp:20
size_t size() const
Return the current number of entries.
Definition: BCP_vector.hpp:116
virtual CoinWarmStart * convert_to_CoinWarmStart() const
Return an CoinWarmStart object that can be fed to the LP engine.
virtual BCP_storage_t storage() const
Return how the warmstarting info is stored.
BCP_vec_change< double > _primal
The primal vector stored as a vector change.
virtual void update(const BCP_warmstart *const change)
Update the current data with the one in the argument.
This class describes a warmstart information that consists solely of the dual vector.