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-2019 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 "soplex/spxdefines.h"
26 #include "soplex/basevectors.h"
27 #include "soplex/datakey.h"
28 #include "soplex/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 
232  if(lhs(i) <= double(-infinity))
234 
235  if(lhs(i) == rhs(i))
236  return LPRowBase<R>::EQUAL;
237 
238  return LPRowBase<R>::RANGE;
239  }
240 
241  /// Returns the inequality type of the LPRowBase with DataKey \p k.
242  typename LPRowBase<R>::Type type(const DataKey& k) const
243  {
244  return type(number(k));
245  }
246 
247  /// Changes the inequality type of row \p i to \p type.
248  void setType(int i, typename LPRowBase<R>::Type t)
249  {
250  switch(t)
251  {
253  lhs_w(i) = -infinity;
254  break;
255 
256  case LPRowBase<R>::EQUAL:
257  if(lhs_w(i) > -infinity)
258  rhs_w(i) = lhs(i);
259  else
260  lhs_w(i) = rhs(i);
261 
262  break;
263 
265  rhs_w(i) = infinity;
266  break;
267 
268  case LPRowBase<R>::RANGE:
269  MSG_ERROR(std::cerr << "EROWST01 RANGE not supported in LPRowSet::setType()" << std::endl);
270  throw SPxInternalCodeException("XROWST01 This should never happen.");
271 
272  default:
273  throw SPxInternalCodeException("XROWST02 This should never happen.");
274  }
275  }
276 
277  /// Returns the value of the \p i'th LPRowBase.
278  const R& value(int i) const
279  {
280  if(rhs(i) < infinity)
281  return rhs(i);
282  else
283  {
284  assert(lhs(i) > -infinity);
285  return lhs(i);
286  }
287  }
288 
289  /// Returns the value of the LPRowBase with DataKey \p k.
290  /** The \em value of a row depends on its type: if the inequality is of type "greater or equal", the value is the lhs
291  * of the row. Otherwise, the value is the rhs.
292  */
293  const R& value(const DataKey& k) const
294  {
295  return value(number(k));
296  }
297 
298  /// Returns the DataKey of the \p i 'th LPRowBase in LPRowSetBase.
299  DataKey key(int i) const
300  {
301  return SVSetBase<R>::key(i);
302  }
303 
304  /// Returns the number of the LPRowBase with DataKey \p k in LPRowSetBase.
305  int number(const DataKey& k) const
306  {
307  return SVSetBase<R>::number(k);
308  }
309 
310  /// does DataKey \p k belong to LPRowSetBase ?
311  bool has(const DataKey& k) const
312  {
313  return SVSetBase<R>::has(k);
314  }
315 
316  //@}
317 
318  // ------------------------------------------------------------------------------------------------------------------
319  /**@name Extension
320  *
321  * Extension methods come with two signatures, one of them providing a parameter to return the assigned
322  * DataKey(s). See DataSet for a more detailed description. All extension methods will automatically rearrange or
323  * allocate more memory if required.
324  */
325  //@{
326 
327  ///
328  void add(const LPRowBase<R>& row)
329  {
330  DataKey k;
331  add(k, row);
332  }
333 
334  /// Adds \p row to LPRowSetBase.
335  void add(DataKey& pkey, const LPRowBase<R>& prow)
336  {
337  add(pkey, prow.lhs(), prow.rowVector(), prow.rhs(), prow.obj());
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  void add(const R& plhs, const SVectorBase<R>& prowVector, const R& prhs, const R& pobj = 0,
342  const int& pscaleExp = 0)
343  {
344  DataKey k;
345  add(k, plhs, prowVector, prhs, pobj, pscaleExp);
346  }
347 
348  /// Adds LPRowBase consisting of left hand side \p lhs, row vector \p rowVector, and right hand side \p rhs to LPRowSetBase.
349  template < class S >
350  void add(const S* lhsValue, const S* rowValues, const int* rowIndices, int rowSize,
351  const S* rhsValue, const S* objValue = 0)
352  {
353  assert(lhsValue != 0);
354  assert(rowSize <= 0 || rowValues != 0);
355  assert(rowSize <= 0 || rowIndices != 0);
356  assert(rhsValue != 0);
357 
358  DataKey k;
359  add(k, lhsValue, rowValues, rowIndices, rowSize, rhsValue, objValue);
360  }
361 
362  /// Adds LPRowBase consisting of left hand side \p lhs, row vector \p rowVector, and right hand side \p rhs to
363  /// LPRowSetBase, with DataKey \p key.
364  template < class S >
365  void add(DataKey& newkey, const S* lhsValue, const S* rowValues, const int* rowIndices, int rowSize,
366  const S* rhsValue, const S* objValue = 0)
367  {
368  assert(lhsValue != 0);
369  assert(rowSize <= 0 || rowValues != 0);
370  assert(rowSize <= 0 || rowIndices != 0);
371  assert(rhsValue != 0);
372 
373  SVSetBase<R>::add(newkey, rowValues, rowIndices, rowSize);
374 
375  if(num() > left.dim())
376  {
377  left.reDim(num());
378  right.reDim(num());
379  object.reDim(num());
380  }
381 
382  left[num() - 1] = *lhsValue;
383  right[num() - 1] = *rhsValue;
384 
385  if(objValue != 0)
386  object[num() - 1] = *objValue;
387  else
388  object[num() - 1] = 0;
389  }
390 
391  /// Adds LPRowBase consisting of left hand side \p lhs, row vector \p rowVector, and right hand side \p rhs to
392  /// LPRowSetBase, with DataKey \p key.
393  void add(DataKey& newkey, const R& newlhs, const SVectorBase<R>& newrowVector, const R& newrhs,
394  const R& newobj = 0, const int& newscaleExp = 0)
395  {
396  SVSetBase<R>::add(newkey, newrowVector);
397 
398  if(num() > left.dim())
399  {
400  left.reDim(num());
401  right.reDim(num());
402  object.reDim(num());
403  scaleExp.reSize(num());
404  }
405 
406  left[num() - 1] = newlhs;
407  right[num() - 1] = newrhs;
408  object[num() - 1] = newobj;
409  scaleExp[num() - 1] = newscaleExp;
410  }
411 
412  ///
413  void add(const LPRowSetBase<R>& newset)
414  {
415  int i = num();
416 
417  SVSetBase<R>::add(newset);
418 
419  if(num() > left.dim())
420  {
421  left.reDim(num());
422  right.reDim(num());
423  object.reDim(num());
424  scaleExp.reSize(num());
425  }
426 
427  for(int j = 0; i < num(); ++i, ++j)
428  {
429  left[i] = newset.lhs(j);
430  right[i] = newset.rhs(j);
431  object[i] = newset.obj(j);
432  scaleExp[i] = newset.scaleExp[j];
433  }
434  }
435 
436  /// Adds all LPRowBase%s of \p set to LPRowSetBase.
437  void add(DataKey keys[], const LPRowSetBase<R>& set)
438  {
439  int i = num();
440 
441  add(set);
442 
443  for(int j = 0; i < num(); ++i, ++j)
444  keys[j] = key(i);
445  }
446 
447  /// Extends row \p n to fit \p newmax nonzeros.
448  void xtend(int n, int newmax)
449  {
450  SVSetBase<R>::xtend(rowVector_w(n), newmax);
451  }
452 
453  /// Extends row with DataKey \p key to fit \p newmax nonzeros.
454  void xtend(const DataKey& pkey, int pnewmax)
455  {
456  SVSetBase<R>::xtend(rowVector_w(pkey), pnewmax);
457  }
458 
459  /// Adds \p n nonzero (\p idx, \p val)-pairs to rowVector with DataKey \p k.
460  void add2(const DataKey& k, int n, const int idx[], const R val[])
461  {
462  SVSetBase<R>::add2(rowVector_w(k), n, idx, val);
463  }
464 
465  /// Adds \p n nonzero (\p idx, \p val)-pairs to \p i 'th rowVector.
466  void add2(int i, int n, const int idx[], const R val[])
467  {
468  SVSetBase<R>::add2(rowVector_w(i), n, idx, val);
469  }
470 
471  /// Adds \p n nonzero (\p idx, \p val)-pairs to \p i 'th rowVector.
472  template < class S >
473  void add2(int i, int n, const int idx[], const S val[])
474  {
475  SVSetBase<R>::add2(rowVector_w(i), n, idx, val);
476  }
477 
478  /// Creates new LPRowBase with specified parameters and returns a reference to its row vector.
479  SVectorBase<R>& create(int pnonzeros = 0, const R& plhs = 0, const R& prhs = 1, const R& pobj = 0,
480  const int& pscaleExp = 0)
481  {
482  DataKey k;
483  return create(k, pnonzeros, plhs, prhs, pobj, pscaleExp);
484  }
485 
486  /// Creates new LPRowBase with specified parameters and returns a reference to its row vector.
487  SVectorBase<R>& create(DataKey& newkey, int nonzeros = 0, const R& newlhs = 0, const R& newrhs = 1,
488  const R& newobj = 0, const int& newscaleExp = 0)
489  {
490  if(num() + 1 > left.dim())
491  {
492  left.reDim(num() + 1);
493  right.reDim(num() + 1);
494  object.reDim(num() + 1);
495  scaleExp.reSize(num() + 1);
496  }
497 
498  left[num()] = newlhs;
499  right[num()] = newrhs;
500  object[num()] = newobj;
501  scaleExp[num()] = newscaleExp;
502 
503  return *SVSetBase<R>::create(newkey, nonzeros);
504  }
505 
506  //@}
507 
508  // ------------------------------------------------------------------------------------------------------------------
509  /**@name Shrinking
510  *
511  * See DataSet for a description of the renumbering of the remaining LPRowBase%s in a LPRowSetBase after the call of
512  * a removal method.
513  */
514  //@{
515 
516  /// Removes \p i 'th LPRowBase.
517  void remove(int i)
518  {
520  left[i] = left[num()];
521  right[i] = right[num()];
522  object[i] = object[num()];
523  scaleExp[i] = scaleExp[num()];
524  left.reDim(num());
525  right.reDim(num());
526  object.reDim(num());
527  scaleExp.reSize(num());
528  }
529 
530  /// Removes LPRowBase with DataKey \p k.
531  void remove(const DataKey& k)
532  {
533  remove(number(k));
534  }
535 
536  /// Removes multiple LPRowBase%s.
537  void remove(int perm[])
538  {
539  int j = num();
540 
541  SVSetBase<R>::remove(perm);
542 
543  for(int i = 0; i < j; ++i)
544  {
545  if(perm[i] >= 0 && perm[i] != i)
546  {
547  left[perm[i]] = left[i];
548  right[perm[i]] = right[i];
549  object[perm[i]] = object[i];
550  scaleExp[perm[i]] = scaleExp[i];
551  }
552  }
553 
554  left.reDim(num());
555  right.reDim(num());
556  object.reDim(num());
557  scaleExp.reSize(num());
558  }
559 
560  /// Removes \p n LPRowBase%s with row numbers given by \p nums.
561  void remove(const int nums[], int n)
562  {
563  DataArray<int> perm(num());
564  remove(nums, n, perm.get_ptr());
565  }
566 
567  /// Removes \p n LPRowBase%s with row numbers given by \p nums,
568  /// Stores permutation of row indices in \p perm.
569  void remove(const int nums[], int n, int* perm)
570  {
571  SVSetBase<R>::remove(nums, n, perm);
572 
573  int j = num();
574 
575  for(int i = 0; i < j; ++i)
576  {
577  if(perm[i] >= 0 && perm[i] != i)
578  {
579  left[perm[i]] = left[i];
580  right[perm[i]] = right[i];
581  object[perm[i]] = object[i];
582  scaleExp[perm[i]] = scaleExp[i];
583  }
584  }
585 
586  left.reDim(num());
587  right.reDim(num());
588  object.reDim(num());
589  scaleExp.reSize(num());
590  }
591 
592  /// Removes all LPRowBase%s.
593  void clear()
594  {
596  left.reDim(num());
597  right.reDim(num());
598  object.reDim(num());
599  scaleExp.clear();
600  }
601 
602  //@}
603 
604  // ------------------------------------------------------------------------------------------------------------------
605  /**@name Memory Management
606  *
607  * For a description of the memory management methods, see the documentation of SVSet, which has been used for
608  * implementating LPRowSetBase.
609  */
610  //@{
611 
612  /// Reallocates memory to be able to store \p newmax LPRowBase%s.
613  void reMax(int newmax = 0)
614  {
615  SVSetBase<R>::reMax(newmax);
616  left.reSize(max());
617  right.reSize(max());
618  object.reSize(max());
619  scaleExp.reSize(max());
620  }
621 
622  /// Returns number of used nonzero entries.
623  int memSize() const
624  {
625  return SVSetBase<R>::memSize();
626  }
627 
628  /// Returns length of nonzero memory.
629  int memMax() const
630  {
631  return SVSetBase<R>::memMax();
632  }
633 
634  /// Reallocates memory to be able to store \p newmax nonzeros.
635  void memRemax(int newmax)
636  {
637  SVSetBase<R>::memRemax(newmax);
638  }
639 
640  /// Garbage collection in nonzero memory.
641  void memPack()
642  {
644  }
645 
646  //@}
647 
648  // ------------------------------------------------------------------------------------------------------------------
649  /**@name Consistency check */
650 
651  /// Checks consistency.
652  bool isConsistent() const
653  {
654 #ifdef ENABLE_CONSISTENCY_CHECKS
655  const int ldim = left.dim();
656 
657  if(ldim != right.dim())
658  return MSGinconsistent("LPRowSetBase");
659 
660  if(ldim != object.dim())
661  return MSGinconsistent("LPRowSetBase");
662 
663  if(ldim != num())
664  return MSGinconsistent("LPRowSetBase");
665 
666  return left.isConsistent() && right.isConsistent() && object.isConsistent()
668 #else
669  return true;
670 #endif
671  }
672 
673  //@}
674 
675  // ------------------------------------------------------------------------------------------------------------------
676  /**@name Construction / Destruction */
677  //@{
678 
679  /// Default constructor.
680  /** The user can specify the initial maximum number of rows \p max and the initial maximum number of nonzero entries
681  * \p memmax. If these parameters are omitted, a default size is used. However, one can add an arbitrary number of
682  * rows to the LPRowSetBase, which may result in automated memory realllocation.
683  */
684  explicit
685  LPRowSetBase<R>(int pmax = -1, int pmemmax = -1)
686  : SVSetBase<R>(pmax, pmemmax), left(0), right(0), object(0), scaleExp(0)
687  {
688  assert(isConsistent());
689  }
690 
691  /// Assignment operator.
693  {
694  if(this != &rs)
695  {
697  left = rs.left;
698  right = rs.right;
699  object = rs.object;
700  scaleExp = rs.scaleExp;
701 
702  assert(isConsistent());
703  }
704 
705  return *this;
706  }
707 
708  /// Assignment operator.
709  template < class S >
711  {
712  if(this != (const LPRowSetBase<R>*)(&rs))
713  {
715  left = rs.left;
716  right = rs.right;
717  object = rs.object;
718  scaleExp = rs.scaleExp;
719 
720  assert(isConsistent());
721  }
722 
723  return *this;
724  }
725 
726  /// Copy constructor.
728  : SVSetBase<R>(rs)
729  , left(rs.left)
730  , right(rs.right)
731  , object(rs.object)
732  , scaleExp(rs.scaleExp)
733  {
734  assert(isConsistent());
735  }
736 
737  /// Copy constructor.
738  template < class S >
740  : SVSetBase<R>(rs)
741  , left(rs.left)
742  , right(rs.right)
743  , object(rs.object)
744  , scaleExp(rs.scaleExp)
745  {
746  assert(isConsistent());
747  }
748 
749  /// Destructor.
750  virtual ~LPRowSetBase<R>()
751  {}
752 
753  //@}
754 };
755 } // namespace soplex
756 #endif // _LPROWSETBASE_H_
DataKey key(int i) const
Returns the DataKey of the i &#39;th LPRowBase in LPRowSetBase.
Definition: lprowsetbase.h:299
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:629
int memSize() const
Returns number of used nonzero entries.
Definition: lprowsetbase.h:623
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:293
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:350
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:253
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:466
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:307
SVSetBase< R > & operator=(const SVSetBase< R > &rhs)
Assignment operator.
Definition: svsetbase.h:988
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:437
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:933
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:448
void clear()
Removes all LPRowBases.
Definition: lprowsetbase.h:593
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:247
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:223
const R & value(int i) const
Returns the value of the i&#39;th LPRowBase.
Definition: lprowsetbase.h:278
int number(const DataKey &k) const
Gets vector number of DataKey.
Definition: svsetbase.h:783
void setType(int i, typename LPRowBase< R >::Type t)
Changes the inequality type of row i to type.
Definition: lprowsetbase.h:248
void clear()
remove all elements.
Definition: dataarray.h:208
int memSize() const
Used nonzero memory.
Definition: svsetbase.h:819
SVectorBase< R > * create(int idxmax=0)
Creates new SVectorBase in set.
Definition: svsetbase.h:437
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:454
void add(const LPRowBase< R > &row)
Definition: lprowsetbase.h:328
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:771
void memRemax(int newmax)
Reallocates memory to be able to store newmax nonzeros.
Definition: lprowsetbase.h:635
void memPack()
Garbage collection in nonzero memory.
Definition: lprowsetbase.h:641
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:335
void reSize(int newsize)
Resets DVectorBase&#39;s memory size to newsize.
Definition: dvectorbase.h:270
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:313
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:211
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:473
LPRowSetBase< R > & operator=(const LPRowSetBase< R > &rs)
Assignment operator.
Definition: lprowsetbase.h:692
#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:825
SVectorBase< R > & operator[](int n)
Gets SVectorBase by number, writeable.
Definition: svsetbase.h:729
bool has(const DataKey &k) const
True iff SVSetBase contains a SVectorBase for DataKey k.
Definition: svsetbase.h:795
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:939
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:460
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:393
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:487
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:710
(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:831
void memPack()
Garbage collection in nonzero memory.
Definition: svsetbase.h:883
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:217
LPRowBase< R >::Type type(const DataKey &k) const
Returns the inequality type of the LPRowBase with DataKey k.
Definition: lprowsetbase.h:242
Everything should be within this namespace.
void reMax(int newmax=0)
Reallocates memory to be able to store newmax LPRowBases.
Definition: lprowsetbase.h:613
void add(const LPRowSetBase< R > &newset)
Definition: lprowsetbase.h:413
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:365
R obj() const
Objective coefficient value.
Definition: lprowbase.h:235
(In)equality for LPs.
bool has(const DataKey &k) const
does DataKey k belong to LPRowSetBase ?
Definition: lprowsetbase.h:311
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:566
bool isConsistent() const
Checks consistency.
Definition: lprowsetbase.h:652
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:341
void xtend(SVectorBase< R > &svec, int newmax)
Extends svec to fit newmax nonzeros.
Definition: svsetbase.h:484
void remove(const DataKey &removekey)
Removes the vector with key removekey from the set.
Definition: svsetbase.h:606
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:305
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:765
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:226
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:479
int num() const
Current number of SVectorBases.
Definition: svsetbase.h:759
Sparse vector set.Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBases in a...
Definition: ssvectorbase.h:34
void clear()
Removes all elements.
Definition: classarray.h:202
int num() const
Returns the number of LPRowBases in LPRowSetBase.
Definition: lprowsetbase.h:83