Scippy

SoPlex

Sequential object-oriented simPlex

spxdevexpr.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2017 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 #include "spxdefines.h"
17 #include "spxdevexpr.h"
18 
19 #define DEVEX_REFINETOL 2.0
20 
21 namespace soplex
22 {
23 
25 {
26  thesolver = base;
27  setRep(base->rep());
28  assert(isConsistent());
29 }
30 
32 {
33 #ifdef ENABLE_CONSISTENCY_CHECKS
34  if (thesolver != 0)
35  if (weights.dim() != thesolver->coDim()
36  || coWeights.dim() != thesolver->dim())
37  return MSGinconsistent("SPxDevexPR");
38 #endif
39 
40  return true;
41 }
42 
44 {
45  int i;
46  if (tp == SPxSolver::ENTER)
47  {
48  for (i = weights.dim(); --i >= 0;)
49  weights[i] = 2;
50  for (i = coWeights.dim(); --i >= 0;)
51  coWeights[i] = 2;
53  {
55  {
56  bestPrices.clear();
59  }
61  {
65  }
66  }
67  }
68  else
69  {
70  for (i = coWeights.dim(); --i >= 0;)
71  coWeights[i] = 1;
73  {
74  bestPrices.clear();
77  }
78  }
79  weightsAreSetup = true;
80  assert(isConsistent());
81 }
82 
84 {
85  init(tp);
86  refined = false;
87 }
88 
89 /**@todo suspicious: Shouldn't the relation between dim, coDim, Vecs,
90  * and CoVecs be influenced by the representation ?
91  */
93 {
94  if (thesolver != 0)
95  {
98  assert(isConsistent());
99  }
100 }
101 
102 Real inline computePrice(Real viol, Real weight, Real tol)
103 {
104  if( weight < tol )
105  return viol * viol / tol;
106  else
107  return viol * viol / weight;
108 }
109 
110 
112 {
113  int idx;
114  int nsorted;
115  Real fTesti;
116  const Real* fTest = thesolver->fTest().get_const_ptr();
117  const Real* cpen = coWeights.get_const_ptr();
118  IdxElement price;
119  prices.clear();
120  bestPrices.clear();
121 
122  // TODO we should check infeasiblities for duplicates or loop over dimension
123  // bestPrices may then also contain duplicates!
124  // construct vector of all prices
125  for (int i = thesolver->infeasibilities.size() - 1; i >= 0; --i)
126  {
127  idx = thesolver->infeasibilities.index(i);
128  fTesti = fTest[idx];
129  if (fTesti < -feastol)
130  {
132  price.idx = idx;
133  price.val = computePrice(fTesti, cpen[idx], feastol);
134  prices.append(price);
135  }
136  }
137  // set up structures for the quicksort implementation
139  // do a partial sort to move the best ones to the front
140  // TODO this can be done more efficiently, since we only need the indices
142  // copy indices of best values to bestPrices
143  for( int i = 0; i < nsorted; ++i )
144  {
145  bestPrices.addIdx(prices[i].idx);
147  }
148 
149  if( nsorted > 0 )
150  return prices[0].idx;
151  else
152  return -1;
153 }
154 
156 {
157  int retid;
158 
160  {
161  if ( bestPrices.size() < 2 || thesolver->basis().lastUpdate() == 0 )
162  {
163  // call init method to build up price-vector and return index of largest price
165  }
166  else
167  retid = selectLeaveHyper(theeps);
168  }
169  else if (thesolver->sparsePricingLeave)
170  retid = selectLeaveSparse(theeps);
171  else
172  retid = selectLeaveX(theeps);
173 
174  if ( retid < 0 && !refined )
175  {
176  refined = true;
177  MSG_INFO3( (*thesolver->spxout), (*thesolver->spxout) << "WDEVEX02 trying refinement step..\n"; )
179  }
180 
181  assert(retid < thesolver->dim());
182 
183  return retid;
184 }
185 
186 int SPxDevexPR::selectLeaveX(Real feastol, int start, int incr)
187 {
188  Real x;
189 
190  const Real* fTest = thesolver->fTest().get_const_ptr();
191  const Real* cpen = coWeights.get_const_ptr();
192  Real best = 0;
193  int bstI = -1;
194  int end = coWeights.dim();
195 
196  for (; start < end; start += incr)
197  {
198  if (fTest[start] < -feastol)
199  {
200  x = computePrice(fTest[start], cpen[start], feastol);
201  if (x > best)
202  {
203  best = x;
204  bstI = start;
205  last = cpen[start];
206  }
207  }
208  }
209  return bstI;
210 }
211 
213 {
214  Real x;
215 
216  const Real* fTest = thesolver->fTest().get_const_ptr();
217  const Real* cpen = coWeights.get_const_ptr();
218  Real best = 0;
219  int bstI = -1;
220  int idx = -1;
221 
222  for (int i = thesolver->infeasibilities.size() - 1; i >= 0; --i)
223  {
224  idx = thesolver->infeasibilities.index(i);
225  x = fTest[idx];
226  if (x < -feastol)
227  {
228  x = computePrice(x, cpen[idx], feastol);
229  if (x > best)
230  {
231  best = x;
232  bstI = idx;
233  last = cpen[idx];
234  }
235  }
236  else
237  {
241  }
242  }
243  return bstI;
244 }
245 
247 {
248  Real x;
249 
250  const Real* fTest = thesolver->fTest().get_const_ptr();
251  const Real* cpen = coWeights.get_const_ptr();
252  Real best = 0;
253  Real leastBest = infinity;
254  int bstI = -1;
255  int idx = -1;
256 
257  // find the best price from the short candidate list
258  for( int i = bestPrices.size() - 1; i >= 0; --i )
259  {
260  idx = bestPrices.index(i);
261  x = fTest[idx];
262  if( x < -feastol )
263  {
264  x = computePrice(x, cpen[idx], feastol);
265  if( x > best )
266  {
267  best = x;
268  bstI = idx;
269  last = cpen[idx];
270  }
271  // get the smallest price of candidate list
272  if( x < leastBest )
273  leastBest = x;
274  }
275  else
276  {
277  bestPrices.remove(i);
279  }
280  }
281 
282  // make sure we do not skip potential candidates due to a high leastBest value
283  if( leastBest == infinity )
284  {
285  assert(bestPrices.size() == 0);
286  leastBest = 0;
287  }
288 
289  // scan the updated indices for a better price
290  for( int i = thesolver->updateViols.size() - 1; i >= 0; --i )
291  {
292  idx = thesolver->updateViols.index(i);
293  // only look at indeces that were not checked already
294  if( thesolver->isInfeasible[idx] == VIOLATED )
295  {
296  x = fTest[idx];
297  assert(x < -feastol);
298  x = computePrice(x, cpen[idx], feastol);
299  if( x > leastBest )
300  {
301  if( x > best )
302  {
303  best = x;
304  bstI = idx;
305  last = cpen[idx];
306  }
307  // put index into candidate list
309  bestPrices.addIdx(idx);
310  }
311  }
312  }
313 
314  return bstI;
315 }
316 
317 void SPxDevexPR::left4(int n, SPxId id)
318 {
319  if (id.isValid())
320  {
321  int i, j;
322  Real x;
323  const Real* rhoVec = thesolver->fVec().delta().values();
324  Real rhov_1 = 1 / rhoVec[n];
325  Real beta_q = thesolver->coPvec().delta().length2() * rhov_1 * rhov_1;
326 
327 #ifndef NDEBUG
328  if (spxAbs(rhoVec[n]) < theeps)
329  {
330  MSG_INFO3( (*thesolver->spxout), (*thesolver->spxout) << "WDEVEX01: rhoVec = "
331  << rhoVec[n] << " with smaller absolute value than theeps = " << theeps << std::endl; )
332  }
333 #endif // NDEBUG
334 
335  // Update #coPenalty# vector
336  const IdxSet& rhoIdx = thesolver->fVec().idx();
337  int len = thesolver->fVec().idx().size();
338  for (i = len - 1; i >= 0; --i)
339  {
340  j = rhoIdx.index(i);
341  x = rhoVec[j] * rhoVec[j] * beta_q;
342  // if(x > coPenalty[j])
343  coWeights[j] += x;
344  }
345 
346  coWeights[n] = beta_q;
347  }
348 }
349 
351 {
352  int idx;
353  int nsorted;
354  Real x;
355  const Real* coTest = thesolver->coTest().get_const_ptr();
356  const Real* cpen = coWeights.get_const_ptr();
357  IdxElement price;
358  prices.clear();
359  bestPrices.clear();
360 
361  // construct vector of all prices
362  for (int i = thesolver->infeasibilities.size() - 1; i >= 0; --i)
363  {
364  idx = thesolver->infeasibilities.index(i);
365  x = coTest[idx];
366  if ( x < -feastol)
367  {
369  price.idx = idx;
370  price.val = computePrice(x, cpen[idx], feastol);
371  prices.append(price);
372  }
373  else
374  {
377  }
378  }
379  // set up structures for the quicksort implementation
381  // do a partial sort to move the best ones to the front
382  // TODO this can be done more efficiently, since we only need the indices
384  // copy indices of best values to bestPrices
385  for( int i = 0; i < nsorted; ++i )
386  {
387  bestPrices.addIdx(prices[i].idx);
389  }
390 
391  if( nsorted > 0 )
392  {
393  best = prices[0].val;
394  return thesolver->coId(prices[0].idx);
395  }
396  else
397  return SPxId();
398 }
399 
401 {
402  int idx;
403  int nsorted;
404  Real x;
405  const Real* test = thesolver->test().get_const_ptr();
406  const Real* pen = weights.get_const_ptr();
407  IdxElement price;
408  pricesCo.clear();
410 
411  // construct vector of all prices
412  for (int i = thesolver->infeasibilitiesCo.size() - 1; i >= 0; --i)
413  {
415  x = test[idx];
416  if ( x < -feastol)
417  {
419  price.idx = idx;
420  price.val = computePrice(x, pen[idx], feastol);
421  pricesCo.append(price);
422  }
423  else
424  {
427  }
428  }
429  // set up structures for the quicksort implementation
431  // do a partial sort to move the best ones to the front
432  // TODO this can be done more efficiently, since we only need the indices
434  // copy indices of best values to bestPrices
435  for( int i = 0; i < nsorted; ++i )
436  {
437  bestPricesCo.addIdx(pricesCo[i].idx);
439  }
440 
441  if( nsorted > 0 )
442  {
443  best = pricesCo[0].val;
444  return thesolver->id(pricesCo[0].idx);
445  }
446  else
447  return SPxId();
448 }
449 
451 {
452  assert(thesolver != 0);
453 
454  SPxId enterId;
455 
456  enterId = selectEnterX(theeps);
457 
458  if( !enterId.isValid() && !refined )
459  {
460  refined = true;
461  MSG_INFO3( (*thesolver->spxout), (*thesolver->spxout) << "WDEVEX02 trying refinement step..\n"; )
463  }
464 
465  return enterId;
466 }
467 
468 // choose the best entering index among columns and rows but prefer sparsity
470 {
471  SPxId enterId;
472  SPxId enterCoId;
473  Real best;
474  Real bestCo;
475 
476  best = 0;
477  bestCo = 0;
478  last = 1.0;
479 
480  // avoid uninitialized value later on in entered4X()
481  last = 1.0;
482 
484  {
485  if( bestPrices.size() < 2 || thesolver->basis().lastUpdate() == 0 )
486  enterCoId = (thesolver->sparsePricingEnter) ? buildBestPriceVectorEnterDim(best, tol) : selectEnterDenseDim(best, tol);
487  else
488  enterCoId = (thesolver->sparsePricingEnter) ? selectEnterHyperDim(best, tol) : selectEnterDenseDim(best, tol);
489 
490  if( bestPricesCo.size() < 2 || thesolver->basis().lastUpdate() == 0 )
491  enterId = (thesolver->sparsePricingEnterCo) ? buildBestPriceVectorEnterCoDim(bestCo, tol) : selectEnterDenseCoDim(bestCo, tol);
492  else
493  enterId = (thesolver->sparsePricingEnterCo) ? selectEnterHyperCoDim(bestCo, tol) : selectEnterDenseCoDim(bestCo, tol);
494  }
495  else
496  {
497  enterCoId = (thesolver->sparsePricingEnter && !refined) ? selectEnterSparseDim(best, tol) : selectEnterDenseDim(best, tol);
498  enterId = (thesolver->sparsePricingEnterCo && !refined) ? selectEnterSparseCoDim(bestCo, tol) : selectEnterDenseCoDim(bestCo, tol);
499  }
500 
501  // prefer coIds to increase the number of unit vectors in the basis matrix, i.e., rows in colrep and cols in rowrep
502  if( enterCoId.isValid() && (best > SPARSITY_TRADEOFF * bestCo || !enterId.isValid()) )
503  return enterCoId;
504  else
505  return enterId;
506 }
507 
509 {
510  const Real* cTest = thesolver->coTest().get_const_ptr();
511  const Real* cpen = coWeights.get_const_ptr();
512  Real leastBest = infinity;
513  Real x;
514  int enterIdx = -1;
515  int idx;
516 
517  // find the best price from short candidate list
518  for( int i = bestPrices.size() - 1; i >= 0; --i )
519  {
520  idx = bestPrices.index(i);
521  x = cTest[idx];
522  if( x < -feastol )
523  {
524  x = computePrice(x, cpen[idx], feastol);
525  if( x > best )
526  {
527  best = x;
528  enterIdx = idx;
529  last = cpen[idx];
530  }
531  if( x < leastBest )
532  leastBest = x;
533  }
534  else
535  {
536  bestPrices.remove(i);
538  }
539  }
540 
541  // make sure we do not skip potential candidates due to a high leastBest value
542  if( leastBest == infinity )
543  {
544  assert(bestPrices.size() == 0);
545  leastBest = 0;
546  }
547 
548  // scan the updated indeces for a better price
549  for( int i = thesolver->updateViols.size() -1; i >= 0; --i )
550  {
551  idx = thesolver->updateViols.index(i);
552  // only look at indeces that were not checked already
553  if( thesolver->isInfeasible[idx] == VIOLATED )
554  {
555  x = cTest[idx];
556  if( x < -feastol )
557  {
558  x = computePrice(x, cpen[idx], feastol);
559  if(x > leastBest)
560  {
561  if( x > best )
562  {
563  best = x;
564  enterIdx = idx;
565  last = cpen[idx];
566  }
567  // put index into candidate list
569  bestPrices.addIdx(idx);
570  }
571  }
572  else
573  {
575  }
576  }
577  }
578 
579  if (enterIdx >= 0)
580  return thesolver->coId(enterIdx);
581  else
582  return SPxId();
583 }
584 
585 
587 {
588  const Real* test = thesolver->test().get_const_ptr();
589  const Real* pen = weights.get_const_ptr();
590  Real leastBest = infinity;
591  Real x;
592  int enterIdx = -1;
593  int idx;
594 
595  // find the best price from short candidate list
596  for( int i = bestPricesCo.size() - 1; i >= 0; --i )
597  {
598  idx = bestPricesCo.index(i);
599  x = test[idx];
600  if( x < -feastol )
601  {
602  x = computePrice(x, pen[idx], feastol);
603  if( x > best )
604  {
605  best = x;
606  enterIdx = idx;
607  last = pen[idx];
608  }
609  if( x < leastBest )
610  leastBest = x;
611  }
612  else
613  {
614  bestPricesCo.remove(i);
616  }
617  }
618  // make sure we do not skip potential candidates due to a high leastBest value
619  if( leastBest == infinity )
620  {
621  assert(bestPricesCo.size() == 0);
622  leastBest = 0;
623  }
624 
625  //scan the updated indeces for a better price
626  for( int i = thesolver->updateViolsCo.size() -1; i >= 0; --i )
627  {
628  idx = thesolver->updateViolsCo.index(i);
629  // only look at indeces that were not checked already
630  if( thesolver->isInfeasibleCo[idx] == VIOLATED )
631  {
632  x = test[idx];
633  if( x < -feastol )
634  {
635  x = computePrice(x, pen[idx], feastol);
636  if( x > leastBest )
637  {
638  if( x > best )
639  {
640  best = x;
641  enterIdx = idx;
642  last = pen[idx];
643  }
644  // put index into candidate list
646  bestPricesCo.addIdx(idx);
647  }
648  }
649  else
650  {
652  }
653  }
654  }
655 
656  if( enterIdx >= 0 )
657  return thesolver->id(enterIdx);
658  else
659  return SPxId();
660 }
661 
662 
664 {
665  const Real* cTest = thesolver->coTest().get_const_ptr();
666  const Real* cpen = coWeights.get_const_ptr();
667  int enterIdx = -1;
668  int idx;
669  Real x;
670 
671  assert(coWeights.dim() == thesolver->coTest().dim());
672  for(int i = thesolver->infeasibilities.size() -1; i >= 0; --i)
673  {
674  idx = thesolver->infeasibilities.index(i);
675  x = cTest[idx];
676  if( x < -feastol )
677  {
678  x = computePrice(x, cpen[idx], feastol);
679  if (x > best)
680  {
681  best = x;
682  enterIdx = idx;
683  last = cpen[idx];
684  }
685  }
686  else
687  {
690  }
691  }
692  if (enterIdx >= 0)
693  return thesolver->coId(enterIdx);
694 
695  return SPxId();
696 }
697 
698 
700 {
701  const Real* test = thesolver->test().get_const_ptr();
702  const Real* pen = weights.get_const_ptr();
703  int enterIdx = -1;
704  int idx;
705  Real x;
706 
707  assert(weights.dim() == thesolver->test().dim());
708  for (int i = thesolver->infeasibilitiesCo.size() -1; i >= 0; --i)
709  {
711  x = test[idx];
712  if (x < -feastol)
713  {
714  x = computePrice(x, pen[idx], feastol);
715  if (x > best)
716  {
717  best = x;
718  enterIdx = idx;
719  last = pen[idx];
720  }
721  }
722  else
723  {
726  }
727  }
728 
729  if (enterIdx >= 0)
730  return thesolver->id(enterIdx);
731 
732  return SPxId();
733 }
734 
735 
736 SPxId SPxDevexPR::selectEnterDenseDim(Real& best, Real feastol, int start, int incr)
737 {
738  const Real* cTest = thesolver->coTest().get_const_ptr();
739  const Real* cpen = coWeights.get_const_ptr();
740  int end = coWeights.dim();
741  int enterIdx = -1;
742  Real x;
743 
744  assert(end == thesolver->coTest().dim());
745  for (; start < end; start += incr)
746  {
747  x = cTest[start];
748  if( x < -feastol )
749  {
750  x = computePrice(x, cpen[start], feastol);
751  if (x > best)
752  {
753  best = x;
754  enterIdx = start;
755  last = cpen[start];
756  }
757  }
758  }
759 
760  if (enterIdx >= 0)
761  return thesolver->coId(enterIdx);
762 
763  return SPxId();
764 }
765 
766 
767 SPxId SPxDevexPR::selectEnterDenseCoDim(Real& best, Real feastol, int start, int incr)
768 {
769  const Real* test = thesolver->test().get_const_ptr();
770  const Real* pen = weights.get_const_ptr();
771  int end = weights.dim();
772  int enterIdx = -1;
773  Real x;
774 
775  assert(end == thesolver->test().dim());
776  for (; start < end; start += incr)
777  {
778  x = test[start];
779  if (test[start] < -feastol)
780  {
781  x = computePrice(x, pen[start], feastol);
782  if (x > best)
783  {
784  best = x;
785  enterIdx = start;
786  last = pen[start];
787  }
788  }
789  }
790 
791  if (enterIdx >= 0)
792  return thesolver->id(enterIdx);
793 
794  return SPxId();
795 }
796 
797 
798 /**@todo suspicious: the pricer should be informed, that variable id
799  has entered the basis at position n, but the id is not used here
800  (this is true for all pricers)
801 */
802 void SPxDevexPR::entered4(SPxId /*id*/, int n)
803 {
804  if (n >= 0 && n < thesolver->dim())
805  {
806  const Real* pVec = thesolver->pVec().delta().values();
807  const IdxSet& pIdx = thesolver->pVec().idx();
808  const Real* coPvec = thesolver->coPvec().delta().values();
809  const IdxSet& coPidx = thesolver->coPvec().idx();
810  Real xi_p = 1 / thesolver->fVec().delta()[n];
811  int i, j;
812 
813  assert(thesolver->fVec().delta()[n] > thesolver->epsilon()
814  || thesolver->fVec().delta()[n] < -thesolver->epsilon());
815 
816  xi_p = xi_p * xi_p * last;
817 
818  for (j = coPidx.size() - 1; j >= 0; --j)
819  {
820  i = coPidx.index(j);
821  coWeights[i] += xi_p * coPvec[i] * coPvec[i];
822  if (coWeights[i] <= 1 || coWeights[i] > 1e+6)
823  {
825  return;
826  }
827  }
828 
829  for (j = pIdx.size() - 1; j >= 0; --j)
830  {
831  i = pIdx.index(j);
832  weights[i] += xi_p * pVec[i] * pVec[i];
833  if (weights[i] <= 1 || weights[i] > 1e+6)
834  {
836  return;
837  }
838  }
839  }
840 }
841 
843 {
844  int initval = (thesolver->type() == SPxSolver::ENTER) ? 2 : 1;
845  n = weights.dim();
847  for (int i = weights.dim()-1; i >= n; --i )
848  weights[i] = initval;
849 }
850 
852 {
853  int initval = (thesolver->type() == SPxSolver::ENTER) ? 2 : 1;
854  n = coWeights.dim();
856  for (int i = coWeights.dim()-1; i >= n; --i)
857  coWeights[i] = initval;
858 }
859 
860 } // namespace soplex
Rational spxAbs(const Rational &r)
Absolute.
Definition: rational.cpp:3909
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1089
virtual SPxId selectEnter()
Definition: spxdevexpr.cpp:450
DIdxSet bestPricesCo
set of best pricing candidates
Definition: spxdevexpr.h:54
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:249
SPxId buildBestPriceVectorEnterCoDim(Real &best, Real feastol)
Definition: spxdevexpr.cpp:400
const Vector & fTest() const
Violations of fVec.
Definition: spxsolver.h:1357
DIdxSet updateViols
store indices that were changed in the previous iteration and must be checked in hyper pricing ...
Definition: spxsolver.h:406
SPxOut * spxout
message handler
Definition: spxsolver.h:427
bool sparsePricingLeave
These values enable or disable sparse pricing.
Definition: spxsolver.h:417
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
Type
Algorithmic type.
Definition: spxsolver.h:124
DataArray< IdxElement > pricesCo
temporary array of precomputed pricing values
Definition: spxdevexpr.h:52
virtual bool isConsistent() const
consistency check
Definition: spxdevexpr.cpp:31
#define DEVEX_REFINETOL
Definition: spxdevexpr.cpp:19
T * get_ptr()
get a C pointer to the data.
Definition: dataarray.h:110
Representation
LP basis representation.
Definition: spxsolver.h:105
bool sparsePricingEnterCo
true if sparsePricing is turned on in the entering Simplex
Definition: spxsolver.h:419
Real computePrice(Real viol, Real weight, Real tol)
Definition: spxdevexpr.cpp:102
DVector weights
vector to store pricing weights or norms
Definition: spxpricer.h:60
DataArray< int > isInfeasible
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:413
virtual void left4(int n, SPxId id)
Definition: spxdevexpr.cpp:317
SPxId selectEnterDenseCoDim(Real &best, Real feastol, int start=0, int incr=1)
SPxPricer::selectEnter() in dense case.
Definition: spxdevexpr.cpp:767
void clear()
removes all indices.
Definition: idxset.h:184
void init(SPxSolver::Type)
set entering/leaving algorithm
Definition: spxdevexpr.cpp:43
int lastUpdate() const
returns number of basis changes since last refactorization.
Definition: spxbasis.h:539
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1047
void clear()
remove all elements.
Definition: dataarray.h:205
SPxId buildBestPriceVectorEnterDim(Real &best, Real feastol)
build up vector of pricing values for later use
Definition: spxdevexpr.cpp:350
Devex pricer.
Real last
penalty, selected at last iteration.
Definition: spxdevexpr.h:50
SPxId selectEnterSparseCoDim(Real &best, Real feastol)
implementation of sparse pricing in the entering Simplex
Definition: spxdevexpr.cpp:699
bool weightsAreSetup
are the weights already set up?
Definition: spxpricer.h:63
int buildBestPriceVectorLeave(Real feastol)
build up vector of pricing values for later use
Definition: spxdevexpr.cpp:111
const R * get_const_ptr() const
Conversion to C-style pointer.
Definition: vectorbase.h:453
Entering Simplex.
Definition: spxsolver.h:134
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
UpdateVector & coPvec() const
copricing vector.
Definition: spxsolver.h:1370
void remove(int n, int m)
removes indices at position numbers n through m.
Definition: idxset.cpp:49
DataArray< IdxElement > prices
temporary array of precomputed pricing values
Definition: spxdevexpr.h:51
double Real
Definition: spxdefines.h:215
int selectLeaveSparse(Real feastol)
implementation of sparse pricing in the leaving Simplex
Definition: spxdevexpr.cpp:212
const R * values() const
Returns array values.
Definition: ssvectorbase.h:299
virtual void setType(SPxSolver::Type)
set entering/leaving algorithm
Definition: spxdevexpr.cpp:83
virtual void setRep(SPxSolver::Representation)
set row/column representation
Definition: spxdevexpr.cpp:92
#define HYPERPRICINGSIZE
Definition: spxsolver.h:38
int size() const
returns the number of used indices.
Definition: idxset.h:124
void append(const T &t)
append element t.
Definition: dataarray.h:121
SPxId id(int i) const
id of i &#39;th vector.
Definition: spxsolver.h:1070
UpdateVector & fVec() const
feasibility vector.
Definition: spxsolver.h:1295
void addIdx(int i)
adds index i to the index set
Definition: didxset.h:75
const T * get_const_ptr() const
get a const C pointer to the data.
Definition: dataarray.h:115
SPxSolver * thesolver
the solver
Definition: spxpricer.h:56
SPxId selectEnterHyperCoDim(Real &best, Real feastol)
implementation of hyper sparse pricing in the entering Simplex
Definition: spxdevexpr.cpp:586
bool sparsePricingEnter
true if sparsePricing is turned on in the entering Simplex for slack variables
Definition: spxsolver.h:418
const Vector & test() const
Violations of pVec.
Definition: spxsolver.h:1503
DIdxSet bestPrices
set of best pricing candidates
Definition: spxdevexpr.h:53
#define MSG_INFO3(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO3.
Definition: spxdefines.h:119
Real epsilon() const
values are considered to be 0.
Definition: spxsolver.h:758
Debugging, floating point type and parameter definitions.
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:84
UpdateVector & pVec() const
pricing vector.
Definition: spxsolver.h:1450
DIdxSet infeasibilities
Definition: spxsolver.h:400
R length2() const
Squared euclidian norm.
Definition: ssvectorbase.h:531
int dim() const
Dimension of vector.
Definition: vectorbase.h:215
Everything should be within this namespace.
const IdxSet & idx() const
nonzero indices of update vector
Definition: updatevector.h:133
IdxCompare compare
Definition: spxpricer.h:93
int selectLeaveHyper(Real feastol)
implementation of hyper sparse pricing in the leaving Simplex
Definition: spxdevexpr.cpp:246
virtual int selectLeave()
Definition: spxdevexpr.cpp:155
bool refined
has a refinement step already been tried?
Definition: spxdevexpr.h:55
DVector coWeights
Definition: spxpricer.h:61
#define SPARSITY_TRADEOFF
Definition: spxsolver.h:41
int SPxQuicksortPart(T *keys, COMPARATOR &compare, int start, int end, int size, int start2=0, int end2=0, bool type=true)
Generic implementation of Partial QuickSort.
Definition: sorter.h:219
SPxId selectEnterHyperDim(Real &best, Real feastol)
implementation of hyper sparse pricing in the entering Simplex
Definition: spxdevexpr.cpp:508
Real theeps
violation bound
Definition: spxpricer.h:58
const Vector & coTest() const
violations of coPvec.
Definition: spxsolver.h:1437
int selectLeaveX(Real feastol, int start=0, int incr=1)
internal implementation of SPxPricer::selectLeave()
Definition: spxdevexpr.cpp:186
bool isValid() const
returns TRUE iff the id is a valid column or row identifier.
Definition: spxid.h:150
virtual void entered4(SPxId id, int n)
Definition: spxdevexpr.cpp:802
int size() const
return nr. of elements.
Definition: dataarray.h:211
Type type() const
return current Type.
Definition: spxsolver.h:475
DataArray< int > isInfeasibleCo
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:414
int coDim() const
codimension.
Definition: spxsolver.h:1052
bool hyperPricingEnter
true if hyper sparse pricing is turned on in the entering Simplex
Definition: spxsolver.h:421
virtual void addedCoVecs(int n)
n covectors have been added to loaded LP.
Definition: spxdevexpr.cpp:851
#define MSGinconsistent(name)
Definition: spxdefines.h:123
virtual void load(SPxSolver *base)
sets the solver
Definition: spxdevexpr.cpp:24
SSVector & delta()
update vector , writeable
Definition: updatevector.h:122
DIdxSet updateViolsCo
Definition: spxsolver.h:407
void reMax(int newMax=1, int newSize=-1)
reset maximum number of elements.
Definition: dataarray.h:254
SPxId selectEnterSparseDim(Real &best, Real feastol)
implementation of sparse pricing in the entering Simplex (slack variables)
Definition: spxdevexpr.cpp:663
int index(int n) const
access n &#39;th index.
Definition: idxset.h:118
SPxId selectEnterDenseDim(Real &best, Real feastol, int start=0, int incr=1)
SPxPricer::selectEnter() in dense case (slack variabels)
Definition: spxdevexpr.cpp:736
void setMax(int newmax=1)
sets the maximum number of indices.
Definition: didxset.cpp:22
const SPxBasis & basis() const
Return current basis.
Definition: spxsolver.h:1727
DIdxSet infeasibilitiesCo
Definition: spxsolver.h:403
bool hyperPricingLeave
true if hyper sparse pricing is turned on in the leaving Simplex
Definition: spxsolver.h:420
const IdxElement * elements
Definition: spxpricer.h:82
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:469
Set of indices.Class IdxSet provides a set of indices. At construction it must be given an array of i...
Definition: idxset.h:56
virtual void addedVecs(int n)
n vectors have been added to loaded LP.
Definition: spxdevexpr.cpp:842
SPxId selectEnterX(Real tol)
choose the best entering index among columns and rows but prefer sparsity
Definition: spxdevexpr.cpp:469