Scippy

SoPlex

Sequential object-oriented simPlex

spxmainsm.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-2020 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 spxmainsm.h
17  * @brief General methods in LP preprocessing.
18  */
19 #ifndef _SPXMAINSM_H_
20 #define _SPXMAINSM_H_
21 
22 #include <assert.h>
23 #include <memory>
24 
25 #include "soplex/spxdefines.h"
26 #include "soplex/spxsimplifier.h"
27 #include "soplex/array.h"
28 #include "soplex/exceptions.h"
29 
30 namespace soplex
31 {
32 //---------------------------------------------------------------------
33 // class SPxMainSM
34 //---------------------------------------------------------------------
35 
36 /**@brief LP simplifier for removing uneccessary row/columns.
37  @ingroup Algo
38 
39  This #SPxSimplifier is mainly based on the paper "Presolving in
40  linear programming" by E. Andersen and K. Andersen (Mathematical
41  Programming, 1995). It implements all proposed methods and some
42  other preprocessing techniques for removing redundant rows and
43  columns and bounds. Also infeasibility and unboundedness may be
44  detected.
45 
46  Removed are:
47  - empty rows / columns
48  - unconstraint rows
49  - row singletons
50  - forcing rows
51  - zero objective column singletons
52  - (implied) free column singletons
53  - doubleton equations combined with a column singleton
54  - (implicitly) fixed columns
55  - redundant lhs / rhs
56  - redundant variable bounds
57  - variables that are free in one direction
58  - (weakly) dominated columns
59  - duplicate rows / columns
60 */
61 template <class R>
62 class SPxMainSM : public SPxSimplifier<R>
63 {
64 private:
65  //---------------------------------------------------------------------
66  // class PostsolveStep
67  //---------------------------------------------------------------------
68 
69  /**@brief Base class for postsolving operations.
70  @ingroup Algo
71 
72  Class #PostStep is an abstract base class providing the
73  interface for operations in the postsolving process.
74  */
75  class PostStep
76  {
77  private:
78  /// name of the simplifier
79  const char* m_name;
80  /// number of cols
81  int nCols;
82  /// number of rows
83  int nRows;
84 
85  public:
86  /// constructor.
87  PostStep(const char* p_name, int nR = 0, int nC = 0)
88  : m_name(p_name)
89  , nCols(nC)
90  , nRows(nR)
91  {}
92  /// copy constructor.
93  PostStep(const PostStep& old)
94  : m_name(old.m_name)
95  , nCols(old.nCols)
96  , nRows(old.nRows)
97  {}
98  /// assignment operator
99  PostStep& operator=(const PostStep& /*rhs*/)
100  {
101  return *this;
102  }
103  /// destructor.
104  virtual ~PostStep()
105  {
106  m_name = 0;
107  }
108  /// get name of simplifying step.
109  virtual const char* getName() const
110  {
111  return m_name;
112  }
113  /// clone function for polymorphism
114  virtual PostStep* clone() const = 0;
115  /// executes the postsolving.
116  virtual void execute(
117  VectorBase<R>& x, //*< Primal solution VectorBase<R> */
118  VectorBase<R>& y, //*< Dual solution VectorBase<R> */
119  VectorBase<R>& s, //*< VectorBase<R> of slacks */
120  VectorBase<R>& r, //*< Reduced cost VectorBase<R> */
121  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis, //*< Basis status of column basis */
122  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, //*< Basis status of row basis */
123  bool isOptimal
124  ) const = 0;
125 
126  virtual bool checkBasisDim(DataArray<typename SPxSolverBase<R>::VarStatus> rows,
127  DataArray<typename SPxSolverBase<R>::VarStatus> cols) const;
128 
129  static R eps()
130  {
131  return 1e-6;
132  }
133  };
134 
135  /**@brief Postsolves row objectives.
136  @ingroup Algo
137  */
138  class RowObjPS : public PostStep
139  {
140  private:
141  int m_i; ///< row index
142  int m_j; ///< slack column index
143 
144  public:
145  ///
146  RowObjPS(const SPxLPBase<R>& lp, int _i, int _j)
147  : PostStep("RowObj", lp.nRows(), lp.nCols())
148  , m_i(_i)
149  , m_j(_j)
150  {}
151  /// copy constructor
152  RowObjPS(const RowObjPS& old)
153  : PostStep(old)
154  , m_i(old.m_i)
155  , m_j(old.m_j)
156  {}
157  /// assignment operator
159  {
160  if(this != &rhs)
161  {
162  m_i = rhs.m_i;
163  m_j = rhs.m_j;
164  }
165 
166  return *this;
167  }
168  ///
169  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
170  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
171  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
172  /// clone function for polymorphism
173  inline virtual PostStep* clone() const
174  {
175  return new RowObjPS(*this);
176  }
177  };
178 
179  /**@brief Postsolves unconstraint constraints.
180  @ingroup Algo
181  */
182  class FreeConstraintPS : public PostStep
183  {
184  private:
185  int m_i;
186  int m_old_i;
189 
190  public:
191  ///
192  FreeConstraintPS(const SPxLPBase<R>& lp, int _i)
193  : PostStep("FreeConstraint", lp.nRows(), lp.nCols())
194  , m_i(_i)
195  , m_old_i(lp.nRows() - 1)
196  , m_row(lp.rowVector(_i))
197  , m_row_obj(lp.rowObj(_i))
198  {}
199  /// copy constructor
201  : PostStep(old)
202  , m_i(old.m_i)
203  , m_old_i(old.m_old_i)
204  , m_row(old.m_row)
205  , m_row_obj(old.m_row_obj)
206  {}
207  /// assignment operator
209  {
210  if(this != &rhs)
211  {
212  m_i = rhs.m_i;
213  m_old_i = rhs.m_old_i;
214  m_row = rhs.m_row;
215  m_row_obj = rhs.m_row_obj;
216  }
217 
218  return *this;
219  }
220  ///
221  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
222  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
223  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
224  /// clone function for polymorphism
225  inline virtual PostStep* clone() const
226  {
227  return new FreeConstraintPS(*this);
228  }
229  };
230 
231  /**@brief Postsolves empty constraints.
232  @ingroup Algo
233  */
235  {
236  private:
237  int m_i;
238  int m_old_i;
240 
241  public:
242  ///
243  EmptyConstraintPS(const SPxLPBase<R>& lp, int _i)
244  : PostStep("EmptyConstraint", lp.nRows(), lp.nCols())
245  , m_i(_i)
246  , m_old_i(lp.nRows() - 1)
247  , m_row_obj(lp.rowObj(_i))
248  {}
249  /// copy constructor
251  : PostStep(old)
252  , m_i(old.m_i)
253  , m_old_i(old.m_old_i)
254  , m_row_obj(old.m_row_obj)
255  {}
256  /// assignment operator
258  {
259  if(this != &rhs)
260  {
261  m_i = rhs.m_i;
262  m_old_i = rhs.m_old_i;
263  m_row_obj = rhs.m_row_obj;
264  }
265 
266  return *this;
267  }
268  ///
269  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
270  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
271  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
272  /// clone function for polymorphism
273  inline virtual PostStep* clone() const
274  {
275  return new EmptyConstraintPS(*this);
276  }
277  };
278 
279  /**@brief Postsolves row singletons.
280  @ingroup Algo
281  */
282  class RowSingletonPS : public PostStep
283  {
284  private:
285  const int m_i;
286  const int m_old_i;
287  const int m_j;
288  const R m_lhs;
289  const R m_rhs;
290  const bool m_strictLo;
291  const bool m_strictUp;
292  const bool m_maxSense;
293  const R m_obj;
295  const R m_newLo;
296  const R m_newUp;
297  const R m_oldLo;
298  const R m_oldUp;
299  const R m_row_obj;
300 
301  public:
302  ///
303  RowSingletonPS(const SPxLPBase<R>& lp, int _i, int _j, bool strictLo, bool strictUp,
304  R newLo, R newUp, R oldLo, R oldUp)
305  : PostStep("RowSingleton", lp.nRows(), lp.nCols())
306  , m_i(_i)
307  , m_old_i(lp.nRows() - 1)
308  , m_j(_j)
309  , m_lhs(lp.lhs(_i))
310  , m_rhs(lp.rhs(_i))
311  , m_strictLo(strictLo)
312  , m_strictUp(strictUp)
313  , m_maxSense(lp.spxSense() == SPxLPBase<R>::MAXIMIZE)
314  , m_obj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
315  , m_col(lp.colVector(_j))
316  , m_newLo(newLo)
317  , m_newUp(newUp)
318  , m_oldLo(oldLo)
319  , m_oldUp(oldUp)
320  , m_row_obj(lp.rowObj(_i))
321  {}
322  /// copy constructor
324  : PostStep(old)
325  , m_i(old.m_i)
326  , m_old_i(old.m_old_i)
327  , m_j(old.m_j)
328  , m_lhs(old.m_lhs)
329  , m_rhs(old.m_rhs)
330  , m_strictLo(old.m_strictLo)
331  , m_strictUp(old.m_strictUp)
332  , m_maxSense(old.m_maxSense)
333  , m_obj(old.m_obj)
334  , m_col(old.m_col)
335  , m_newLo(old.m_newLo)
336  , m_newUp(old.m_newUp)
337  , m_oldLo(old.m_oldLo)
338  , m_oldUp(old.m_oldUp)
339  , m_row_obj(old.m_row_obj)
340  {}
341  /// assignment operator
343  {
344  if(this != &rhs)
345  {
346  PostStep::operator=(rhs);
347  m_col = rhs.m_col;
348  }
349 
350  return *this;
351  }
352  /// clone function for polymorphism
353  inline virtual PostStep* clone() const
354  {
355  return new RowSingletonPS(*this);
356  }
357  ///
358  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
359  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
360  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
361  };
362 
363  /**@brief Postsolves forcing constraints.
364  @ingroup Algo
365  */
367  {
368  private:
369  const int m_i;
370  const int m_old_i;
371  const R m_lRhs;
376  const bool m_lhsFixed;
377  const bool m_maxSense;
380  const R m_lhs;
381  const R m_rhs;
382  const R m_rowobj;
383 
384  public:
385  ///
386  ForceConstraintPS(const SPxLPBase<R>& lp, int _i, bool lhsFixed, DataArray<bool>& fixCols,
387  Array<R>& lo, Array<R>& up)
388  : PostStep("ForceConstraint", lp.nRows(), lp.nCols())
389  , m_i(_i)
390  , m_old_i(lp.nRows() - 1)
391  , m_lRhs(lhsFixed ? lp.lhs(_i) : lp.rhs(_i))
392  , m_row(lp.rowVector(_i))
393  , m_objs(lp.rowVector(_i).size())
394  , m_fixed(fixCols)
395  , m_cols(lp.rowVector(_i).size())
396  , m_lhsFixed(lhsFixed)
397  , m_maxSense(lp.spxSense() == SPxLPBase<R>::MAXIMIZE)
398  , m_oldLowers(lo)
399  , m_oldUppers(up)
400  , m_lhs(lp.lhs(_i))
401  , m_rhs(lp.rhs(_i))
402  , m_rowobj(lp.rowObj(_i))
403  {
404  for(int k = 0; k < m_row.size(); ++k)
405  {
406  m_objs[k] = (lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(m_row.index(k)) : -lp.obj(m_row.index(
407  k)));
408  m_cols[k] = lp.colVector(m_row.index(k));
409  }
410  }
411  /// copy constructor
413  : PostStep(old)
414  , m_i(old.m_i)
415  , m_old_i(old.m_old_i)
416  , m_lRhs(old.m_lRhs)
417  , m_row(old.m_row)
418  , m_objs(old.m_objs)
419  , m_fixed(old.m_fixed)
420  , m_cols(old.m_cols)
421  , m_lhsFixed(old.m_lhsFixed)
422  , m_maxSense(old.m_maxSense)
423  , m_oldLowers(old.m_oldLowers)
424  , m_oldUppers(old.m_oldUppers)
425  , m_lhs(old.m_lhs)
426  , m_rhs(old.m_rhs)
427  , m_rowobj(old.m_rowobj)
428  {}
429  /// assignment operator
431  {
432  if(this != &rhs)
433  {
434  PostStep::operator=(rhs);
435  m_row = rhs.m_row;
436  m_objs = rhs.m_objs;
437  m_fixed = rhs.m_fixed;
438  m_cols = rhs.m_cols;
439  m_oldLowers = rhs.m_oldLowers;
440  m_oldUppers = rhs.m_oldUppers;
441  }
442 
443  return *this;
444  }
445  /// clone function for polymorphism
446  inline virtual PostStep* clone() const
447  {
448  return new ForceConstraintPS(*this);
449  }
450  ///
451  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
452  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
453  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
454  };
455 
456  /**@brief Postsolves variable fixing.
457  @ingroup Algo
458  */
459  class FixVariablePS : public PostStep
460  {
461  private:
462  const int m_j;
463  const int m_old_j;
464  const R m_val;
465  const R m_obj;
466  const R m_lower;
467  const R m_upper;
468  const bool m_correctIdx; /// does the index mapping have to be updated in postsolving?
470 
471  public:
472  ///
473  FixVariablePS(const SPxLPBase<R>& lp, SPxMainSM& simplifier, int _j, const R val,
474  bool correctIdx = true)
475  : PostStep("FixVariable", lp.nRows(), lp.nCols())
476  , m_j(_j)
477  , m_old_j(lp.nCols() - 1)
478  , m_val(val)
479  , m_obj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
480  , m_lower(lp.lower(_j))
481  , m_upper(lp.upper(_j))
482  , m_correctIdx(correctIdx)
483  , m_col(lp.colVector(_j))
484  {
485  simplifier.addObjoffset(m_val * lp.obj(m_j));
486  }
487  /// copy constructor
489  : PostStep(old)
490  , m_j(old.m_j)
491  , m_old_j(old.m_old_j)
492  , m_val(old.m_val)
493  , m_obj(old.m_obj)
494  , m_lower(old.m_lower)
495  , m_upper(old.m_upper)
496  , m_correctIdx(old.m_correctIdx)
497  , m_col(old.m_col)
498  {}
499  /// assignment operator
501  {
502  if(this != &rhs)
503  {
504  PostStep::operator=(rhs);
505  m_col = rhs.m_col;
506  }
507 
508  return *this;
509  }
510  /// clone function for polymorphism
511  inline virtual PostStep* clone() const
512  {
513  return new FixVariablePS(*this);
514  }
515  ///
516  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
517  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
518  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
519  };
520 
521  /**@brief Postsolves variable bound fixing.
522  @ingroup Algo
523  */
524  class FixBoundsPS : public PostStep
525  {
526  private:
527  const int m_j;
529 
530  public:
531  ///
532  FixBoundsPS(const SPxLPBase<R>& lp, int j, R val)
533  : PostStep("FixBounds", lp.nRows(), lp.nCols())
534  , m_j(j)
535  {
536  if(EQrel(lp.lower(j), lp.upper(j), this->eps()))
537  m_status = SPxSolverBase<R>::FIXED;
538  else if(EQrel(val, lp.lower(j), this->eps()))
539  m_status = SPxSolverBase<R>::ON_LOWER;
540  else if(EQrel(val, lp.upper(j), this->eps()))
541  m_status = SPxSolverBase<R>::ON_UPPER;
542  else if(lp.lower(j) <= R(-infinity) && lp.upper(j) >= R(infinity))
543  m_status = SPxSolverBase<R>::ZERO;
544  else
545  {
546  throw SPxInternalCodeException("XMAISM14 This should never happen.");
547  }
548  }
549  /// copy constructor
551  : PostStep(old)
552  , m_j(old.m_j)
553  , m_status(old.m_status)
554  {}
555  /// assignment operator
557  {
558  if(this != &rhs)
559  {
560  PostStep::operator=(rhs);
561  m_status = rhs.m_status;
562  }
563 
564  return *this;
565  }
566  /// clone function for polymorphism
567  inline virtual PostStep* clone() const
568  {
569  FixBoundsPS* FixBoundsPSptr = 0;
570  spx_alloc(FixBoundsPSptr);
571  return new(FixBoundsPSptr) FixBoundsPS(*this);
572  }
573  ///
574  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
575  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
576  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
577  };
578 
579  /**@brief Postsolves the case when constraints are removed due to a
580  variable with zero objective that is free in one direction.
581  @ingroup Algo
582  */
584  {
585  private:
586  const int m_j;
587  const int m_old_j;
588  const int m_old_i;
589  const R m_bnd;
594  const bool m_loFree;
595 
596  public:
597  ///
598  FreeZeroObjVariablePS(const SPxLPBase<R>& lp, int _j, bool loFree, SVectorBase<R> col_idx_sorted)
599  : PostStep("FreeZeroObjVariable", lp.nRows(), lp.nCols())
600  , m_j(_j)
601  , m_old_j(lp.nCols() - 1)
602  , m_old_i(lp.nRows() - 1)
603  , m_bnd(loFree ? lp.upper(_j) : lp.lower(_j))
604  , m_col(col_idx_sorted)
605  , m_lRhs(lp.colVector(_j).size())
606  , m_rowObj(lp.colVector(_j).size())
607  , m_rows(lp.colVector(_j).size())
608  , m_loFree(loFree)
609  {
610  for(int k = 0; k < m_col.size(); ++k)
611  {
612  assert(isNotZero(m_col.value(k)));
613 
614  int r = m_col.index(k);
615 
616  if((m_loFree && m_col.value(k) > 0) ||
617  (!m_loFree && m_col.value(k) < 0))
618  m_lRhs.add(k, lp.rhs(r));
619  else
620  m_lRhs.add(k, lp.lhs(r));
621 
622  m_rows[k] = lp.rowVector(r);
623  m_rowObj.add(k, lp.rowObj(r));
624  }
625  }
626  /// copy constructor
628  : PostStep(old)
629  , m_j(old.m_j)
630  , m_old_j(old.m_old_j)
631  , m_old_i(old.m_old_i)
632  , m_bnd(old.m_bnd)
633  , m_col(old.m_col)
634  , m_lRhs(old.m_lRhs)
635  , m_rowObj(old.m_rowObj)
636  , m_rows(old.m_rows)
637  , m_loFree(old.m_loFree)
638  {}
639  /// assignment operator
641  {
642  if(this != &rhs)
643  {
644  PostStep::operator=(rhs);
645  m_col = rhs.m_col;
646  m_lRhs = rhs.m_lRhs;
647  m_rowObj = rhs.m_rowObj;
648  m_rows = rhs.m_rows;
649  }
650 
651  return *this;
652  }
653  /// clone function for polymorphism
654  inline virtual PostStep* clone() const
655  {
656  FreeZeroObjVariablePS* FreeZeroObjVariablePSptr = 0;
657  spx_alloc(FreeZeroObjVariablePSptr);
658  return new(FreeZeroObjVariablePSptr) FreeZeroObjVariablePS(*this);
659  }
660  ///
661  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
662  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
663  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
664  };
665 
666  /**@brief Postsolves column singletons with zero objective.
667  @ingroup Algo
668  */
670  {
671  private:
672  const int m_j;
673  const int m_i;
674  const int m_old_j;
675  const R m_lhs;
676  const R m_rhs;
677  const R m_lower;
678  const R m_upper;
680 
681  public:
682  ///
683  ZeroObjColSingletonPS(const SPxLPBase<R>& lp, const SPxMainSM&, int _j, int _i)
684  : PostStep("ZeroObjColSingleton", lp.nRows(), lp.nCols())
685  , m_j(_j)
686  , m_i(_i)
687  , m_old_j(lp.nCols() - 1)
688  , m_lhs(lp.lhs(_i))
689  , m_rhs(lp.rhs(_i))
690  , m_lower(lp.lower(_j))
691  , m_upper(lp.upper(_j))
692  , m_row(lp.rowVector(_i))
693  {}
694  /// copy constructor
696  : PostStep(old)
697  , m_j(old.m_j)
698  , m_i(old.m_i)
699  , m_old_j(old.m_old_j)
700  , m_lhs(old.m_lhs)
701  , m_rhs(old.m_rhs)
702  , m_lower(old.m_lower)
703  , m_upper(old.m_upper)
704  , m_row(old.m_row)
705  {}
706  /// assignment operator
708  {
709  if(this != &rhs)
710  {
711  PostStep::operator=(rhs);
712  m_row = rhs.m_row;
713  }
714 
715  return *this;
716  }
717  /// clone function for polymorphism
718  inline virtual PostStep* clone() const
719  {
720  ZeroObjColSingletonPS* ZeroObjColSingletonPSptr = 0;
721  spx_alloc(ZeroObjColSingletonPSptr);
722  return new(ZeroObjColSingletonPSptr) ZeroObjColSingletonPS(*this);
723  }
724  ///
725  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
726  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
727  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
728  };
729 
730  /**@brief Postsolves free column singletons.
731  @ingroup Algo
732  */
734  {
735  private:
736  const int m_j;
737  const int m_i;
738  const int m_old_j;
739  const int m_old_i;
740  const R m_obj;
741  const R m_lRhs;
742  const bool m_onLhs;
743  const bool m_eqCons;
745 
746  public:
747  ///
748  FreeColSingletonPS(const SPxLPBase<R>& lp, SPxMainSM& simplifier, int _j, int _i, R slackVal)
749  : PostStep("FreeColSingleton", lp.nRows(), lp.nCols())
750  , m_j(_j)
751  , m_i(_i)
752  , m_old_j(lp.nCols() - 1)
753  , m_old_i(lp.nRows() - 1)
754  , m_obj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
755  , m_lRhs(slackVal)
756  , m_onLhs(EQ(slackVal, lp.lhs(_i)))
757  , m_eqCons(EQ(lp.lhs(_i), lp.rhs(_i)))
758  , m_row(lp.rowVector(_i))
759  {
760  assert(m_row[m_j] != 0.0);
761  simplifier.addObjoffset(m_lRhs * (lp.obj(m_j) / m_row[m_j]));
762  }
763  /// copy constructor
765  : PostStep(old)
766  , m_j(old.m_j)
767  , m_i(old.m_i)
768  , m_old_j(old.m_old_j)
769  , m_old_i(old.m_old_i)
770  , m_obj(old.m_obj)
771  , m_lRhs(old.m_lRhs)
772  , m_onLhs(old.m_onLhs)
773  , m_eqCons(old.m_eqCons)
774  , m_row(old.m_row)
775  {}
776  /// assignment operator
778  {
779  if(this != &rhs)
780  {
781  PostStep::operator=(rhs);
782  m_row = rhs.m_row;
783  }
784 
785  return *this;
786  }
787  /// clone function for polymorphism
788  inline virtual PostStep* clone() const
789  {
790  FreeColSingletonPS* FreeColSingletonPSptr = 0;
791  spx_alloc(FreeColSingletonPSptr);
792  return new(FreeColSingletonPSptr) FreeColSingletonPS(*this);
793  }
794  ///
795  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
796  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
797  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
798  };
799 
800  /**@brief Postsolves doubleton equations combined with a column singleton.
801  @ingroup Algo
802  */
804  {
805  private:
806  const int m_j;
807  const int m_k;
808  const int m_i;
809  const bool m_maxSense;
810  const bool m_jFixed;
811  const R m_jObj;
812  const R m_kObj;
813  const R m_aij;
814  const bool m_strictLo;
815  const bool m_strictUp;
816  const R m_newLo;
817  const R m_newUp;
818  const R m_oldLo;
819  const R m_oldUp;
820  const R m_Lo_j;
821  const R m_Up_j;
822  const R m_lhs;
823  const R m_rhs;
825 
826  public:
827  ///
828  DoubletonEquationPS(const SPxLPBase<R>& lp, int _j, int _k, int _i, R oldLo, R oldUp)
829  : PostStep("DoubletonEquation", lp.nRows(), lp.nCols())
830  , m_j(_j)
831  , m_k(_k)
832  , m_i(_i)
833  , m_maxSense(lp.spxSense() == SPxLPBase<R>::MAXIMIZE)
834  , m_jFixed(EQ(lp.lower(_j), lp.upper(_j)))
835  , m_jObj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
836  , m_kObj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_k) : -lp.obj(_k))
837  , m_aij(lp.colVector(_j).value(0))
838  , m_strictLo(lp.lower(_k) > oldLo)
839  , m_strictUp(lp.upper(_k) < oldUp)
840  , m_newLo(lp.lower(_k))
841  , m_newUp(lp.upper(_k))
842  , m_oldLo(oldLo)
843  , m_oldUp(oldUp)
844  , m_Lo_j(lp.lower(_j))
845  , m_Up_j(lp.upper(_j))
846  , m_lhs(lp.lhs(_i))
847  , m_rhs(lp.rhs(_i))
848  , m_col(lp.colVector(_k))
849  {}
850  /// copy constructor
852  : PostStep(old)
853  , m_j(old.m_j)
854  , m_k(old.m_k)
855  , m_i(old.m_i)
856  , m_maxSense(old.m_maxSense)
857  , m_jFixed(old.m_jFixed)
858  , m_jObj(old.m_jObj)
859  , m_kObj(old.m_kObj)
860  , m_aij(old.m_aij)
861  , m_strictLo(old.m_strictLo)
862  , m_strictUp(old.m_strictUp)
863  , m_newLo(old.m_newLo)
864  , m_newUp(old.m_newUp)
865  , m_oldLo(old.m_oldLo)
866  , m_oldUp(old.m_oldUp)
867  , m_Lo_j(old.m_Lo_j)
868  , m_Up_j(old.m_Up_j)
869  , m_lhs(old.m_lhs)
870  , m_rhs(old.m_rhs)
871  , m_col(old.m_col)
872  {}
873  /// assignment operator
875  {
876  if(this != &rhs)
877  {
878  PostStep::operator=(rhs);
879  m_col = rhs.m_col;
880  }
881 
882  return *this;
883  }
884  /// clone function for polymorphism
885  inline virtual PostStep* clone() const
886  {
887  DoubletonEquationPS* DoubletonEquationPSptr = 0;
888  spx_alloc(DoubletonEquationPSptr);
889  return new(DoubletonEquationPSptr) DoubletonEquationPS(*this);
890  }
891  ///
892  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
893  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
894  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
895  };
896 
897  /**@brief Postsolves duplicate rows.
898  @ingroup Algo
899  */
900  class DuplicateRowsPS : public PostStep
901  {
902  private:
903  const int m_i;
904  const R m_i_rowObj;
905  const int m_maxLhsIdx;
906  const int m_minRhsIdx;
907  const bool m_maxSense;
908  const bool m_isFirst;
909  const bool m_isLast;
910  const bool m_fixed;
911  const int m_nCols;
917 
918  public:
919  DuplicateRowsPS(const SPxLPBase<R>& lp, int _i,
920  int maxLhsIdx, int minRhsIdx, const DSVectorBase<R>& dupRows,
921  const Array<R> scale, const DataArray<int> perm, const DataArray<bool> isLhsEqualRhs,
922  bool isTheLast, bool isFixedRow, bool isFirst = false)
923  : PostStep("DuplicateRows", lp.nRows(), lp.nCols())
924  , m_i(_i)
925  , m_i_rowObj(lp.rowObj(_i))
926  , m_maxLhsIdx((maxLhsIdx == -1) ? -1 : maxLhsIdx)
927  , m_minRhsIdx((minRhsIdx == -1) ? -1 : minRhsIdx)
928  , m_maxSense(lp.spxSense() == SPxLPBase<R>::MAXIMIZE)
929  , m_isFirst(isFirst)
930  , m_isLast(isTheLast)
931  , m_fixed(isFixedRow)
932  , m_nCols(lp.nCols())
933  , m_scale(dupRows.size())
934  , m_rowObj(dupRows.size())
935  , m_rIdxLocalOld(dupRows.size())
936  , m_perm(perm)
937  , m_isLhsEqualRhs(isLhsEqualRhs)
938  {
939  R rowScale = scale[_i];
940 
941  for(int k = 0; k < dupRows.size(); ++k)
942  {
943  m_scale.add(dupRows.index(k), rowScale / scale[dupRows.index(k)]);
944  m_rowObj.add(dupRows.index(k), lp.rowObj(dupRows.index(k)));
945  m_rIdxLocalOld[k] = dupRows.index(k);
946  }
947  }
948  /// copy constructor
950  : PostStep(old)
951  , m_i(old.m_i)
952  , m_i_rowObj(old.m_i_rowObj)
953  , m_maxLhsIdx(old.m_maxLhsIdx)
954  , m_minRhsIdx(old.m_minRhsIdx)
955  , m_maxSense(old.m_maxSense)
956  , m_isFirst(old.m_isFirst)
957  , m_isLast(old.m_isLast)
958  , m_fixed(old.m_fixed)
959  , m_nCols(old.m_nCols)
960  , m_scale(old.m_scale)
961  , m_rowObj(old.m_rowObj)
962  , m_rIdxLocalOld(old.m_rIdxLocalOld)
963  , m_perm(old.m_perm)
964  , m_isLhsEqualRhs(old.m_isLhsEqualRhs)
965  {}
966  /// assignment operator
968  {
969  if(this != &rhs)
970  {
971  PostStep::operator=(rhs);
972  m_scale = rhs.m_scale;
973  m_rowObj = rhs.m_rowObj;
974  m_rIdxLocalOld = rhs.m_rIdxLocalOld;
975  m_perm = rhs.m_perm;
976  m_isLhsEqualRhs = rhs.m_isLhsEqualRhs;
977  }
978 
979  return *this;
980  }
981  /// clone function for polymorphism
982  inline virtual PostStep* clone() const
983  {
984  DuplicateRowsPS* DuplicateRowsPSptr = 0;
985  spx_alloc(DuplicateRowsPSptr);
986  return new(DuplicateRowsPSptr) DuplicateRowsPS(*this);
987  }
988  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
989  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
990  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
991  };
992 
993  /**@brief Postsolves duplicate columns.
994  @ingroup Algo
995  */
996  class DuplicateColsPS : public PostStep
997  {
998  private:
999  const int m_j;
1000  const int m_k;
1001  const R m_loJ;
1002  const R m_upJ;
1003  const R m_loK;
1004  const R m_upK;
1005  const R m_scale;
1006  const bool m_isFirst;
1007  const bool m_isLast;
1009 
1010  public:
1011  DuplicateColsPS(const SPxLPBase<R>& lp, int _j, int _k, R scale, DataArray<int> perm,
1012  bool isFirst = false, bool isTheLast = false)
1013  : PostStep("DuplicateCols", lp.nRows(), lp.nCols())
1014  , m_j(_j)
1015  , m_k(_k)
1016  , m_loJ(lp.lower(_j))
1017  , m_upJ(lp.upper(_j))
1018  , m_loK(lp.lower(_k))
1019  , m_upK(lp.upper(_k))
1020  , m_scale(scale)
1021  , m_isFirst(isFirst)
1022  , m_isLast(isTheLast)
1023  , m_perm(perm)
1024  {}
1025  /// copy constructor
1027  : PostStep(old)
1028  , m_j(old.m_j)
1029  , m_k(old.m_k)
1030  , m_loJ(old.m_loJ)
1031  , m_upJ(old.m_upJ)
1032  , m_loK(old.m_loK)
1033  , m_upK(old.m_upK)
1034  , m_scale(old.m_scale)
1035  , m_isFirst(old.m_isFirst)
1036  , m_isLast(old.m_isLast)
1037  , m_perm(old.m_perm)
1038  {}
1039  /// assignment operator
1041  {
1042  if(this != &rhs)
1043  {
1044  PostStep::operator=(rhs);
1045  }
1046 
1047  return *this;
1048  }
1049  /// clone function for polymorphism
1050  inline virtual PostStep* clone() const
1051  {
1052  DuplicateColsPS* DuplicateColsPSptr = 0;
1053  spx_alloc(DuplicateColsPSptr);
1054  return new(DuplicateColsPSptr) DuplicateColsPS(*this);
1055  }
1056  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
1057  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
1058  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
1059  };
1060 
1061  /**@brief Postsolves aggregation.
1062  @ingroup Algo
1063  */
1064  class AggregationPS : public PostStep
1065  {
1066  private:
1067  const int m_j;
1068  const int m_i;
1069  const int m_old_j;
1070  const int m_old_i;
1071  const R m_upper;
1072  const R m_lower;
1073  const R m_obj;
1074  const R m_oldupper;
1075  const R m_oldlower;
1076  const R m_rhs;
1079 
1080  public:
1081  ///
1082  AggregationPS(const SPxLPBase<R>& lp, int _i, int _j, R rhs, R oldupper, R oldlower)
1083  : PostStep("Aggregation", lp.nRows(), lp.nCols())
1084  , m_j(_j)
1085  , m_i(_i)
1086  , m_old_j(lp.nCols() - 1)
1087  , m_old_i(lp.nRows() - 1)
1088  , m_upper(lp.upper(_j))
1089  , m_lower(lp.lower(_j))
1090  , m_obj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
1091  , m_oldupper(oldupper)
1092  , m_oldlower(oldlower)
1093  , m_rhs(rhs)
1094  , m_row(lp.rowVector(_i))
1095  , m_col(lp.colVector(_j))
1096  {
1097  assert(m_row[m_j] != 0.0);
1098  }
1099  /// copy constructor
1101  : PostStep(old)
1102  , m_j(old.m_j)
1103  , m_i(old.m_i)
1104  , m_old_j(old.m_old_j)
1105  , m_old_i(old.m_old_i)
1106  , m_upper(old.m_upper)
1107  , m_lower(old.m_lower)
1108  , m_obj(old.m_obj)
1109  , m_oldupper(old.m_oldupper)
1110  , m_oldlower(old.m_oldlower)
1111  , m_rhs(old.m_rhs)
1112  , m_row(old.m_row)
1113  , m_col(old.m_col)
1114  {}
1115  /// assignment operator
1117  {
1118  if(this != &rhs)
1119  {
1120  PostStep::operator=(rhs);
1121  m_row = rhs.m_row;
1122  m_col = rhs.m_col;
1123  }
1124 
1125  return *this;
1126  }
1127  /// clone function for polymorphism
1128  inline virtual PostStep* clone() const
1129  {
1130  AggregationPS* AggregationPSptr = 0;
1131  spx_alloc(AggregationPSptr);
1132  return new(AggregationPSptr) AggregationPS(*this);
1133  }
1134  ///
1135  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
1136  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
1137  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
1138  };
1139 
1140  /**@brief Postsolves multi aggregation.
1141  @ingroup Algo
1142  */
1144  {
1145  private:
1146  const int m_j;
1147  const int m_i;
1148  const int m_old_j;
1149  const int m_old_i;
1150  const R m_upper;
1151  const R m_lower;
1152  const R m_obj;
1153  const R m_const;
1154  const bool m_onLhs;
1155  const bool m_eqCons;
1158 
1159  public:
1160  ///
1161  MultiAggregationPS(const SPxLPBase<R>& lp, SPxMainSM& simplifier, int _i, int _j, R constant)
1162  : PostStep("MultiAggregation", lp.nRows(), lp.nCols())
1163  , m_j(_j)
1164  , m_i(_i)
1165  , m_old_j(lp.nCols() - 1)
1166  , m_old_i(lp.nRows() - 1)
1167  , m_upper(lp.upper(_j))
1168  , m_lower(lp.lower(_j))
1169  , m_obj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
1170  , m_const(constant)
1171  , m_onLhs(EQ(constant, lp.lhs(_i)))
1172  , m_eqCons(EQ(lp.lhs(_i), lp.rhs(_i)))
1173  , m_row(lp.rowVector(_i))
1174  , m_col(lp.colVector(_j))
1175  {
1176  assert(m_row[m_j] != 0.0);
1177  simplifier.addObjoffset(m_obj * m_const / m_row[m_j]);
1178  }
1179  /// copy constructor
1181  : PostStep(old)
1182  , m_j(old.m_j)
1183  , m_i(old.m_i)
1184  , m_old_j(old.m_old_j)
1185  , m_old_i(old.m_old_i)
1186  , m_upper(old.m_upper)
1187  , m_lower(old.m_lower)
1188  , m_obj(old.m_obj)
1189  , m_const(old.m_const)
1190  , m_onLhs(old.m_onLhs)
1191  , m_eqCons(old.m_eqCons)
1192  , m_row(old.m_row)
1193  , m_col(old.m_col)
1194  {}
1195  /// assignment operator
1197  {
1198  if(this != &rhs)
1199  {
1200  PostStep::operator=(rhs);
1201  m_row = rhs.m_row;
1202  m_col = rhs.m_col;
1203  }
1204 
1205  return *this;
1206  }
1207  /// clone function for polymorphism
1208  inline virtual PostStep* clone() const
1209  {
1210  MultiAggregationPS* MultiAggregationPSptr = 0;
1211  spx_alloc(MultiAggregationPSptr);
1212  return new(MultiAggregationPSptr) MultiAggregationPS(*this);
1213  }
1214  ///
1215  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
1216  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
1217  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
1218  };
1219 
1220  /**@brief Postsolves variable bound tightening from pseudo objective propagation.
1221  @ingroup Algo
1222  */
1223  class TightenBoundsPS : public PostStep
1224  {
1225  private:
1226  const int m_j;
1227  const R m_origupper;
1228  const R m_origlower;
1229 
1230  public:
1231  ///
1232  TightenBoundsPS(const SPxLPBase<R>& lp, int j, R origupper, R origlower)
1233  : PostStep("TightenBounds", lp.nRows(), lp.nCols())
1234  , m_j(j)
1235  , m_origupper(origupper)
1236  , m_origlower(origlower)
1237  {
1238  }
1239  /// copy constructor
1241  : PostStep(old)
1242  , m_j(old.m_j)
1243  , m_origupper(old.m_origupper)
1244  , m_origlower(old.m_origlower)
1245  {}
1246  /// assignment operator
1248  {
1249  return *this;
1250  }
1251  /// clone function for polymorphism
1252  inline virtual PostStep* clone() const
1253  {
1254  TightenBoundsPS* TightenBoundsPSptr = 0;
1255  spx_alloc(TightenBoundsPSptr);
1256  return new(TightenBoundsPSptr) TightenBoundsPS(*this);
1257  }
1258  ///
1259  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
1260  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
1261  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
1262  };
1263  // friends
1264  friend class FreeConstraintPS;
1265  friend class EmptyConstraintPS;
1266  friend class RowSingletonPS;
1267  friend class ForceConstraintPS;
1268  friend class FixVariablePS;
1269  friend class FixBoundsPS;
1272  friend class FreeColSingletonPS;
1273  friend class DoubletonEquationPS;
1274  friend class DuplicateRowsPS;
1275  friend class DuplicateColsPS;
1276  friend class AggregationPS;
1277 
1278 private:
1279  //------------------------------------
1280  ///@name Types
1281  ///@{
1282  /// Different simplification steps.
1284  {
1290  FIX_COL = 5,
1302  };
1303  ///@}
1304 
1305  //------------------------------------
1306  ///@name Data
1307  ///@{
1308  ///
1309  VectorBase<R> m_prim; ///< unsimplified primal solution VectorBase<R>.
1310  VectorBase<R> m_slack; ///< unsimplified slack VectorBase<R>.
1311  VectorBase<R> m_dual; ///< unsimplified dual solution VectorBase<R>.
1312  VectorBase<R> m_redCost; ///< unsimplified reduced cost VectorBase<R>.
1315  DataArray<int> m_cIdx; ///< column index VectorBase<R> in original LP.
1316  DataArray<int> m_rIdx; ///< row index VectorBase<R> in original LP.
1317  Array<std::shared_ptr<PostStep>>m_hist; ///< VectorBase<R> of presolve history.
1319  m_classSetRows; ///< stores parallel classes with non-zero colum entry
1321  m_classSetCols; ///< stores parallel classes with non-zero row entry
1323  m_dupRows; ///< arrange duplicate rows using bucket sort w.r.t. their pClass values
1325  m_dupCols; ///< arrange duplicate columns w.r.t. their pClass values
1326  bool m_postsolved; ///< status of postsolving.
1327  R m_epsilon; ///< epsilon zero.
1328  R m_feastol; ///< primal feasibility tolerance.
1329  R m_opttol; ///< dual feasibility tolerance.
1330  DataArray<int> m_stat; ///< preprocessing history.
1331  typename SPxLPBase<R>::SPxSense m_thesense; ///< optimization sense.
1332  bool m_keepbounds; ///< keep some bounds (for boundflipping)
1333  int m_addedcols; ///< columns added by handleRowObjectives()
1334  typename SPxSimplifier<R>::Result m_result; ///< result of the simplification.
1335  R m_cutoffbound; ///< the cutoff bound that is found by heuristics
1336  R m_pseudoobj; ///< the pseudo objective function value
1337  ///@}
1338 
1339 private:
1340  //------------------------------------
1341  ///@name Private helpers
1342  ///@{
1343  /// handle row objectives
1345 
1346  /// handles extreme values by setting them to zero or R(infinity).
1347  void handleExtremes(SPxLPBase<R>& lp);
1348 
1349  /// computes the minimum and maximum residual activity for a given row and column. If colNumber is set to -1, then
1350  // the activity of the row is returned.
1351  void computeMinMaxResidualActivity(SPxLPBase<R>& lp, int rowNumber, int colNumber, R& minAct,
1352  R& maxAct);
1353 
1354  /// calculate min/max value for the multi aggregated variables
1355  void computeMinMaxValues(SPxLPBase<R>& lp, R side, R val, R minRes, R maxRes, R& minVal, R& maxVal);
1356 
1357  /// tries to find good lower bound solutions by applying some trivial heuristics
1358  void trivialHeuristic(SPxLPBase<R>& lp);
1359 
1360  /// checks a solution for feasibility
1361  bool checkSolution(SPxLPBase<R>& lp, VectorBase<R> sol);
1362 
1363  /// tightens variable bounds by propagating the pseudo objective function value.
1364  void propagatePseudoobj(SPxLPBase<R>& lp);
1365 
1366  /// removed empty rows and empty columns.
1368 
1369  /// remove row singletons.
1371  int& i);
1372 
1373  /// aggregate two variables that appear in an equation.
1375  int& i);
1376 
1377  /// performs simplification steps on the rows of the LP.
1378  typename SPxSimplifier<R>::Result simplifyRows(SPxLPBase<R>& lp, bool& again);
1379 
1380  /// performs simplification steps on the columns of the LP.
1381  typename SPxSimplifier<R>::Result simplifyCols(SPxLPBase<R>& lp, bool& again);
1382 
1383  /// performs simplification steps on the LP based on dual concepts.
1384  typename SPxSimplifier<R>::Result simplifyDual(SPxLPBase<R>& lp, bool& again);
1385 
1386  /// performs multi-aggregations of variable based upon constraint activitu.
1387  typename SPxSimplifier<R>::Result multiaggregation(SPxLPBase<R>& lp, bool& again);
1388 
1389  /// removes duplicate rows.
1390  typename SPxSimplifier<R>::Result duplicateRows(SPxLPBase<R>& lp, bool& again);
1391 
1392  /// removes duplicate columns
1393  typename SPxSimplifier<R>::Result duplicateCols(SPxLPBase<R>& lp, bool& again);
1394 
1395  /// handles the fixing of a variable. correctIdx is true iff the index mapping has to be updated.
1396  void fixColumn(SPxLPBase<R>& lp, int i, bool correctIdx = true);
1397 
1398  /// removes a row in the LP.
1399  void removeRow(SPxLPBase<R>& lp, int i)
1400  {
1401  m_rIdx[i] = m_rIdx[lp.nRows() - 1];
1402  lp.removeRow(i);
1403  }
1404  /// removes a column in the LP.
1405  void removeCol(SPxLPBase<R>& lp, int j)
1406  {
1407  m_cIdx[j] = m_cIdx[lp.nCols() - 1];
1408  lp.removeCol(j);
1409  }
1410  /// returns for a given row index of the (reduced) LP the corresponding row index in the unsimplified LP.
1411  int rIdx(int i) const
1412  {
1413  return m_rIdx[i];
1414  }
1415  /// returns for a given column index of the (reduced) LP the corresponding column index in the unsimplified LP.
1416  int cIdx(int j) const
1417  {
1418  return m_cIdx[j];
1419  }
1420  ///@}
1421 
1422 protected:
1423 
1424  ///
1425  R epsZero() const
1426  {
1427  return m_epsilon;
1428  }
1429  ///
1430  R feastol() const
1431  {
1432  return m_feastol;
1433  }
1434  ///
1435  R opttol() const
1436  {
1437  return m_opttol;
1438  }
1439 
1440 public:
1441 
1442  //------------------------------------
1443  ///@name Constructors / destructors
1444  ///@{
1445  /// default constructor.
1447  : SPxSimplifier<R>("MainSM", ttype)
1448  , m_postsolved(0)
1449  , m_epsilon(DEFAULT_EPS_ZERO)
1450  , m_feastol(DEFAULT_BND_VIOL)
1451  , m_opttol(DEFAULT_BND_VIOL)
1452  , m_stat(16)
1453  , m_thesense(SPxLPBase<R>::MAXIMIZE)
1454  , m_keepbounds(false)
1455  , m_addedcols(0)
1456  , m_result(this->OKAY)
1457  , m_cutoffbound(R(-infinity))
1458  , m_pseudoobj(R(-infinity))
1459  {}
1460  /// copy constructor.
1461  SPxMainSM(const SPxMainSM& old)
1462  : SPxSimplifier<R>(old)
1463  , m_prim(old.m_prim)
1464  , m_slack(old.m_slack)
1465  , m_dual(old.m_dual)
1466  , m_redCost(old.m_redCost)
1467  , m_cBasisStat(old.m_cBasisStat)
1468  , m_rBasisStat(old.m_rBasisStat)
1469  , m_cIdx(old.m_cIdx)
1470  , m_rIdx(old.m_rIdx)
1471  , m_hist(old.m_hist)
1472  , m_postsolved(old.m_postsolved)
1473  , m_epsilon(old.m_epsilon)
1474  , m_feastol(old.m_feastol)
1475  , m_opttol(old.m_opttol)
1476  , m_stat(old.m_stat)
1477  , m_thesense(old.m_thesense)
1478  , m_keepbounds(old.m_keepbounds)
1479  , m_addedcols(old.m_addedcols)
1480  , m_result(old.m_result)
1481  , m_cutoffbound(old.m_cutoffbound)
1482  , m_pseudoobj(old.m_pseudoobj)
1483  {
1484  ;
1485  }
1486  /// assignment operator
1488  {
1489  if(this != &rhs)
1490  {
1492  m_prim = rhs.m_prim;
1493  m_slack = rhs.m_slack;
1494  m_dual = rhs.m_dual;
1495  m_redCost = rhs.m_redCost;
1496  m_cBasisStat = rhs.m_cBasisStat;
1497  m_rBasisStat = rhs.m_rBasisStat;
1498  m_cIdx = rhs.m_cIdx;
1499  m_rIdx = rhs.m_rIdx;
1500  m_postsolved = rhs.m_postsolved;
1501  m_epsilon = rhs.m_epsilon;
1502  m_feastol = rhs.m_feastol;
1503  m_opttol = rhs.m_opttol;
1504  m_stat = rhs.m_stat;
1505  m_thesense = rhs.m_thesense;
1506  m_keepbounds = rhs.m_keepbounds;
1507  m_addedcols = rhs.m_addedcols;
1508  m_result = rhs.m_result;
1509  m_cutoffbound = rhs.m_cutoffbound;
1510  m_pseudoobj = rhs.m_pseudoobj;
1511  m_hist = rhs.m_hist;
1512  }
1513 
1514 
1515  return *this;
1516  }
1517  /// destructor.
1518  virtual ~SPxMainSM()
1519  {
1520  ;
1521  }
1522  /// clone function for polymorphism
1523  inline virtual SPxSimplifier<R>* clone() const
1524  {
1525  return new SPxMainSM(*this);
1526  }
1527  ///@}
1528 
1529  //------------------------------------
1530  //**@name LP simplification */
1531  ///@{
1532  /// simplify SPxLPBase<R> \p lp with identical primal and dual feasibility tolerance.
1533  virtual typename SPxSimplifier<R>::Result simplify(SPxLPBase<R>& lp, R eps, R delta)
1534  {
1535  return simplify(lp, eps, delta, delta);
1536  }
1537  /// simplify SPxLPBase<R> \p lp with independent primal and dual feasibility tolerance.
1538  virtual typename SPxSimplifier<R>::Result simplify(SPxLPBase<R>& lp, R eps, R ftol, R otol,
1539  bool keepbounds = false);
1540 
1541  /// reconstructs an optimal solution for the unsimplified LP.
1542  virtual void unsimplify(const VectorBase<R>& x, const VectorBase<R>& y, const VectorBase<R>& s,
1543  const VectorBase<R>& r,
1544  const typename SPxSolverBase<R>::VarStatus rows[],
1545  const typename SPxSolverBase<R>::VarStatus cols[], bool isOptimal = true);
1546 
1547  /// returns result status of the simplification
1548  virtual typename SPxSimplifier<R>::Result result() const
1549  {
1550  return m_result;
1551  }
1552 
1553  /// specifies whether an optimal solution has already been unsimplified.
1554  virtual bool isUnsimplified() const
1555  {
1556  return m_postsolved;
1557  }
1558  /// returns a reference to the unsimplified primal solution.
1560  {
1561  assert(m_postsolved);
1562  return m_prim;
1563  }
1564  /// returns a reference to the unsimplified dual solution.
1566  {
1567  assert(m_postsolved);
1568  return m_dual;
1569  }
1570  /// returns a reference to the unsimplified slack values.
1572  {
1573  assert(m_postsolved);
1574  return m_slack;
1575  }
1576  /// returns a reference to the unsimplified reduced costs.
1578  {
1579  assert(m_postsolved);
1580  return m_redCost;
1581  }
1582  /// gets basis status for a single row.
1583  virtual typename SPxSolverBase<R>::VarStatus getBasisRowStatus(int i) const
1584  {
1585  assert(m_postsolved);
1586  return m_rBasisStat[i];
1587  }
1588  /// gets basis status for a single column.
1589  virtual typename SPxSolverBase<R>::VarStatus getBasisColStatus(int j) const
1590  {
1591  assert(m_postsolved);
1592  return m_cBasisStat[j];
1593  }
1594  /// get optimal basis.
1595  virtual void getBasis(typename SPxSolverBase<R>::VarStatus rows[],
1596  typename SPxSolverBase<R>::VarStatus cols[], const int rowsSize = -1, const int colsSize = -1) const
1597  {
1598  assert(m_postsolved);
1599  assert(rowsSize < 0 || rowsSize >= m_rBasisStat.size());
1600  assert(colsSize < 0 || colsSize >= m_cBasisStat.size());
1601 
1602  for(int i = 0; i < m_rBasisStat.size(); ++i)
1603  rows[i] = m_rBasisStat[i];
1604 
1605  for(int j = 0; j < m_cBasisStat.size(); ++j)
1606  cols[j] = m_cBasisStat[j];
1607  }
1608  ///@}
1609 
1610 private:
1611  //------------------------------------
1612  //**@name Types */
1613  ///@{
1614  /// comparator for class SVectorBase<R>::Element: compare nonzeros according to value
1616  {
1617  public:
1619 
1620  int operator()(const typename SVectorBase<R>::Element& e1,
1621  const typename SVectorBase<R>::Element& e2) const
1622  {
1623  if(EQ(e1.val, e2.val))
1624  return 0;
1625 
1626  if(e1.val < e2.val)
1627  return -1;
1628  else // (e1.val > e2.val)
1629  return 1;
1630  }
1631  };
1632  /// comparator for class SVectorBase<R>::Element: compare nonzeros according to index
1633  struct IdxCompare
1634  {
1635  public:
1637 
1638  int operator()(const typename SVectorBase<R>::Element& e1,
1639  const typename SVectorBase<R>::Element& e2) const
1640  {
1641  if(EQ(e1.idx, e2.idx))
1642  return 0;
1643 
1644  if(e1.idx < e2.idx)
1645  return -1;
1646  else // (e1.idx > e2.idx)
1647  return 1;
1648  }
1649  };
1650  ///@}
1651 };
1652 
1653 } // namespace soplex
1654 
1655 // For including general templated functions
1656 #include "spxmainsm.hpp"
1657 
1658 #endif // _SPXMAINSM_H_
const VectorBase< R > & rhs() const
Returns right hand side vector.
Definition: spxlpbase.h:239
virtual bool isUnsimplified() const
specifies whether an optimal solution has already been unsimplified.
Definition: spxmainsm.h:1554
Postsolves multi aggregation.
Definition: spxmainsm.h:1143
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
Definition: exceptions.h:109
RowObjPS & operator=(const RowObjPS &rhs)
assignment operator
Definition: spxmainsm.h:158
SPxSimplifier< R >::Result simplifyCols(SPxLPBase< R > &lp, bool &again)
performs simplification steps on the columns of the LP.
virtual void removeRow(int i)
Removes i &#39;th row.
Definition: spxlpbase.h:951
MultiAggregationPS(const MultiAggregationPS &old)
copy constructor
Definition: spxmainsm.h:1180
Safe arrays of data objects.Class DataArray provides safe arrays of Data Objects. For general C++ obj...
Definition: dataarray.h:65
friend class FreeConstraintPS
Definition: spxmainsm.h:1264
DataArray< int > m_stat
preprocessing history.
Definition: spxmainsm.h:1330
Sparse vector nonzero element.
Definition: svectorbase.h:37
ZeroObjColSingletonPS & operator=(const ZeroObjColSingletonPS &rhs)
assignment operator
Definition: spxmainsm.h:707
PostStep & operator=(const PostStep &)
assignment operator
Definition: spxmainsm.h:99
SPxMainSM(Timer::TYPE ttype=Timer::USER_TIME)
Definition: spxmainsm.h:1446
SPxLPBase< R >::SPxSense m_thesense
optimization sense.
Definition: spxmainsm.h:1331
const VectorBase< R > & upper() const
Returns upper bound vector.
Definition: spxlpbase.h:479
void removeCol(SPxLPBase< R > &lp, int j)
removes a column in the LP.
Definition: spxmainsm.h:1405
#define DEFAULT_BND_VIOL
default allowed bound violation
Definition: spxdefines.h:235
virtual SPxSimplifier< R > * clone() const
clone function for polymorphism
Definition: spxmainsm.h:1523
bool EQ(int a, int b)
Definition: spxdefines.cpp:27
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:32
Postsolves variable bound fixing.
Definition: spxmainsm.h:524
Result
Result of the simplification.
Definition: spxsimplifier.h:82
Dense vector.Class VectorBase provides dense linear algebra vectors. Internally, VectorBase wraps std...
Definition: dsvectorbase.h:28
AggregationPS & operator=(const AggregationPS &rhs)
assignment operator
Definition: spxmainsm.h:1116
ZeroObjColSingletonPS(const SPxLPBase< R > &lp, const SPxMainSM &, int _j, int _i)
Definition: spxmainsm.h:683
R opttol() const
Definition: spxmainsm.h:1435
virtual const VectorBase< R > & unsimplifiedPrimal()
returns a reference to the unsimplified primal solution.
Definition: spxmainsm.h:1559
virtual SPxSolverBase< R >::VarStatus getBasisColStatus(int j) const
gets basis status for a single column.
Definition: spxmainsm.h:1589
Postsolves duplicate rows.
Definition: spxmainsm.h:900
int size() const
Number of used indices.
Definition: svectorbase.h:155
const char * m_name
name of the simplifier
Definition: spxmainsm.h:79
FixVariablePS(const FixVariablePS &old)
copy constructor
Definition: spxmainsm.h:488
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:273
Sequential object-oriented SimPlex.SPxSolverBase is an LP solver class using the revised Simplex algo...
Definition: spxbasis.h:49
DoubletonEquationPS(const SPxLPBase< R > &lp, int _j, int _k, int _i, R oldLo, R oldUp)
Definition: spxmainsm.h:828
Exception classes for SoPlex.
void fixColumn(SPxLPBase< R > &lp, int i, bool correctIdx=true)
handles the fixing of a variable. correctIdx is true iff the index mapping has to be updated...
SPxMainSM & operator=(const SPxMainSM &rhs)
assignment operator
Definition: spxmainsm.h:1487
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:173
int operator()(const typename SVectorBase< R >::Element &e1, const typename SVectorBase< R >::Element &e2) const
Definition: spxmainsm.h:1638
Dynamic sparse vectors.Class DSVectorBase implements dynamic sparse vectors, i.e. SVectorBases with a...
Definition: dsvectorbase.h:43
SPxSimplifier< R >::Result multiaggregation(SPxLPBase< R > &lp, bool &again)
performs multi-aggregations of variable based upon constraint activitu.
SPxSolverBase< R >::VarStatus m_status
Definition: spxmainsm.h:528
virtual bool checkBasisDim(DataArray< typename SPxSolverBase< R >::VarStatus > rows, DataArray< typename SPxSolverBase< R >::VarStatus > cols) const
virtual SPxSolverBase< R >::VarStatus getBasisRowStatus(int i) const
gets basis status for a single row.
Definition: spxmainsm.h:1583
friend class DuplicateRowsPS
Definition: spxmainsm.h:1274
PostStep(const PostStep &old)
copy constructor.
Definition: spxmainsm.h:93
SPxSimplifier< R >::Result duplicateRows(SPxLPBase< R > &lp, bool &again)
removes duplicate rows.
R m_feastol
primal feasibility tolerance.
Definition: spxmainsm.h:1328
int cIdx(int j) const
returns for a given column index of the (reduced) LP the corresponding column index in the unsimplifi...
Definition: spxmainsm.h:1416
FixBoundsPS & operator=(const FixBoundsPS &rhs)
assignment operator
Definition: spxmainsm.h:556
void handleExtremes(SPxLPBase< R > &lp)
handles extreme values by setting them to zero or R(infinity).
RowSingletonPS & operator=(const RowSingletonPS &rhs)
assignment operator
Definition: spxmainsm.h:342
Base class for postsolving operations.Class PostStep is an abstract base class providing the interfac...
Definition: spxmainsm.h:75
R m_opttol
dual feasibility tolerance.
Definition: spxmainsm.h:1329
FreeConstraintPS(const FreeConstraintPS &old)
copy constructor
Definition: spxmainsm.h:200
virtual void removeCol(int i)
Removes i &#39;th column.
Definition: spxlpbase.h:1051
R & value(int n)
Reference to value of n &#39;th nonzero.
Definition: svectorbase.h:255
FreeZeroObjVariablePS(const SPxLPBase< R > &lp, int _j, bool loFree, SVectorBase< R > col_idx_sorted)
Definition: spxmainsm.h:598
DuplicateRowsPS & operator=(const DuplicateRowsPS &rhs)
assignment operator
Definition: spxmainsm.h:967
Postsolves empty constraints.
Definition: spxmainsm.h:234
void trivialHeuristic(SPxLPBase< R > &lp)
tries to find good lower bound solutions by applying some trivial heuristics
void propagatePseudoobj(SPxLPBase< R > &lp)
tightens variable bounds by propagating the pseudo objective function value.
PostStep(const char *p_name, int nR=0, int nC=0)
constructor.
Definition: spxmainsm.h:87
FreeConstraintPS(const SPxLPBase< R > &lp, int _i)
Definition: spxmainsm.h:192
FreeColSingletonPS(const FreeColSingletonPS &old)
copy constructor
Definition: spxmainsm.h:764
bool m_postsolved
status of postsolving.
Definition: spxmainsm.h:1326
int rIdx(int i) const
returns for a given row index of the (reduced) LP the corresponding row index in the unsimplified LP...
Definition: spxmainsm.h:1411
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:1208
virtual void unsimplify(const VectorBase< R > &x, const VectorBase< R > &y, const VectorBase< R > &s, const VectorBase< R > &r, const typename SPxSolverBase< R >::VarStatus rows[], const typename SPxSolverBase< R >::VarStatus cols[], bool isOptimal=true)
reconstructs an optimal solution for the unsimplified LP.
int idx
Index of nonzero element.
Definition: svectorbase.h:42
LP simplification base class.
AggregationPS(const SPxLPBase< R > &lp, int _i, int _j, R rhs, R oldupper, R oldlower)
Definition: spxmainsm.h:1082
FreeZeroObjVariablePS & operator=(const FreeZeroObjVariablePS &rhs)
assignment operator
Definition: spxmainsm.h:640
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:1128
int nRows() const
Returns number of rows in LP.
Definition: spxlpbase.h:170
void add(const SVectorBase< S > &vec)
Append nonzeros of sv.
Definition: dsvectorbase.h:219
VectorBase< R > m_redCost
unsimplified reduced cost VectorBase<R>.
Definition: spxmainsm.h:1312
FixVariablePS(const SPxLPBase< R > &lp, SPxMainSM &simplifier, int _j, const R val, bool correctIdx=true)
Definition: spxmainsm.h:473
void spx_alloc(T &p, int n=1)
Allocate memory.
Definition: spxalloc.h:49
simplification could be done
Definition: spxsimplifier.h:84
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:567
Postsolves the case when constraints are removed due to a variable with zero objective that is free i...
Definition: spxmainsm.h:583
virtual const char * getName() const
get name of simplifying step.
Definition: spxmainsm.h:109
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:654
friend class RowSingletonPS
Definition: spxmainsm.h:1266
EmptyConstraintPS(const EmptyConstraintPS &old)
copy constructor
Definition: spxmainsm.h:250
EmptyConstraintPS(const SPxLPBase< R > &lp, int _i)
Definition: spxmainsm.h:243
SPxSimplifier & operator=(const SPxSimplifier &rhs)
assignment operator
SPxSense
Optimization sense.
Definition: spxlpbase.h:115
TightenBoundsPS & operator=(const TightenBoundsPS &rhs)
assignment operator
Definition: spxmainsm.h:1247
virtual ~PostStep()
destructor.
Definition: spxmainsm.h:104
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:511
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:885
Array< std::shared_ptr< PostStep > > m_hist
VectorBase<R> of presolve history.
Definition: spxmainsm.h:1317
RowSingletonPS(const RowSingletonPS &old)
copy constructor
Definition: spxmainsm.h:323
int nRows
number of rows
Definition: spxmainsm.h:83
SPxSense spxSense() const
Returns the optimization sense.
Definition: spxlpbase.h:533
int & index(int n)
Reference to index of n &#39;th nonzero.
Definition: svectorbase.h:237
Postsolves row singletons.
Definition: spxmainsm.h:282
MultiAggregationPS & operator=(const MultiAggregationPS &rhs)
assignment operator
Definition: spxmainsm.h:1196
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:718
ForceConstraintPS(const SPxLPBase< R > &lp, int _i, bool lhsFixed, DataArray< bool > &fixCols, Array< R > &lo, Array< R > &up)
Definition: spxmainsm.h:386
virtual const VectorBase< R > & unsimplifiedRedCost()
returns a reference to the unsimplified reduced costs.
Definition: spxmainsm.h:1577
void handleRowObjectives(SPxLPBase< R > &lp)
LP simplification abstract base class.Instances of classes derived from SPxSimplifier may be loaded t...
Definition: spxsimplifier.h:42
DuplicateColsPS & operator=(const DuplicateColsPS &rhs)
assignment operator
Definition: spxmainsm.h:1040
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:225
R feastol() const
Definition: spxmainsm.h:1430
R rowObj(int i) const
Definition: spxlpbase.h:300
friend class DoubletonEquationPS
Definition: spxmainsm.h:1273
Array< DSVectorBase< R > > m_classSetCols
stores parallel classes with non-zero row entry
Definition: spxmainsm.h:1321
SPxMainSM(const SPxMainSM &old)
copy constructor.
Definition: spxmainsm.h:1461
FixVariablePS & operator=(const FixVariablePS &rhs)
assignment operator
Definition: spxmainsm.h:500
Postsolves doubleton equations combined with a column singleton.
Definition: spxmainsm.h:803
Postsolves free column singletons.
Definition: spxmainsm.h:733
RowSingletonPS(const SPxLPBase< R > &lp, int _i, int _j, bool strictLo, bool strictUp, R newLo, R newUp, R oldLo, R oldUp)
Definition: spxmainsm.h:303
ForceConstraintPS & operator=(const ForceConstraintPS &rhs)
assignment operator
Definition: spxmainsm.h:430
Array< DSVectorBase< R > > m_classSetRows
stores parallel classes with non-zero colum entry
Definition: spxmainsm.h:1319
SPxSimplifier< R >::Result m_result
result of the simplification.
Definition: spxmainsm.h:1334
#define DEFAULT_EPS_ZERO
default allowed additive zero: 1.0 + EPS_ZERO == 1.0
Definition: spxdefines.h:239
int operator()(const typename SVectorBase< R >::Element &e1, const typename SVectorBase< R >::Element &e2) const
Definition: spxmainsm.h:1620
comparator for class SVectorBase<R>::Element: compare nonzeros according to value ...
Definition: spxmainsm.h:1615
R obj(int i) const
Returns objective value of column i.
Definition: spxlpbase.h:425
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:1252
const VectorBase< R > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:273
friend class FixBoundsPS
Definition: spxmainsm.h:1269
DataArray< int > m_cIdx
column index VectorBase<R> in original LP.
Definition: spxmainsm.h:1315
FixBoundsPS(const FixBoundsPS &old)
copy constructor
Definition: spxmainsm.h:550
SPxSimplifier< R >::Result simplifyDual(SPxLPBase< R > &lp, bool &again)
performs simplification steps on the LP based on dual concepts.
DuplicateColsPS(const DuplicateColsPS &old)
copy constructor
Definition: spxmainsm.h:1026
R m_pseudoobj
the pseudo objective function value
Definition: spxmainsm.h:1336
SPxSimplifier< R >::Result duplicateCols(SPxLPBase< R > &lp, bool &again)
removes duplicate columns
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:353
DuplicateRowsPS(const DuplicateRowsPS &old)
copy constructor
Definition: spxmainsm.h:949
DoubletonEquationPS(const DoubletonEquationPS &old)
copy constructor
Definition: spxmainsm.h:851
DuplicateRowsPS(const SPxLPBase< R > &lp, int _i, int maxLhsIdx, int minRhsIdx, const DSVectorBase< R > &dupRows, const Array< R > scale, const DataArray< int > perm, const DataArray< bool > isLhsEqualRhs, bool isTheLast, bool isFixedRow, bool isFirst=false)
Definition: spxmainsm.h:919
MultiAggregationPS(const SPxLPBase< R > &lp, SPxMainSM &simplifier, int _i, int _j, R constant)
Definition: spxmainsm.h:1161
virtual PostStep * clone() const =0
clone function for polymorphism
Debugging, floating point type and parameter definitions.
bool checkSolution(SPxLPBase< R > &lp, VectorBase< R > sol)
checks a solution for feasibility
Postsolves row objectives.
Definition: spxmainsm.h:138
DataArray< int > m_rIdx
row index VectorBase<R> in original LP.
Definition: spxmainsm.h:1316
Postsolves column singletons with zero objective.
Definition: spxmainsm.h:669
TightenBoundsPS(const TightenBoundsPS &old)
copy constructor
Definition: spxmainsm.h:1240
virtual void execute(VectorBase< R > &x, VectorBase< R > &y, VectorBase< R > &s, VectorBase< R > &r, DataArray< typename SPxSolverBase< R >::VarStatus > &cBasis, DataArray< typename SPxSolverBase< R >::VarStatus > &rBasis, bool isOptimal) const =0
executes the postsolving.
R epsZero() const
Definition: spxmainsm.h:1425
void computeMinMaxValues(SPxLPBase< R > &lp, R side, R val, R minRes, R maxRes, R &minVal, R &maxVal)
calculate min/max value for the multi aggregated variables
SPxSimplifier< R >::Result removeRowSingleton(SPxLPBase< R > &lp, const SVectorBase< R > &row, int &i)
remove row singletons.
bool m_keepbounds
keep some bounds (for boundflipping)
Definition: spxmainsm.h:1332
Array< DSVectorBase< R > > m_dupRows
arrange duplicate rows using bucket sort w.r.t. their pClass values
Definition: spxmainsm.h:1323
Everything should be within this namespace.
AggregationPS(const AggregationPS &old)
copy constructor
Definition: spxmainsm.h:1100
TYPE
types of timers
Definition: timer.h:99
RowObjPS(const SPxLPBase< R > &lp, int _i, int _j)
Definition: spxmainsm.h:146
friend class ForceConstraintPS
Definition: spxmainsm.h:1267
VectorBase< R > m_slack
unsimplified slack VectorBase<R>.
Definition: spxmainsm.h:1310
Saving LPs in a form suitable for SoPlex.Class SPxLPBase provides the data structures required for sa...
Definition: spxlpbase.h:56
virtual ~SPxMainSM()
destructor.
Definition: spxmainsm.h:1518
friend class AggregationPS
Definition: spxmainsm.h:1276
virtual const VectorBase< R > & unsimplifiedDual()
returns a reference to the unsimplified dual solution.
Definition: spxmainsm.h:1565
VectorBase< R > m_dual
unsimplified dual solution VectorBase<R>.
Definition: spxmainsm.h:1311
Save arrays of arbitrary types.
SPxSimplifier< R >::Result removeEmpty(SPxLPBase< R > &lp)
removed empty rows and empty columns.
friend class DuplicateColsPS
Definition: spxmainsm.h:1275
FreeZeroObjVariablePS(const FreeZeroObjVariablePS &old)
copy constructor
Definition: spxmainsm.h:627
Array< DSVectorBase< R > > m_cols
Definition: spxmainsm.h:375
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
Definition: spxlpbase.h:224
comparator for class SVectorBase<R>::Element: compare nonzeros according to index ...
Definition: spxmainsm.h:1633
TightenBoundsPS(const SPxLPBase< R > &lp, int j, R origupper, R origlower)
Definition: spxmainsm.h:1232
FreeColSingletonPS & operator=(const FreeColSingletonPS &rhs)
assignment operator
Definition: spxmainsm.h:777
virtual SPxSimplifier< R >::Result simplify(SPxLPBase< R > &lp, R eps, R delta)
simplify SPxLPBase<R> lp with identical primal and dual feasibility tolerance.
Definition: spxmainsm.h:1533
DSVectorBase< R > m_col
does the index mapping have to be updated in postsolving?
Definition: spxmainsm.h:469
void computeMinMaxResidualActivity(SPxLPBase< R > &lp, int rowNumber, int colNumber, R &minAct, R &maxAct)
computes the minimum and maximum residual activity for a given row and column. If colNumber is set to...
int m_j
slack column index
Definition: spxmainsm.h:142
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:446
Postsolves duplicate columns.
Definition: spxmainsm.h:996
DataArray< bool > m_isLhsEqualRhs
Definition: spxmainsm.h:916
int size() const
return nr. of elements.
Definition: dataarray.h:219
Postsolves forcing constraints.
Definition: spxmainsm.h:366
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:982
Postsolves unconstraint constraints.
Definition: spxmainsm.h:182
R val
Value of nonzero element.
Definition: svectorbase.h:41
Postsolves variable bound tightening from pseudo objective propagation.
Definition: spxmainsm.h:1223
const SVectorBase< R > & colVector(int i) const
Returns column vector of column i.
Definition: spxlpbase.h:395
void removeRow(SPxLPBase< R > &lp, int i)
removes a row in the LP.
Definition: spxmainsm.h:1399
Postsolves variable fixing.
Definition: spxmainsm.h:459
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:176
virtual const VectorBase< R > & unsimplifiedSlacks()
returns a reference to the unsimplified slack values.
Definition: spxmainsm.h:1571
friend class FreeColSingletonPS
Definition: spxmainsm.h:1272
FixBoundsPS(const SPxLPBase< R > &lp, int j, R val)
Definition: spxmainsm.h:532
R m_cutoffbound
the cutoff bound that is found by heuristics
Definition: spxmainsm.h:1335
SPxSimplifier< R >::Result simplifyRows(SPxLPBase< R > &lp, bool &again)
performs simplification steps on the rows of the LP.
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
Definition: ssvectorbase.h:34
Postsolves aggregation.
Definition: spxmainsm.h:1064
friend class FreeZeroObjVariablePS
Definition: spxmainsm.h:1270
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:1050
int m_addedcols
columns added by handleRowObjectives()
Definition: spxmainsm.h:1333
friend class ZeroObjColSingletonPS
Definition: spxmainsm.h:1271
friend class EmptyConstraintPS
Definition: spxmainsm.h:1265
FreeConstraintPS & operator=(const FreeConstraintPS &rhs)
assignment operator
Definition: spxmainsm.h:208
int nCols
number of cols
Definition: spxmainsm.h:81
DataArray< typename SPxSolverBase< R >::VarStatus > m_rBasisStat
basis status of rows.
Definition: spxmainsm.h:1314
RowObjPS(const RowObjPS &old)
copy constructor
Definition: spxmainsm.h:152
Array< DSVectorBase< R > > m_rows
Definition: spxmainsm.h:593
Array< DSVectorBase< R > > m_dupCols
arrange duplicate columns w.r.t. their pClass values
Definition: spxmainsm.h:1325
EmptyConstraintPS & operator=(const EmptyConstraintPS &rhs)
assignment operator
Definition: spxmainsm.h:257
FreeColSingletonPS(const SPxLPBase< R > &lp, SPxMainSM &simplifier, int _j, int _i, R slackVal)
Definition: spxmainsm.h:748
ZeroObjColSingletonPS(const ZeroObjColSingletonPS &old)
copy constructor
Definition: spxmainsm.h:695
R m_epsilon
epsilon zero.
Definition: spxmainsm.h:1327
VectorBase< R > m_prim
unsimplified primal solution VectorBase<R>.
Definition: spxmainsm.h:1309
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
Definition: spxlpbase.h:506
DuplicateColsPS(const SPxLPBase< R > &lp, int _j, int _k, R scale, DataArray< int > perm, bool isFirst=false, bool isTheLast=false)
Definition: spxmainsm.h:1011
virtual void getBasis(typename SPxSolverBase< R >::VarStatus rows[], typename SPxSolverBase< R >::VarStatus cols[], const int rowsSize=-1, const int colsSize=-1) const
get optimal basis.
Definition: spxmainsm.h:1595
DoubletonEquationPS & operator=(const DoubletonEquationPS &rhs)
assignment operator
Definition: spxmainsm.h:874
virtual SPxSimplifier< R >::Result result() const
returns result status of the simplification
Definition: spxmainsm.h:1548
SPxSimplifier< R >::Result aggregateVars(SPxLPBase< R > &lp, const SVectorBase< R > &row, int &i)
aggregate two variables that appear in an equation.
LP simplifier for removing uneccessary row/columns.This SPxSimplifier is mainly based on the paper "P...
Definition: spxlpbase.h:54
friend class FixVariablePS
Definition: spxmainsm.h:1268
ForceConstraintPS(const ForceConstraintPS &old)
copy constructor
Definition: spxmainsm.h:412
DataArray< typename SPxSolverBase< R >::VarStatus > m_cBasisStat
basis status of columns.
Definition: spxmainsm.h:1313
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:788