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-2022 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, DSVectorBase<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  int r = m_col.index(k);
613 
614  if((m_loFree && m_col.value(k) > 0) ||
615  (!m_loFree && m_col.value(k) < 0))
616  m_lRhs.add(k, lp.rhs(r));
617  else
618  m_lRhs.add(k, lp.lhs(r));
619 
620  m_rows[k] = lp.rowVector(r);
621  m_rowObj.add(k, lp.rowObj(r));
622  }
623  }
624  /// copy constructor
626  : PostStep(old)
627  , m_j(old.m_j)
628  , m_old_j(old.m_old_j)
629  , m_old_i(old.m_old_i)
630  , m_bnd(old.m_bnd)
631  , m_col(old.m_col)
632  , m_lRhs(old.m_lRhs)
633  , m_rowObj(old.m_rowObj)
634  , m_rows(old.m_rows)
635  , m_loFree(old.m_loFree)
636  {}
637  /// assignment operator
639  {
640  if(this != &rhs)
641  {
642  PostStep::operator=(rhs);
643  m_col = rhs.m_col;
644  m_lRhs = rhs.m_lRhs;
645  m_rowObj = rhs.m_rowObj;
646  m_rows = rhs.m_rows;
647  }
648 
649  return *this;
650  }
651  /// clone function for polymorphism
652  inline virtual PostStep* clone() const
653  {
654  FreeZeroObjVariablePS* FreeZeroObjVariablePSptr = 0;
655  spx_alloc(FreeZeroObjVariablePSptr);
656  return new(FreeZeroObjVariablePSptr) FreeZeroObjVariablePS(*this);
657  }
658  ///
659  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
660  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
661  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
662  };
663 
664  /**@brief Postsolves column singletons with zero objective.
665  @ingroup Algo
666  */
668  {
669  private:
670  const int m_j;
671  const int m_i;
672  const int m_old_j;
673  const R m_lhs;
674  const R m_rhs;
675  const R m_lower;
676  const R m_upper;
678 
679  public:
680  ///
681  ZeroObjColSingletonPS(const SPxLPBase<R>& lp, const SPxMainSM&, int _j, int _i)
682  : PostStep("ZeroObjColSingleton", lp.nRows(), lp.nCols())
683  , m_j(_j)
684  , m_i(_i)
685  , m_old_j(lp.nCols() - 1)
686  , m_lhs(lp.lhs(_i))
687  , m_rhs(lp.rhs(_i))
688  , m_lower(lp.lower(_j))
689  , m_upper(lp.upper(_j))
690  , m_row(lp.rowVector(_i))
691  {}
692  /// copy constructor
694  : PostStep(old)
695  , m_j(old.m_j)
696  , m_i(old.m_i)
697  , m_old_j(old.m_old_j)
698  , m_lhs(old.m_lhs)
699  , m_rhs(old.m_rhs)
700  , m_lower(old.m_lower)
701  , m_upper(old.m_upper)
702  , m_row(old.m_row)
703  {}
704  /// assignment operator
706  {
707  if(this != &rhs)
708  {
709  PostStep::operator=(rhs);
710  m_row = rhs.m_row;
711  }
712 
713  return *this;
714  }
715  /// clone function for polymorphism
716  inline virtual PostStep* clone() const
717  {
718  ZeroObjColSingletonPS* ZeroObjColSingletonPSptr = 0;
719  spx_alloc(ZeroObjColSingletonPSptr);
720  return new(ZeroObjColSingletonPSptr) ZeroObjColSingletonPS(*this);
721  }
722  ///
723  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
724  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
725  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
726  };
727 
728  /**@brief Postsolves free column singletons.
729  @ingroup Algo
730  */
732  {
733  private:
734  const int m_j;
735  const int m_i;
736  const int m_old_j;
737  const int m_old_i;
738  const R m_obj;
739  const R m_lRhs;
740  const bool m_onLhs;
741  const bool m_eqCons;
743 
744  public:
745  ///
746  FreeColSingletonPS(const SPxLPBase<R>& lp, SPxMainSM& simplifier, int _j, int _i, R slackVal)
747  : PostStep("FreeColSingleton", lp.nRows(), lp.nCols())
748  , m_j(_j)
749  , m_i(_i)
750  , m_old_j(lp.nCols() - 1)
751  , m_old_i(lp.nRows() - 1)
752  , m_obj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
753  , m_lRhs(slackVal)
754  , m_onLhs(EQ(slackVal, lp.lhs(_i)))
755  , m_eqCons(EQ(lp.lhs(_i), lp.rhs(_i)))
756  , m_row(lp.rowVector(_i))
757  {
758  assert(m_row[m_j] != 0.0);
759  simplifier.addObjoffset(m_lRhs * (lp.obj(m_j) / m_row[m_j]));
760  }
761  /// copy constructor
763  : PostStep(old)
764  , m_j(old.m_j)
765  , m_i(old.m_i)
766  , m_old_j(old.m_old_j)
767  , m_old_i(old.m_old_i)
768  , m_obj(old.m_obj)
769  , m_lRhs(old.m_lRhs)
770  , m_onLhs(old.m_onLhs)
771  , m_eqCons(old.m_eqCons)
772  , m_row(old.m_row)
773  {}
774  /// assignment operator
776  {
777  if(this != &rhs)
778  {
779  PostStep::operator=(rhs);
780  m_row = rhs.m_row;
781  }
782 
783  return *this;
784  }
785  /// clone function for polymorphism
786  inline virtual PostStep* clone() const
787  {
788  FreeColSingletonPS* FreeColSingletonPSptr = 0;
789  spx_alloc(FreeColSingletonPSptr);
790  return new(FreeColSingletonPSptr) FreeColSingletonPS(*this);
791  }
792  ///
793  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
794  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
795  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
796  };
797 
798  /**@brief Postsolves doubleton equations combined with a column singleton.
799  @ingroup Algo
800  */
802  {
803  private:
804  const int m_j;
805  const int m_k;
806  const int m_i;
807  const bool m_maxSense;
808  const bool m_jFixed;
809  const R m_jObj;
810  const R m_kObj;
811  const R m_aij;
812  const bool m_strictLo;
813  const bool m_strictUp;
814  const R m_newLo;
815  const R m_newUp;
816  const R m_oldLo;
817  const R m_oldUp;
818  const R m_Lo_j;
819  const R m_Up_j;
820  const R m_lhs;
821  const R m_rhs;
823 
824  public:
825  ///
826  DoubletonEquationPS(const SPxLPBase<R>& lp, int _j, int _k, int _i, R oldLo, R oldUp)
827  : PostStep("DoubletonEquation", lp.nRows(), lp.nCols())
828  , m_j(_j)
829  , m_k(_k)
830  , m_i(_i)
831  , m_maxSense(lp.spxSense() == SPxLPBase<R>::MAXIMIZE)
832  , m_jFixed(EQ(lp.lower(_j), lp.upper(_j)))
833  , m_jObj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
834  , m_kObj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_k) : -lp.obj(_k))
835  , m_aij(lp.colVector(_j).value(0))
836  , m_strictLo(lp.lower(_k) > oldLo)
837  , m_strictUp(lp.upper(_k) < oldUp)
838  , m_newLo(lp.lower(_k))
839  , m_newUp(lp.upper(_k))
840  , m_oldLo(oldLo)
841  , m_oldUp(oldUp)
842  , m_Lo_j(lp.lower(_j))
843  , m_Up_j(lp.upper(_j))
844  , m_lhs(lp.lhs(_i))
845  , m_rhs(lp.rhs(_i))
846  , m_col(lp.colVector(_k))
847  {}
848  /// copy constructor
850  : PostStep(old)
851  , m_j(old.m_j)
852  , m_k(old.m_k)
853  , m_i(old.m_i)
854  , m_maxSense(old.m_maxSense)
855  , m_jFixed(old.m_jFixed)
856  , m_jObj(old.m_jObj)
857  , m_kObj(old.m_kObj)
858  , m_aij(old.m_aij)
859  , m_strictLo(old.m_strictLo)
860  , m_strictUp(old.m_strictUp)
861  , m_newLo(old.m_newLo)
862  , m_newUp(old.m_newUp)
863  , m_oldLo(old.m_oldLo)
864  , m_oldUp(old.m_oldUp)
865  , m_Lo_j(old.m_Lo_j)
866  , m_Up_j(old.m_Up_j)
867  , m_lhs(old.m_lhs)
868  , m_rhs(old.m_rhs)
869  , m_col(old.m_col)
870  {}
871  /// assignment operator
873  {
874  if(this != &rhs)
875  {
876  PostStep::operator=(rhs);
877  m_col = rhs.m_col;
878  }
879 
880  return *this;
881  }
882  /// clone function for polymorphism
883  inline virtual PostStep* clone() const
884  {
885  DoubletonEquationPS* DoubletonEquationPSptr = 0;
886  spx_alloc(DoubletonEquationPSptr);
887  return new(DoubletonEquationPSptr) DoubletonEquationPS(*this);
888  }
889  ///
890  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
891  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
892  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
893  };
894 
895  /**@brief Postsolves duplicate rows.
896  @ingroup Algo
897  */
898  class DuplicateRowsPS : public PostStep
899  {
900  private:
901  const int m_i;
902  const R m_i_rowObj;
903  const int m_maxLhsIdx;
904  const int m_minRhsIdx;
905  const bool m_maxSense;
906  const bool m_isFirst;
907  const bool m_isLast;
908  const bool m_fixed;
909  const int m_nCols;
915 
916  public:
917  DuplicateRowsPS(const SPxLPBase<R>& lp, int _i,
918  int maxLhsIdx, int minRhsIdx, const DSVectorBase<R>& dupRows,
919  const Array<R> scale, const DataArray<int> perm, const DataArray<bool> isLhsEqualRhs,
920  bool isTheLast, bool isFixedRow, bool isFirst = false)
921  : PostStep("DuplicateRows", lp.nRows(), lp.nCols())
922  , m_i(_i)
923  , m_i_rowObj(lp.rowObj(_i))
924  , m_maxLhsIdx((maxLhsIdx == -1) ? -1 : maxLhsIdx)
925  , m_minRhsIdx((minRhsIdx == -1) ? -1 : minRhsIdx)
926  , m_maxSense(lp.spxSense() == SPxLPBase<R>::MAXIMIZE)
927  , m_isFirst(isFirst)
928  , m_isLast(isTheLast)
929  , m_fixed(isFixedRow)
930  , m_nCols(lp.nCols())
931  , m_scale(dupRows.size())
932  , m_rowObj(dupRows.size())
933  , m_rIdxLocalOld(dupRows.size())
934  , m_perm(perm)
935  , m_isLhsEqualRhs(isLhsEqualRhs)
936  {
937  R rowScale = scale[_i];
938 
939  for(int k = 0; k < dupRows.size(); ++k)
940  {
941  m_scale.add(dupRows.index(k), rowScale / scale[dupRows.index(k)]);
942  m_rowObj.add(dupRows.index(k), lp.rowObj(dupRows.index(k)));
943  m_rIdxLocalOld[k] = dupRows.index(k);
944  }
945  }
946  /// copy constructor
948  : PostStep(old)
949  , m_i(old.m_i)
950  , m_i_rowObj(old.m_i_rowObj)
951  , m_maxLhsIdx(old.m_maxLhsIdx)
952  , m_minRhsIdx(old.m_minRhsIdx)
953  , m_maxSense(old.m_maxSense)
954  , m_isFirst(old.m_isFirst)
955  , m_isLast(old.m_isLast)
956  , m_fixed(old.m_fixed)
957  , m_nCols(old.m_nCols)
958  , m_scale(old.m_scale)
959  , m_rowObj(old.m_rowObj)
960  , m_rIdxLocalOld(old.m_rIdxLocalOld)
961  , m_perm(old.m_perm)
962  , m_isLhsEqualRhs(old.m_isLhsEqualRhs)
963  {}
964  /// assignment operator
966  {
967  if(this != &rhs)
968  {
969  PostStep::operator=(rhs);
970  m_scale = rhs.m_scale;
971  m_rowObj = rhs.m_rowObj;
972  m_rIdxLocalOld = rhs.m_rIdxLocalOld;
973  m_perm = rhs.m_perm;
974  m_isLhsEqualRhs = rhs.m_isLhsEqualRhs;
975  }
976 
977  return *this;
978  }
979  /// clone function for polymorphism
980  inline virtual PostStep* clone() const
981  {
982  DuplicateRowsPS* DuplicateRowsPSptr = 0;
983  spx_alloc(DuplicateRowsPSptr);
984  return new(DuplicateRowsPSptr) DuplicateRowsPS(*this);
985  }
986  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
987  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
988  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
989  };
990 
991  /**@brief Postsolves duplicate columns.
992  @ingroup Algo
993  */
994  class DuplicateColsPS : public PostStep
995  {
996  private:
997  const int m_j;
998  const int m_k;
999  const R m_loJ;
1000  const R m_upJ;
1001  const R m_loK;
1002  const R m_upK;
1003  const R m_scale;
1004  const bool m_isFirst;
1005  const bool m_isLast;
1007 
1008  public:
1009  DuplicateColsPS(const SPxLPBase<R>& lp, int _j, int _k, R scale, DataArray<int> perm,
1010  bool isFirst = false, bool isTheLast = false)
1011  : PostStep("DuplicateCols", lp.nRows(), lp.nCols())
1012  , m_j(_j)
1013  , m_k(_k)
1014  , m_loJ(lp.lower(_j))
1015  , m_upJ(lp.upper(_j))
1016  , m_loK(lp.lower(_k))
1017  , m_upK(lp.upper(_k))
1018  , m_scale(scale)
1019  , m_isFirst(isFirst)
1020  , m_isLast(isTheLast)
1021  , m_perm(perm)
1022  {}
1023  /// copy constructor
1025  : PostStep(old)
1026  , m_j(old.m_j)
1027  , m_k(old.m_k)
1028  , m_loJ(old.m_loJ)
1029  , m_upJ(old.m_upJ)
1030  , m_loK(old.m_loK)
1031  , m_upK(old.m_upK)
1032  , m_scale(old.m_scale)
1033  , m_isFirst(old.m_isFirst)
1034  , m_isLast(old.m_isLast)
1035  , m_perm(old.m_perm)
1036  {}
1037  /// assignment operator
1039  {
1040  if(this != &rhs)
1041  {
1042  PostStep::operator=(rhs);
1043  }
1044 
1045  return *this;
1046  }
1047  /// clone function for polymorphism
1048  inline virtual PostStep* clone() const
1049  {
1050  DuplicateColsPS* DuplicateColsPSptr = 0;
1051  spx_alloc(DuplicateColsPSptr);
1052  return new(DuplicateColsPSptr) DuplicateColsPS(*this);
1053  }
1054  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
1055  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
1056  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
1057  };
1058 
1059  /**@brief Postsolves aggregation.
1060  @ingroup Algo
1061  */
1062  class AggregationPS : public PostStep
1063  {
1064  private:
1065  const int m_j;
1066  const int m_i;
1067  const int m_old_j;
1068  const int m_old_i;
1069  const R m_upper;
1070  const R m_lower;
1071  const R m_obj;
1072  const R m_oldupper;
1073  const R m_oldlower;
1074  const R m_rhs;
1077 
1078  public:
1079  ///
1080  AggregationPS(const SPxLPBase<R>& lp, int _i, int _j, R rhs, R oldupper, R oldlower)
1081  : PostStep("Aggregation", lp.nRows(), lp.nCols())
1082  , m_j(_j)
1083  , m_i(_i)
1084  , m_old_j(lp.nCols() - 1)
1085  , m_old_i(lp.nRows() - 1)
1086  , m_upper(lp.upper(_j))
1087  , m_lower(lp.lower(_j))
1088  , m_obj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
1089  , m_oldupper(oldupper)
1090  , m_oldlower(oldlower)
1091  , m_rhs(rhs)
1092  , m_row(lp.rowVector(_i))
1093  , m_col(lp.colVector(_j))
1094  {
1095  assert(m_row[m_j] != 0.0);
1096  }
1097  /// copy constructor
1099  : PostStep(old)
1100  , m_j(old.m_j)
1101  , m_i(old.m_i)
1102  , m_old_j(old.m_old_j)
1103  , m_old_i(old.m_old_i)
1104  , m_upper(old.m_upper)
1105  , m_lower(old.m_lower)
1106  , m_obj(old.m_obj)
1107  , m_oldupper(old.m_oldupper)
1108  , m_oldlower(old.m_oldlower)
1109  , m_rhs(old.m_rhs)
1110  , m_row(old.m_row)
1111  , m_col(old.m_col)
1112  {}
1113  /// assignment operator
1115  {
1116  if(this != &rhs)
1117  {
1118  PostStep::operator=(rhs);
1119  m_row = rhs.m_row;
1120  m_col = rhs.m_col;
1121  }
1122 
1123  return *this;
1124  }
1125  /// clone function for polymorphism
1126  inline virtual PostStep* clone() const
1127  {
1128  AggregationPS* AggregationPSptr = 0;
1129  spx_alloc(AggregationPSptr);
1130  return new(AggregationPSptr) AggregationPS(*this);
1131  }
1132  ///
1133  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
1134  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
1135  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
1136  };
1137 
1138  /**@brief Postsolves multi aggregation.
1139  @ingroup Algo
1140  */
1142  {
1143  private:
1144  const int m_j;
1145  const int m_i;
1146  const int m_old_j;
1147  const int m_old_i;
1148  const R m_upper;
1149  const R m_lower;
1150  const R m_obj;
1151  const R m_const;
1152  const bool m_onLhs;
1153  const bool m_eqCons;
1156 
1157  public:
1158  ///
1159  MultiAggregationPS(const SPxLPBase<R>& lp, SPxMainSM& simplifier, int _i, int _j, R constant)
1160  : PostStep("MultiAggregation", lp.nRows(), lp.nCols())
1161  , m_j(_j)
1162  , m_i(_i)
1163  , m_old_j(lp.nCols() - 1)
1164  , m_old_i(lp.nRows() - 1)
1165  , m_upper(lp.upper(_j))
1166  , m_lower(lp.lower(_j))
1167  , m_obj(lp.spxSense() == SPxLPBase<R>::MINIMIZE ? lp.obj(_j) : -lp.obj(_j))
1168  , m_const(constant)
1169  , m_onLhs(EQ(constant, lp.lhs(_i)))
1170  , m_eqCons(EQ(lp.lhs(_i), lp.rhs(_i)))
1171  , m_row(lp.rowVector(_i))
1172  , m_col(lp.colVector(_j))
1173  {
1174  assert(m_row[m_j] != 0.0);
1175  simplifier.addObjoffset(m_obj * m_const / m_row[m_j]);
1176  }
1177  /// copy constructor
1179  : PostStep(old)
1180  , m_j(old.m_j)
1181  , m_i(old.m_i)
1182  , m_old_j(old.m_old_j)
1183  , m_old_i(old.m_old_i)
1184  , m_upper(old.m_upper)
1185  , m_lower(old.m_lower)
1186  , m_obj(old.m_obj)
1187  , m_const(old.m_const)
1188  , m_onLhs(old.m_onLhs)
1189  , m_eqCons(old.m_eqCons)
1190  , m_row(old.m_row)
1191  , m_col(old.m_col)
1192  {}
1193  /// assignment operator
1195  {
1196  if(this != &rhs)
1197  {
1198  PostStep::operator=(rhs);
1199  m_row = rhs.m_row;
1200  m_col = rhs.m_col;
1201  }
1202 
1203  return *this;
1204  }
1205  /// clone function for polymorphism
1206  inline virtual PostStep* clone() const
1207  {
1208  MultiAggregationPS* MultiAggregationPSptr = 0;
1209  spx_alloc(MultiAggregationPSptr);
1210  return new(MultiAggregationPSptr) MultiAggregationPS(*this);
1211  }
1212  ///
1213  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
1214  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
1215  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
1216  };
1217 
1218  /**@brief Postsolves variable bound tightening from pseudo objective propagation.
1219  @ingroup Algo
1220  */
1221  class TightenBoundsPS : public PostStep
1222  {
1223  private:
1224  const int m_j;
1225  const R m_origupper;
1226  const R m_origlower;
1227 
1228  public:
1229  ///
1230  TightenBoundsPS(const SPxLPBase<R>& lp, int j, R origupper, R origlower)
1231  : PostStep("TightenBounds", lp.nRows(), lp.nCols())
1232  , m_j(j)
1233  , m_origupper(origupper)
1234  , m_origlower(origlower)
1235  {
1236  }
1237  /// copy constructor
1239  : PostStep(old)
1240  , m_j(old.m_j)
1241  , m_origupper(old.m_origupper)
1242  , m_origlower(old.m_origlower)
1243  {}
1244  /// assignment operator
1246  {
1247  return *this;
1248  }
1249  /// clone function for polymorphism
1250  inline virtual PostStep* clone() const
1251  {
1252  TightenBoundsPS* TightenBoundsPSptr = 0;
1253  spx_alloc(TightenBoundsPSptr);
1254  return new(TightenBoundsPSptr) TightenBoundsPS(*this);
1255  }
1256  ///
1257  virtual void execute(VectorBase<R>& x, VectorBase<R>& y, VectorBase<R>& s, VectorBase<R>& r,
1258  DataArray<typename SPxSolverBase<R>::VarStatus>& cBasis,
1259  DataArray<typename SPxSolverBase<R>::VarStatus>& rBasis, bool isOptimal) const;
1260  };
1261  // friends
1262  friend class FreeConstraintPS;
1263  friend class EmptyConstraintPS;
1264  friend class RowSingletonPS;
1265  friend class ForceConstraintPS;
1266  friend class FixVariablePS;
1267  friend class FixBoundsPS;
1270  friend class FreeColSingletonPS;
1271  friend class DoubletonEquationPS;
1272  friend class DuplicateRowsPS;
1273  friend class DuplicateColsPS;
1274  friend class AggregationPS;
1275 
1276 private:
1277  //------------------------------------
1278  ///@name Types
1279  ///@{
1280  /// Different simplification steps.
1282  {
1288  FIX_COL = 5,
1300  };
1301  ///@}
1302 
1303  //------------------------------------
1304  ///@name Data
1305  ///@{
1306  ///
1307  VectorBase<R> m_prim; ///< unsimplified primal solution VectorBase<R>.
1308  VectorBase<R> m_slack; ///< unsimplified slack VectorBase<R>.
1309  VectorBase<R> m_dual; ///< unsimplified dual solution VectorBase<R>.
1310  VectorBase<R> m_redCost; ///< unsimplified reduced cost VectorBase<R>.
1313  DataArray<int> m_cIdx; ///< column index VectorBase<R> in original LP.
1314  DataArray<int> m_rIdx; ///< row index VectorBase<R> in original LP.
1315  Array<std::shared_ptr<PostStep>>m_hist; ///< VectorBase<R> of presolve history.
1317  m_classSetRows; ///< stores parallel classes with non-zero colum entry
1319  m_classSetCols; ///< stores parallel classes with non-zero row entry
1321  m_dupRows; ///< arrange duplicate rows using bucket sort w.r.t. their pClass values
1323  m_dupCols; ///< arrange duplicate columns w.r.t. their pClass values
1324  bool m_postsolved; ///< status of postsolving.
1325  R m_epsilon; ///< epsilon zero.
1326  R m_feastol; ///< primal feasibility tolerance.
1327  R m_opttol; ///< dual feasibility tolerance.
1328  DataArray<int> m_stat; ///< preprocessing history.
1329  typename SPxLPBase<R>::SPxSense m_thesense; ///< optimization sense.
1330  bool m_keepbounds; ///< keep some bounds (for boundflipping)
1331  int m_addedcols; ///< columns added by handleRowObjectives()
1332  typename SPxSimplifier<R>::Result m_result; ///< result of the simplification.
1333  R m_cutoffbound; ///< the cutoff bound that is found by heuristics
1334  R m_pseudoobj; ///< the pseudo objective function value
1335  ///@}
1336 
1337 private:
1338  //------------------------------------
1339  ///@name Private helpers
1340  ///@{
1341  /// handle row objectives
1343 
1344  /// handles extreme values by setting them to zero or R(infinity).
1345  void handleExtremes(SPxLPBase<R>& lp);
1346 
1347  /// computes the minimum and maximum residual activity for a given row and column. If colNumber is set to -1, then
1348  // the activity of the row is returned.
1349  void computeMinMaxResidualActivity(SPxLPBase<R>& lp, int rowNumber, int colNumber, R& minAct,
1350  R& maxAct);
1351 
1352  /// calculate min/max value for the multi aggregated variables
1353  void computeMinMaxValues(SPxLPBase<R>& lp, R side, R val, R minRes, R maxRes, R& minVal, R& maxVal);
1354 
1355  /// tries to find good lower bound solutions by applying some trivial heuristics
1356  void trivialHeuristic(SPxLPBase<R>& lp);
1357 
1358  /// checks a solution for feasibility
1359  bool checkSolution(SPxLPBase<R>& lp, VectorBase<R> sol);
1360 
1361  /// tightens variable bounds by propagating the pseudo objective function value.
1362  void propagatePseudoobj(SPxLPBase<R>& lp);
1363 
1364  /// removed empty rows and empty columns.
1366 
1367  /// remove row singletons.
1369  int& i);
1370 
1371  /// aggregate two variables that appear in an equation.
1373  int& i);
1374 
1375  /// performs simplification steps on the rows of the LP.
1376  typename SPxSimplifier<R>::Result simplifyRows(SPxLPBase<R>& lp, bool& again);
1377 
1378  /// performs simplification steps on the columns of the LP.
1379  typename SPxSimplifier<R>::Result simplifyCols(SPxLPBase<R>& lp, bool& again);
1380 
1381  /// performs simplification steps on the LP based on dual concepts.
1382  typename SPxSimplifier<R>::Result simplifyDual(SPxLPBase<R>& lp, bool& again);
1383 
1384  /// performs multi-aggregations of variable based upon constraint activitu.
1385  typename SPxSimplifier<R>::Result multiaggregation(SPxLPBase<R>& lp, bool& again);
1386 
1387  /// removes duplicate rows.
1388  typename SPxSimplifier<R>::Result duplicateRows(SPxLPBase<R>& lp, bool& again);
1389 
1390  /// removes duplicate columns
1391  typename SPxSimplifier<R>::Result duplicateCols(SPxLPBase<R>& lp, bool& again);
1392 
1393  /// handles the fixing of a variable. correctIdx is true iff the index mapping has to be updated.
1394  void fixColumn(SPxLPBase<R>& lp, int i, bool correctIdx = true);
1395 
1396  /// removes a row in the LP.
1397  void removeRow(SPxLPBase<R>& lp, int i)
1398  {
1399  m_rIdx[i] = m_rIdx[lp.nRows() - 1];
1400  lp.removeRow(i);
1401  }
1402  /// removes a column in the LP.
1403  void removeCol(SPxLPBase<R>& lp, int j)
1404  {
1405  m_cIdx[j] = m_cIdx[lp.nCols() - 1];
1406  lp.removeCol(j);
1407  }
1408  /// returns for a given row index of the (reduced) LP the corresponding row index in the unsimplified LP.
1409  int rIdx(int i) const
1410  {
1411  return m_rIdx[i];
1412  }
1413  /// returns for a given column index of the (reduced) LP the corresponding column index in the unsimplified LP.
1414  int cIdx(int j) const
1415  {
1416  return m_cIdx[j];
1417  }
1418  ///@}
1419 
1420 protected:
1421 
1422  ///
1423  R epsZero() const
1424  {
1425  return m_epsilon;
1426  }
1427  ///
1428  R feastol() const
1429  {
1430  return m_feastol;
1431  }
1432  ///
1433  R opttol() const
1434  {
1435  return m_opttol;
1436  }
1437 
1438 public:
1439 
1440  //------------------------------------
1441  ///@name Constructors / destructors
1442  ///@{
1443  /// default constructor.
1445  : SPxSimplifier<R>("MainSM", ttype)
1446  , m_postsolved(0)
1447  , m_epsilon(DEFAULT_EPS_ZERO)
1448  , m_feastol(DEFAULT_BND_VIOL)
1449  , m_opttol(DEFAULT_BND_VIOL)
1450  , m_stat(16)
1451  , m_thesense(SPxLPBase<R>::MAXIMIZE)
1452  , m_keepbounds(false)
1453  , m_addedcols(0)
1454  , m_result(this->OKAY)
1455  , m_cutoffbound(R(-infinity))
1456  , m_pseudoobj(R(-infinity))
1457  {}
1458  /// copy constructor.
1459  SPxMainSM(const SPxMainSM& old)
1460  : SPxSimplifier<R>(old)
1461  , m_prim(old.m_prim)
1462  , m_slack(old.m_slack)
1463  , m_dual(old.m_dual)
1464  , m_redCost(old.m_redCost)
1465  , m_cBasisStat(old.m_cBasisStat)
1466  , m_rBasisStat(old.m_rBasisStat)
1467  , m_cIdx(old.m_cIdx)
1468  , m_rIdx(old.m_rIdx)
1469  , m_hist(old.m_hist)
1470  , m_postsolved(old.m_postsolved)
1471  , m_epsilon(old.m_epsilon)
1472  , m_feastol(old.m_feastol)
1473  , m_opttol(old.m_opttol)
1474  , m_stat(old.m_stat)
1475  , m_thesense(old.m_thesense)
1476  , m_keepbounds(old.m_keepbounds)
1477  , m_addedcols(old.m_addedcols)
1478  , m_result(old.m_result)
1479  , m_cutoffbound(old.m_cutoffbound)
1480  , m_pseudoobj(old.m_pseudoobj)
1481  {
1482  ;
1483  }
1484  /// assignment operator
1486  {
1487  if(this != &rhs)
1488  {
1490  m_prim = rhs.m_prim;
1491  m_slack = rhs.m_slack;
1492  m_dual = rhs.m_dual;
1493  m_redCost = rhs.m_redCost;
1494  m_cBasisStat = rhs.m_cBasisStat;
1495  m_rBasisStat = rhs.m_rBasisStat;
1496  m_cIdx = rhs.m_cIdx;
1497  m_rIdx = rhs.m_rIdx;
1498  m_postsolved = rhs.m_postsolved;
1499  m_epsilon = rhs.m_epsilon;
1500  m_feastol = rhs.m_feastol;
1501  m_opttol = rhs.m_opttol;
1502  m_stat = rhs.m_stat;
1503  m_thesense = rhs.m_thesense;
1504  m_keepbounds = rhs.m_keepbounds;
1505  m_addedcols = rhs.m_addedcols;
1506  m_result = rhs.m_result;
1507  m_cutoffbound = rhs.m_cutoffbound;
1508  m_pseudoobj = rhs.m_pseudoobj;
1509  m_hist = rhs.m_hist;
1510  }
1511 
1512 
1513  return *this;
1514  }
1515  /// destructor.
1516  virtual ~SPxMainSM()
1517  {
1518  ;
1519  }
1520  /// clone function for polymorphism
1521  inline virtual SPxSimplifier<R>* clone() const
1522  {
1523  return new SPxMainSM(*this);
1524  }
1525  ///@}
1526 
1527  //------------------------------------
1528  //**@name LP simplification */
1529  ///@{
1530  /// simplify SPxLPBase<R> \p lp with identical primal and dual feasibility tolerance.
1531  virtual typename SPxSimplifier<R>::Result simplify(SPxLPBase<R>& lp, R eps, R delta,
1532  Real remainingTime)
1533  {
1534  return simplify(lp, eps, delta, delta, remainingTime);
1535  }
1536  /// simplify SPxLPBase<R> \p lp with independent primal and dual feasibility tolerance.
1537  virtual typename SPxSimplifier<R>::Result simplify(SPxLPBase<R>& lp, R eps, R ftol, R otol,
1538  Real remainingTime,
1539  bool keepbounds = false, uint32_t seed = 0);
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:1141
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:1178
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:1262
DataArray< int > m_stat
preprocessing history.
Definition: spxmainsm.h:1328
virtual SPxSimplifier< R >::Result simplify(SPxLPBase< R > &lp, R eps, R delta, Real remainingTime)
simplify SPxLPBase<R> lp with identical primal and dual feasibility tolerance.
Definition: spxmainsm.h:1531
Sparse vector nonzero element.
Definition: svectorbase.h:37
ZeroObjColSingletonPS & operator=(const ZeroObjColSingletonPS &rhs)
assignment operator
Definition: spxmainsm.h:705
PostStep & operator=(const PostStep &)
assignment operator
Definition: spxmainsm.h:99
SPxMainSM(Timer::TYPE ttype=Timer::USER_TIME)
Definition: spxmainsm.h:1444
SPxLPBase< R >::SPxSense m_thesense
optimization sense.
Definition: spxmainsm.h:1329
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:1403
#define DEFAULT_BND_VIOL
default allowed bound violation
Definition: spxdefines.h:264
virtual SPxSimplifier< R > * clone() const
clone function for polymorphism
Definition: spxmainsm.h:1521
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:1114
ZeroObjColSingletonPS(const SPxLPBase< R > &lp, const SPxMainSM &, int _j, int _i)
Definition: spxmainsm.h:681
R opttol() const
Definition: spxmainsm.h:1433
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:898
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:826
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:1485
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:1272
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:1326
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:1414
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:1327
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
DuplicateRowsPS & operator=(const DuplicateRowsPS &rhs)
assignment operator
Definition: spxmainsm.h:965
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:762
bool m_postsolved
status of postsolving.
Definition: spxmainsm.h:1324
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:1409
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:1206
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:1080
FreeZeroObjVariablePS & operator=(const FreeZeroObjVariablePS &rhs)
assignment operator
Definition: spxmainsm.h:638
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:1126
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:1310
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:652
friend class RowSingletonPS
Definition: spxmainsm.h:1264
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:1245
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:883
double Real
Definition: spxdefines.h:256
Array< std::shared_ptr< PostStep > > m_hist
VectorBase<R> of presolve history.
Definition: spxmainsm.h:1315
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:1194
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:716
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:1038
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:225
R feastol() const
Definition: spxmainsm.h:1428
R rowObj(int i) const
Definition: spxlpbase.h:300
friend class DoubletonEquationPS
Definition: spxmainsm.h:1271
Array< DSVectorBase< R > > m_classSetCols
stores parallel classes with non-zero row entry
Definition: spxmainsm.h:1319
SPxMainSM(const SPxMainSM &old)
copy constructor.
Definition: spxmainsm.h:1459
FixVariablePS & operator=(const FixVariablePS &rhs)
assignment operator
Definition: spxmainsm.h:500
Postsolves doubleton equations combined with a column singleton.
Definition: spxmainsm.h:801
Postsolves free column singletons.
Definition: spxmainsm.h:731
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:1317
SPxSimplifier< R >::Result m_result
result of the simplification.
Definition: spxmainsm.h:1332
#define DEFAULT_EPS_ZERO
default allowed additive zero: 1.0 + EPS_ZERO == 1.0
Definition: spxdefines.h:268
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:1250
const VectorBase< R > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:273
friend class FixBoundsPS
Definition: spxmainsm.h:1267
DataArray< int > m_cIdx
column index VectorBase<R> in original LP.
Definition: spxmainsm.h:1313
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.
FreeZeroObjVariablePS(const SPxLPBase< R > &lp, int _j, bool loFree, DSVectorBase< R > col_idx_sorted)
Definition: spxmainsm.h:598
DuplicateColsPS(const DuplicateColsPS &old)
copy constructor
Definition: spxmainsm.h:1024
R m_pseudoobj
the pseudo objective function value
Definition: spxmainsm.h:1334
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:947
DoubletonEquationPS(const DoubletonEquationPS &old)
copy constructor
Definition: spxmainsm.h:849
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:917
MultiAggregationPS(const SPxLPBase< R > &lp, SPxMainSM &simplifier, int _i, int _j, R constant)
Definition: spxmainsm.h:1159
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:1314
Postsolves column singletons with zero objective.
Definition: spxmainsm.h:667
TightenBoundsPS(const TightenBoundsPS &old)
copy constructor
Definition: spxmainsm.h:1238
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:1423
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:1330
Array< DSVectorBase< R > > m_dupRows
arrange duplicate rows using bucket sort w.r.t. their pClass values
Definition: spxmainsm.h:1321
Everything should be within this namespace.
AggregationPS(const AggregationPS &old)
copy constructor
Definition: spxmainsm.h:1098
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:1265
VectorBase< R > m_slack
unsimplified slack VectorBase<R>.
Definition: spxmainsm.h:1308
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:1516
friend class AggregationPS
Definition: spxmainsm.h:1274
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:1309
Save arrays of arbitrary types.
SPxSimplifier< R >::Result removeEmpty(SPxLPBase< R > &lp)
removed empty rows and empty columns.
friend class DuplicateColsPS
Definition: spxmainsm.h:1273
FreeZeroObjVariablePS(const FreeZeroObjVariablePS &old)
copy constructor
Definition: spxmainsm.h:625
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:1230
FreeColSingletonPS & operator=(const FreeColSingletonPS &rhs)
assignment operator
Definition: spxmainsm.h:775
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:994
DataArray< bool > m_isLhsEqualRhs
Definition: spxmainsm.h:914
int size() const
return nr. of elements.
Definition: dataarray.h:218
Postsolves forcing constraints.
Definition: spxmainsm.h:366
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:980
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:1221
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:1397
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:1270
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:1333
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:1062
friend class FreeZeroObjVariablePS
Definition: spxmainsm.h:1268
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:1048
int m_addedcols
columns added by handleRowObjectives()
Definition: spxmainsm.h:1331
friend class ZeroObjColSingletonPS
Definition: spxmainsm.h:1269
friend class EmptyConstraintPS
Definition: spxmainsm.h:1263
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:1312
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:1323
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:746
ZeroObjColSingletonPS(const ZeroObjColSingletonPS &old)
copy constructor
Definition: spxmainsm.h:693
R m_epsilon
epsilon zero.
Definition: spxmainsm.h:1325
VectorBase< R > m_prim
unsimplified primal solution VectorBase<R>.
Definition: spxmainsm.h:1307
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:1009
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:872
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:1266
ForceConstraintPS(const ForceConstraintPS &old)
copy constructor
Definition: spxmainsm.h:412
DataArray< typename SPxSolverBase< R >::VarStatus > m_cBasisStat
basis status of columns.
Definition: spxmainsm.h:1311
virtual PostStep * clone() const
clone function for polymorphism
Definition: spxmainsm.h:786