Scippy

SoPlex

Sequential object-oriented simPlex

lprowsetbase.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2017 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file lprowsetbase.h
17  * @brief Set of LP columns.
18  */
19 #ifndef _LPROWSETBASE_H_
20 #define _LPROWSETBASE_H_
21 
22 
23 #include <assert.h>
24 
25 #include "spxdefines.h"
26 #include "basevectors.h"
27 #include "datakey.h"
28 #include "lprowbase.h"
29 
30 namespace soplex
31 {
32 /**@brief Set of LP rows.
33  * @ingroup Algebra
34  *
35  * Class LPRowSetBase implements a set of \ref LPRowBase "LPRowBase%s". Unless for memory limitations, any number of
36  * LPRowBase%s may be #add%ed to an LPRowSetBase. Single or multiple LPRowBase%s may be added to an LPRowSetBase, where
37  * each method add() comes with two different signatures. One with and one without a parameter, used for returning the
38  * Keys assigned to the new LPRowBase%s by the set. See DataKey for a more detailed description of the concept of
39  * keys. For the concept of renumbering LPRowBase%s within an LPRowSetBase after removal of some LPRows see DataSet.
40  *
41  * @see DataSet, DataKey
42 */
43 template < class R >
44 class LPRowSetBase : protected SVSetBase<R>
45 {
46  template < class S > friend class LPRowSetBase;
47 
48 private:
49 
50  // ------------------------------------------------------------------------------------------------------------------
51  /**@name Data */
52  //@{
53 
54  DVectorBase<R> left; ///< vector of left hand sides (lower bounds) of LPRowBase%s.
55  DVectorBase<R> right; ///< vector of right hand sides (upper bounds) of LPRowBase%s.
56  DVectorBase<R> object; ///< vector of objective coefficients.
57 
58  //@}
59 
60 protected:
61 
62  DataArray < int > scaleExp; ///< row scaling factors (stored as bitshift)
63 
64  // ------------------------------------------------------------------------------------------------------------------
65  /**@name Helpers */
66  //@{
67 
68  /// Returns the complete SVSet.
69  const SVSetBase<R>* rowSet() const
70  {
71  return this;
72  }
73 
74  //@}
75 
76 public:
77 
78  // ------------------------------------------------------------------------------------------------------------------
79  /**@name Access / modification */
80  //@{
81 
82  /// Returns the number of LPRowBase%s in LPRowSetBase.
83  int num() const
84  {
85  return SVSetBase<R>::num();
86  }
87 
88  /// Returns the maximum number of LPRowBase%s that fit.
89  int max() const
90  {
91  return SVSetBase<R>::max();
92  }
93 
94  /// Returns the vector of lhs values.
95  const VectorBase<R>& lhs() const
96  {
97  return left;
98  }
99 
100  /// Returns the vector of lhs values.
102  {
103  return left;
104  }
105 
106  /// Returns the lhs of the \p i 'th LPRowBase.
107  const R& lhs(int i) const
108  {
109  return left[i];
110  }
111 
112  /// Returns the lhs of the \p i 'th LPRowBase.
113  R& lhs_w(int i)
114  {
115  return left[i];
116  }
117 
118  /// Returns the lhs of the LPRowBase with DataKey \p k in LPRowSetBase.
119  const R& lhs(const DataKey& k) const
120  {
121  return left[number(k)];
122  }
123 
124  /// Returns the lhs of the LPRowBase with DataKey \p k in LPRowSetBase.
125  R& lhs_w(const DataKey& k)
126  {
127  return left[number(k)];
128  }
129 
130  /// Returns the vector of rhs values.
131  const VectorBase<R>& rhs() const
132  {
133  return right;
134  }
135 
136  /// Returns the vector of rhs values (writeable).
138  {
139  return right;
140  }
141 
142  /// Returns the rhs of the \p i 'th LPRowBase.
143  const R& rhs(int i) const
144  {
145  return right[i];
146  }
147 
148  /// Returns the rhs of the \p i 'th LPRowBase (writeable).
149  R& rhs_w(int i)
150  {
151  return right[i];
152  }
153 
154  /// Returns the rhs of the LPRowBase with DataKey \p k in LPRowSetBase.
155  const R& rhs(const DataKey& k) const
156  {
157  return right[number(k)];
158  }
159 
160  /// Returns the rhs of the LPRowBase with DataKey \p k in LPRowSetBase (writeable).
161  R& rhs_w(const DataKey& k)
162  {
163  return right[number(k)];
164  }
165 
166  /// Returns the vector of objective coefficients.
167  const VectorBase<R>& obj() const
168  {
169  return object;
170  }
171 
172  /// Returns the vector of objective coefficients (writeable).
174  {
175  return object;
176  }
177 
178  /// Returns the objective coefficient of the \p i 'th LPRowBase.
179  const R& obj(int i) const
180  {
181  return object[i];
182  }
183 
184  /// Returns the objective coefficient of the \p i 'th LPRowBase (writeable).
185  R& obj_w(int i)
186  {
187  return object[i];
188  }
189 
190  /// Returns the objective coefficient of the LPRowBase with DataKey \p k in LPRowSetBase.
191  const R& obj(const DataKey& k) const
192  {
193  return object[number(k)];
194  }
195 
196  /// Returns the objective coefficient of the LPRowBase with DataKey \p k in LPRowSetBase (writeable).
197  R& obj_w(const DataKey& k)
198  {
199  return object[number(k)];
200  }
201 
202  /// Returns a writable rowVector of the \p i 'th LPRowBase.
204  {
205  return SVSetBase<R>::operator[](i);
206  }
207 
208  /// Returns the rowVector of the \p i 'th LPRowBase.
209  const SVectorBase<R>& rowVector(int i) const
210  {
211  return SVSetBase<R>::operator[](i);
212  }
213 
214  /// Returns a writable rowVector of the LPRowBase with DataKey \p k.
216  {
217  return SVSetBase<R>::operator[](k);
218  }
219 
220  /// Returns the rowVector of the LPRowBase with DataKey \p k.
221  const SVectorBase<R>& rowVector(const DataKey& k) const
222  {
223  return SVSetBase<R>::operator[](k);
224  }
225 
226  /// Returns the inequalitiy type of the \p i 'th LPRowBase.
227  typename LPRowBase<R>::Type type(int i) const
228  {
229  if( rhs(i) >= double(infinity) )
231  if( lhs(i) <= double(-infinity) )
233  if( lhs(i) == rhs(i) )
234  return LPRowBase<R>::EQUAL;
235 
236  return LPRowBase<R>::RANGE;
237  }
238 
239  /// Returns the inequality type of the LPRowBase with DataKey \p k.
240  typename LPRowBase<R>::Type type(const DataKey& k) const
241  {
242  return type(number(k));
243  }
244 
245  /// Changes the inequality type of row \p i to \p type.
246  void setType(int i, typename LPRowBase<R>::Type t)
247  {
248  switch( t )
249  {
251  lhs_w(i) = -infinity;
252  break;
253  case LPRowBase<R>::EQUAL:
254  if( lhs_w(i) > -infinity )
255  rhs_w(i) = lhs(i);
256  else
257  lhs_w(i) = rhs(i);
258  break;
260  rhs_w(i) = infinity;
261  break;
262  case LPRowBase<R>::RANGE:
263  MSG_ERROR( std::cerr << "EROWST01 RANGE not supported in LPRowSet::setType()" << std::endl );
264  throw SPxInternalCodeException("XROWST01 This should never happen.");
265  default:
266  throw SPxInternalCodeException("XROWST02 This should never happen.");
267  }
268  }
269 
270  /// Returns the value of the \p i'th LPRowBase.
271  const R& value(int i) const
272  {
273  if( rhs(i) < infinity )
274  return rhs(i);
275  else
276  {
277  assert(lhs(i) > -infinity);
278  return lhs(i);
279  }
280  }
281 
282  /// Returns the value of the LPRowBase with DataKey \p k.
283  /** The \em value of a row depends on its type: if the inequality is of type "greater or equal", the value is the lhs
284  * of the row. Otherwise, the value is the rhs.
285  */
286  const R& value(const DataKey& k) const
287  {
288  return value(number(k));
289  }
290 
291  /// Returns the DataKey of the \p i 'th LPRowBase in LPRowSetBase.
292  DataKey key(int i) const
293  {
294  return SVSetBase<R>::key(i);
295  }
296 
297  /// Returns the number of the LPRowBase with DataKey \p k in LPRowSetBase.
298  int number(const DataKey& k) const
299  {
300  return SVSetBase<R>::number(k);
301  }
302 
303  /// does DataKey \p k belong to LPRowSetBase ?
304  bool has(const DataKey& k) const
305  {
306  return SVSetBase<R>::has(k);
307  }
308 
309  //@}
310 
311  // ------------------------------------------------------------------------------------------------------------------
312  /**@name Extension
313  *
314  * Extension methods come with two signatures, one of them providing a parameter to return the assigned
315  * DataKey(s). See DataSet for a more detailed description. All extension methods will automatically rearrange or
316  * allocate more memory if required.
317  */
318  //@{
319 
320  ///
321  void add(const LPRowBase<R>& row)
322  {
323  DataKey k;
324  add(k, row);
325  }
326 
327  /// Adds \p row to LPRowSetBase.
328  void add(DataKey& pkey, const LPRowBase<R>& prow)
329  {
330  add(pkey, prow.lhs(), prow.rowVector(), prow.rhs(), prow.obj());
331  }
332 
333  /// Adds LPRowBase consisting of left hand side \p lhs, row vector \p rowVector, and right hand side \p rhs to LPRowSetBase.
334  void add(const R& plhs, const SVectorBase<R>& prowVector, const R& prhs, const R& pobj = 0, const int& pscaleExp = 0)
335  {
336  DataKey k;
337  add(k, plhs, prowVector, prhs, pobj, pscaleExp);
338  }
339 
340  /// Adds LPRowBase consisting of left hand side \p lhs, row vector \p rowVector, and right hand side \p rhs to LPRowSetBase.
341  template < class S >
342  void add(const S* lhsValue, const S* rowValues, const int* rowIndices, int rowSize, const S* rhsValue, const S* objValue = 0)
343  {
344  assert(lhsValue != 0);
345  assert(rowSize <= 0 || rowValues != 0);
346  assert(rowSize <= 0 || rowIndices != 0);
347  assert(rhsValue != 0);
348 
349  DataKey k;
350  add(k, lhsValue, rowValues, rowIndices, rowSize, rhsValue, objValue);
351  }
352 
353  /// Adds LPRowBase consisting of left hand side \p lhs, row vector \p rowVector, and right hand side \p rhs to
354  /// LPRowSetBase, with DataKey \p key.
355  template < class S >
356  void add(DataKey& newkey, const S* lhsValue, const S* rowValues, const int* rowIndices, int rowSize, const S* rhsValue, const S* objValue = 0)
357  {
358  assert(lhsValue != 0);
359  assert(rowSize <= 0 || rowValues != 0);
360  assert(rowSize <= 0 || rowIndices != 0);
361  assert(rhsValue != 0);
362 
363  SVSetBase<R>::add(newkey, rowValues, rowIndices, rowSize);
364 
365  if( num() > left.dim() )
366  {
367  left.reDim(num());
368  right.reDim(num());
369  object.reDim(num());
370  }
371 
372  left[num() - 1] = *lhsValue;
373  right[num() - 1] = *rhsValue;
374  if( objValue != 0 )
375  object[num() - 1] = *objValue;
376  else
377  object[num() - 1] = 0;
378  }
379 
380  /// Adds LPRowBase consisting of left hand side \p lhs, row vector \p rowVector, and right hand side \p rhs to
381  /// LPRowSetBase, with DataKey \p key.
382  void add(DataKey& newkey, const R& newlhs, const SVectorBase<R>& newrowVector, const R& newrhs, const R& newobj = 0, const int& newscaleExp = 0)
383  {
384  SVSetBase<R>::add(newkey, newrowVector);
385 
386  if( num() > left.dim() )
387  {
388  left.reDim(num());
389  right.reDim(num());
390  object.reDim(num());
391  scaleExp.reSize(num());
392  }
393 
394  left[num() - 1] = newlhs;
395  right[num() - 1] = newrhs;
396  object[num() - 1] = newobj;
397  scaleExp[num() - 1] = newscaleExp;
398  }
399 
400  ///
401  void add(const LPRowSetBase<R>& newset)
402  {
403  int i = num();
404 
405  SVSetBase<R>::add(newset);
406 
407  if( num() > left.dim() )
408  {
409  left.reDim(num());
410  right.reDim(num());
411  object.reDim(num());
412  scaleExp.reSize(num());
413  }
414 
415  for( int j = 0; i < num(); ++i, ++j )
416  {
417  left[i] = newset.lhs(j);
418  right[i] = newset.rhs(j);
419  object[i] = newset.obj(j);
420  scaleExp[i] = newset.scaleExp[j];
421  }
422  }
423 
424  /// Adds all LPRowBase%s of \p set to LPRowSetBase.
425  void add(DataKey keys[], const LPRowSetBase<R>& set)
426  {
427  int i = num();
428 
429  add(set);
430 
431  for( int j = 0; i < num(); ++i, ++j )
432  keys[j] = key(i);
433  }
434 
435  /// Extends row \p n to fit \p newmax nonzeros.
436  void xtend(int n, int newmax)
437  {
438  SVSetBase<R>::xtend(rowVector_w(n), newmax);
439  }
440 
441  /// Extends row with DataKey \p key to fit \p newmax nonzeros.
442  void xtend(const DataKey& pkey, int pnewmax)
443  {
444  SVSetBase<R>::xtend(rowVector_w(pkey), pnewmax);
445  }
446 
447  /// Adds \p n nonzero (\p idx, \p val)-pairs to rowVector with DataKey \p k.
448  void add2(const DataKey& k, int n, const int idx[], const R val[])
449  {
450  SVSetBase<R>::add2(rowVector_w(k), n, idx, val);
451  }
452 
453  /// Adds \p n nonzero (\p idx, \p val)-pairs to \p i 'th rowVector.
454  void add2(int i, int n, const int idx[], const R val[])
455  {
456  SVSetBase<R>::add2(rowVector_w(i), n, idx, val);
457  }
458 
459  /// Adds \p n nonzero (\p idx, \p val)-pairs to \p i 'th rowVector.
460  template < class S >
461  void add2(int i, int n, const int idx[], const S val[])
462  {
463  SVSetBase<R>::add2(rowVector_w(i), n, idx, val);
464  }
465 
466  /// Creates new LPRowBase with specified parameters and returns a reference to its row vector.
467  SVectorBase<R>& create(int pnonzeros = 0, const R& plhs = 0, const R& prhs = 1, const R& pobj = 0, const int& pscaleExp = 0)
468  {
469  DataKey k;
470  return create(k, pnonzeros, plhs, prhs, pobj, pscaleExp);
471  }
472 
473  /// Creates new LPRowBase with specified parameters and returns a reference to its row vector.
474  SVectorBase<R>& create(DataKey& newkey, int nonzeros = 0, const R& newlhs = 0, const R& newrhs = 1, const R& newobj = 0, const int& newscaleExp = 0)
475  {
476  if( num() + 1 > left.dim() )
477  {
478  left.reDim(num() + 1);
479  right.reDim(num() + 1);
480  object.reDim(num() + 1);
481  scaleExp.reSize(num() + 1);
482  }
483 
484  left[num()] = newlhs;
485  right[num()] = newrhs;
486  object[num()] = newobj;
487  scaleExp[num()] = newscaleExp;
488 
489  return *SVSetBase<R>::create(newkey, nonzeros);
490  }
491 
492  //@}
493 
494  // ------------------------------------------------------------------------------------------------------------------
495  /**@name Shrinking
496  *
497  * See DataSet for a description of the renumbering of the remaining LPRowBase%s in a LPRowSetBase after the call of
498  * a removal method.
499  */
500  //@{
501 
502  /// Removes \p i 'th LPRowBase.
503  void remove(int i)
504  {
506  left[i] = left[num()];
507  right[i] = right[num()];
508  object[i] = object[num()];
509  scaleExp[i] = scaleExp[num()];
510  left.reDim(num());
511  right.reDim(num());
512  object.reDim(num());
513  scaleExp.reSize(num());
514  }
515 
516  /// Removes LPRowBase with DataKey \p k.
517  void remove(const DataKey& k)
518  {
519  remove(number(k));
520  }
521 
522  /// Removes multiple LPRowBase%s.
523  void remove(int perm[])
524  {
525  int j = num();
526 
527  SVSetBase<R>::remove(perm);
528 
529  for( int i = 0; i < j; ++i )
530  {
531  if( perm[i] >= 0 && perm[i] != i )
532  {
533  left[perm[i]] = left[i];
534  right[perm[i]] = right[i];
535  object[perm[i]] = object[i];
536  scaleExp[perm[i]] = scaleExp[i];
537  }
538  }
539 
540  left.reDim (num());
541  right.reDim(num());
542  object.reDim(num());
543  scaleExp.reSize(num());
544  }
545 
546  /// Removes \p n LPRowBase%s with row numbers given by \p nums.
547  void remove(const int nums[], int n)
548  {
549  DataArray<int> perm(num());
550  remove(nums, n, perm.get_ptr());
551  }
552 
553  /// Removes \p n LPRowBase%s with row numbers given by \p nums,
554  /// Stores permutation of row indices in \p perm.
555  void remove(const int nums[], int n, int* perm)
556  {
557  SVSetBase<R>::remove(nums, n, perm);
558 
559  int j = num();
560 
561  for( int i = 0; i < j; ++i )
562  {
563  if( perm[i] >= 0 && perm[i] != i )
564  {
565  left[perm[i]] = left[i];
566  right[perm[i]] = right[i];
567  object[perm[i]] = object[i];
568  scaleExp[perm[i]] = scaleExp[i];
569  }
570  }
571 
572  left.reDim (num());
573  right.reDim(num());
574  object.reDim(num());
575  scaleExp.reSize(num());
576  }
577 
578  /// Removes all LPRowBase%s.
579  void clear()
580  {
582  left.reDim(num());
583  right.reDim(num());
584  object.reDim(num());
585  scaleExp.clear();
586  }
587 
588  //@}
589 
590  // ------------------------------------------------------------------------------------------------------------------
591  /**@name Memory Management
592  *
593  * For a description of the memory management methods, see the documentation of SVSet, which has been used for
594  * implementating LPRowSetBase.
595  */
596  //@{
597 
598  /// Reallocates memory to be able to store \p newmax LPRowBase%s.
599  void reMax(int newmax = 0)
600  {
601  SVSetBase<R>::reMax(newmax);
602  left.reSize (max());
603  right.reSize(max());
604  object.reSize(max());
605  scaleExp.reSize(max());
606  }
607 
608  /// Returns number of used nonzero entries.
609  int memSize() const
610  {
611  return SVSetBase<R>::memSize();
612  }
613 
614  /// Returns length of nonzero memory.
615  int memMax() const
616  {
617  return SVSetBase<R>::memMax();
618  }
619 
620  /// Reallocates memory to be able to store \p newmax nonzeros.
621  void memRemax(int newmax)
622  {
623  SVSetBase<R>::memRemax(newmax);
624  }
625 
626  /// Garbage collection in nonzero memory.
627  void memPack()
628  {
630  }
631 
632  //@}
633 
634  // ------------------------------------------------------------------------------------------------------------------
635  /**@name Consistency check */
636 
637  /// Checks consistency.
638  bool isConsistent() const
639  {
640 #ifdef ENABLE_CONSISTENCY_CHECKS
641  const int ldim = left.dim();
642 
643  if( ldim != right.dim() )
644  return MSGinconsistent("LPRowSetBase");
645  if( ldim != object.dim() )
646  return MSGinconsistent("LPRowSetBase");
647  if( ldim != num() )
648  return MSGinconsistent("LPRowSetBase");
649 
650  return left.isConsistent() && right.isConsistent() && object.isConsistent() && SVSetBase<R>::isConsistent();
651 #else
652  return true;
653 #endif
654  }
655 
656  //@}
657 
658  // ------------------------------------------------------------------------------------------------------------------
659  /**@name Construction / Destruction */
660  //@{
661 
662  /// Default constructor.
663  /** The user can specify the initial maximum number of rows \p max and the initial maximum number of nonzero entries
664  * \p memmax. If these parameters are omitted, a default size is used. However, one can add an arbitrary number of
665  * rows to the LPRowSetBase, which may result in automated memory realllocation.
666  */
667  explicit
668  LPRowSetBase<R>(int pmax = -1, int pmemmax = -1)
669  : SVSetBase<R>(pmax, pmemmax), left(0), right(0), object(0), scaleExp(0)
670  {
671  assert(isConsistent());
672  }
673 
674  /// Assignment operator.
676  {
677  if( this != &rs )
678  {
680  left = rs.left;
681  right = rs.right;
682  object = rs.object;
683  scaleExp = rs.scaleExp;
684 
685  assert(isConsistent());
686  }
687 
688  return *this;
689  }
690 
691  /// Assignment operator.
692  template < class S >
694  {
695  if( this != (const LPRowSetBase<R>*)(&rs) )
696  {
698  left = rs.left;
699  right = rs.right;
700  object = rs.object;
701  scaleExp = rs.scaleExp;
702 
703  assert(isConsistent());
704  }
705 
706  return *this;
707  }
708 
709  /// Copy constructor.
711  : SVSetBase<R>(rs)
712  , left(rs.left)
713  , right(rs.right)
714  , object(rs.object)
715  , scaleExp(rs.scaleExp)
716  {
717  assert(isConsistent());
718  }
719 
720  /// Copy constructor.
721  template < class S >
723  : SVSetBase<R>(rs)
724  , left(rs.left)
725  , right(rs.right)
726  , object(rs.object)
727  , scaleExp(rs.scaleExp)
728  {
729  assert(isConsistent());
730  }
731 
732  /// Destructor.
733  virtual ~LPRowSetBase<R>()
734  {}
735 
736  //@}
737 };
738 } // namespace soplex
739 #endif // _LPROWSETBASE_H_
DataKey key(int i) const
Returns the DataKey of the i &#39;th LPRowBase in LPRowSetBase.
Definition: lprowsetbase.h:292
SVectorBase< R > & rowVector_w(const DataKey &k)
Returns a writable rowVector of the LPRowBase with DataKey k.
Definition: lprowsetbase.h:215
VectorBase< R > & obj_w()
Returns the vector of objective coefficients (writeable).
Definition: lprowsetbase.h:173
int max() const
Returns the maximum number of LPRowBases that fit.
Definition: lprowsetbase.h:89
int memMax() const
Returns length of nonzero memory.
Definition: lprowsetbase.h:615
int memSize() const
Returns number of used nonzero entries.
Definition: lprowsetbase.h:609
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
Definition: exceptions.h:109
const R & value(const DataKey &k) const
Returns the value of the LPRowBase with DataKey k.
Definition: lprowsetbase.h:286
void add(const S *lhsValue, const S *rowValues, const int *rowIndices, int rowSize, const S *rhsValue, const S *objValue=0)
Adds LPRowBase consisting of left hand side lhs, row vector rowVector, and right hand side rhs to LPR...
Definition: lprowsetbase.h:342
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:249
const SVectorBase< R > & rowVector(const DataKey &k) const
Returns the rowVector of the LPRowBase with DataKey k.
Definition: lprowsetbase.h:221
void add2(int i, int n, const int idx[], const R val[])
Adds n nonzero (idx, val)-pairs to i &#39;th rowVector.
Definition: lprowsetbase.h:454
LPRowBase< R >::Type type(int i) const
Returns the inequalitiy type of the i &#39;th LPRowBase.
Definition: lprowsetbase.h:227
bool isConsistent() const
Consistency check.
Definition: dvectorbase.h:302
SVSetBase< R > & operator=(const SVSetBase< R > &rhs)
Assignment operator.
Definition: svsetbase.h:970
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
void add(DataKey keys[], const LPRowSetBase< R > &set)
Adds all LPRowBases of set to LPRowSetBase.
Definition: lprowsetbase.h:425
Entry identifier class for items of a DataSet.
R & rhs_w(int i)
Returns the rhs of the i &#39;th LPRowBase (writeable).
Definition: lprowsetbase.h:149
void reMax(int newmax=0)
Resets maximum number of SVectorBases.
Definition: svsetbase.h:915
Dynamic dense vectors.Class DVectorBase is a derived class of VectorBase adding automatic memory mana...
Definition: dvectorbase.h:48
Dense vector.Class VectorBase provides dense linear algebra vectors. It does not provide memory manag...
Definition: dsvectorbase.h:28
T * get_ptr()
get a C pointer to the data.
Definition: dataarray.h:110
const VectorBase< R > & lhs() const
Returns the vector of lhs values.
Definition: lprowsetbase.h:95
void xtend(int n, int newmax)
Extends row n to fit newmax nonzeros.
Definition: lprowsetbase.h:436
void clear()
Removes all LPRowBases.
Definition: lprowsetbase.h:579
const R & rhs(const DataKey &k) const
Returns the rhs of the LPRowBase with DataKey k in LPRowSetBase.
Definition: lprowsetbase.h:155
const SVectorBase< R > & rowVector() const
Constraint row vector.
Definition: lprowbase.h:239
R & lhs_w(const DataKey &k)
Returns the lhs of the LPRowBase with DataKey k in LPRowSetBase.
Definition: lprowsetbase.h:125
const R & lhs(const DataKey &k) const
Returns the lhs of the LPRowBase with DataKey k in LPRowSetBase.
Definition: lprowsetbase.h:119
R rhs() const
Right-hand side value.
Definition: lprowbase.h:215
const R & value(int i) const
Returns the value of the i&#39;th LPRowBase.
Definition: lprowsetbase.h:271
int number(const DataKey &k) const
Gets vector number of DataKey.
Definition: svsetbase.h:770
void setType(int i, typename LPRowBase< R >::Type t)
Changes the inequality type of row i to type.
Definition: lprowsetbase.h:246
void clear()
remove all elements.
Definition: dataarray.h:205
int memSize() const
Used nonzero memory.
Definition: svsetbase.h:806
SVectorBase< R > * create(int idxmax=0)
Creates new SVectorBase in set.
Definition: svsetbase.h:428
VectorBase< R > & lhs_w()
Returns the vector of lhs values.
Definition: lprowsetbase.h:101
void xtend(const DataKey &pkey, int pnewmax)
Extends row with DataKey key to fit newmax nonzeros.
Definition: lprowsetbase.h:442
void add(const LPRowBase< R > &row)
Definition: lprowsetbase.h:321
R & lhs_w(int i)
Returns the lhs of the i &#39;th LPRowBase.
Definition: lprowsetbase.h:113
DVectorBase< R > left
vector of left hand sides (lower bounds) of LPRowBases.
Definition: lprowsetbase.h:54
Entry identifier class for items of a DataSet.Every item in a DataSet is assigned a DataKey by which ...
Definition: datakey.h:46
DataKey key(int n) const
Gets DataKey of vector number.
Definition: svsetbase.h:758
void memRemax(int newmax)
Reallocates memory to be able to store newmax nonzeros.
Definition: lprowsetbase.h:621
void memPack()
Garbage collection in nonzero memory.
Definition: lprowsetbase.h:627
DVectorBase< R > object
vector of objective coefficients.
Definition: lprowsetbase.h:56
void add(DataKey &pkey, const LPRowBase< R > &prow)
Adds row to LPRowSetBase.
Definition: lprowsetbase.h:328
void reSize(int newsize)
Resets DVectorBase&#39;s memory size to newsize.
Definition: dvectorbase.h:266
const R & obj(const DataKey &k) const
Returns the objective coefficient of the LPRowBase with DataKey k in LPRowSetBase.
Definition: lprowsetbase.h:191
const R & lhs(int i) const
Returns the lhs of the i &#39;th LPRowBase.
Definition: lprowsetbase.h:107
void add(const SVectorBase< R > &svec)
Adds svec to the set.
Definition: svsetbase.h:305
const VectorBase< R > & rhs() const
Returns the vector of rhs values.
Definition: lprowsetbase.h:131
R lhs() const
Left-hand side value.
Definition: lprowbase.h:203
void add2(int i, int n, const int idx[], const S val[])
Adds n nonzero (idx, val)-pairs to i &#39;th rowVector.
Definition: lprowsetbase.h:461
LPRowSetBase< R > & operator=(const LPRowSetBase< R > &rs)
Assignment operator.
Definition: lprowsetbase.h:675
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
Definition: spxdefines.h:114
SVectorBase< R > & rowVector_w(int i)
Returns a writable rowVector of the i &#39;th LPRowBase.
Definition: lprowsetbase.h:203
int memMax() const
Length of nonzero memory.
Definition: svsetbase.h:812
SVectorBase< R > & operator[](int n)
Gets SVectorBase by number, writeable.
Definition: svsetbase.h:716
bool has(const DataKey &k) const
True iff SVSetBase contains a SVectorBase for DataKey k.
Definition: svsetbase.h:782
const R & obj(int i) const
Returns the objective coefficient of the i &#39;th LPRowBase.
Definition: lprowsetbase.h:179
bool isConsistent() const
Consistency check.
Definition: svsetbase.h:921
void add2(const DataKey &k, int n, const int idx[], const R val[])
Adds n nonzero (idx, val)-pairs to rowVector with DataKey k.
Definition: lprowsetbase.h:448
void add(DataKey &newkey, const R &newlhs, const SVectorBase< R > &newrowVector, const R &newrhs, const R &newobj=0, const int &newscaleExp=0)
Adds LPRowBase consisting of left hand side lhs, row vector rowVector, and right hand side rhs to LPR...
Definition: lprowsetbase.h:382
SVectorBase< R > & create(DataKey &newkey, int nonzeros=0, const R &newlhs=0, const R &newrhs=1, const R &newobj=0, const int &newscaleExp=0)
Creates new LPRowBase with specified parameters and returns a reference to its row vector...
Definition: lprowsetbase.h:474
DataArray< int > scaleExp
row scaling factors (stored as bitshift)
Definition: lprowsetbase.h:62
LPRowSetBase< R > & operator=(const LPRowSetBase< S > &rs)
Assignment operator.
Definition: lprowsetbase.h:693
(In)equality for LPs.Class LPRowBase provides constraints for linear programs in the form where a is...
Definition: lprowbase.h:45
void memRemax(int newmax)
Reset length of nonzero memory.
Definition: svsetbase.h:818
void memPack()
Garbage collection in nonzero memory.
Definition: svsetbase.h:867
Debugging, floating point type and parameter definitions.
R & obj_w(int i)
Returns the objective coefficient of the i &#39;th LPRowBase (writeable).
Definition: lprowsetbase.h:185
Collection of dense, sparse, and semi-sparse vectors.
int dim() const
Dimension of vector.
Definition: vectorbase.h:215
LPRowBase< R >::Type type(const DataKey &k) const
Returns the inequality type of the LPRowBase with DataKey k.
Definition: lprowsetbase.h:240
Everything should be within this namespace.
void reMax(int newmax=0)
Reallocates memory to be able to store newmax LPRowBases.
Definition: lprowsetbase.h:599
void add(const LPRowSetBase< R > &newset)
Definition: lprowsetbase.h:401
R & obj_w(const DataKey &k)
Returns the objective coefficient of the LPRowBase with DataKey k in LPRowSetBase (writeable)...
Definition: lprowsetbase.h:197
const SVectorBase< R > & rowVector(int i) const
Returns the rowVector of the i &#39;th LPRowBase.
Definition: lprowsetbase.h:209
Type
(In)Equality type of an LP row.
Definition: lprowbase.h:72
void add(DataKey &newkey, const S *lhsValue, const S *rowValues, const int *rowIndices, int rowSize, const S *rhsValue, const S *objValue=0)
Adds LPRowBase consisting of left hand side lhs, row vector rowVector, and right hand side rhs to LPR...
Definition: lprowsetbase.h:356
R obj() const
Objective coefficient value.
Definition: lprowbase.h:227
(In)equality for LPs.
bool has(const DataKey &k) const
does DataKey k belong to LPRowSetBase ?
Definition: lprowsetbase.h:304
Set of LP rows.Class LPRowSetBase implements a set of LPRowBase%s. Unless for memory limitations...
Definition: lprowsetbase.h:44
void add2(SVectorBase< R > &svec, int idx, R val)
Adds nonzero (idx, val) to svec of this SVSetBase.
Definition: svsetbase.h:553
bool isConsistent() const
Checks consistency.
Definition: lprowsetbase.h:638
void add(const R &plhs, const SVectorBase< R > &prowVector, const R &prhs, const R &pobj=0, const int &pscaleExp=0)
Adds LPRowBase consisting of left hand side lhs, row vector rowVector, and right hand side rhs to LPR...
Definition: lprowsetbase.h:334
void xtend(SVectorBase< R > &svec, int newmax)
Extends svec to fit newmax nonzeros.
Definition: svsetbase.h:475
void remove(const DataKey &removekey)
Removes the vector with key removekey from the set.
Definition: svsetbase.h:593
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
Definition: dvectorbase.h:31
const R & rhs(int i) const
Returns the rhs of the i &#39;th LPRowBase.
Definition: lprowsetbase.h:143
DVectorBase< R > right
vector of right hand sides (upper bounds) of LPRowBases.
Definition: lprowsetbase.h:55
#define MSGinconsistent(name)
Definition: spxdefines.h:126
int number(const DataKey &k) const
Returns the number of the LPRowBase with DataKey k in LPRowSetBase.
Definition: lprowsetbase.h:298
VectorBase< R > & rhs_w()
Returns the vector of rhs values (writeable).
Definition: lprowsetbase.h:137
const SVSetBase< R > * rowSet() const
Returns the complete SVSet.
Definition: lprowsetbase.h:69
R & rhs_w(const DataKey &k)
Returns the rhs of the LPRowBase with DataKey k in LPRowSetBase (writeable).
Definition: lprowsetbase.h:161
int max() const
Current maximum number of SVectorBases.
Definition: svsetbase.h:752
const VectorBase< R > & obj() const
Returns the vector of objective coefficients.
Definition: lprowsetbase.h:167
void reSize(int newsize)
reset size to newsize.
Definition: dataarray.h:223
SVectorBase< R > & create(int pnonzeros=0, const R &plhs=0, const R &prhs=1, const R &pobj=0, const int &pscaleExp=0)
Creates new LPRowBase with specified parameters and returns a reference to its row vector...
Definition: lprowsetbase.h:467
int num() const
Current number of SVectorBases.
Definition: svsetbase.h:746
Sparse vector set.Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBases in a...
Definition: ssvectorbase.h:33
void clear()
Removes all elements.
Definition: classarray.h:202
int num() const
Returns the number of LPRowBases in LPRowSetBase.
Definition: lprowsetbase.h:83