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-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 #include "soplex/spxdefines.h"
17 #include "soplex/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 
35  if(thesolver != 0)
36  if(weights.dim() != thesolver->coDim()
37  || coWeights.dim() != thesolver->dim())
38  return MSGinconsistent("SPxDevexPR");
39 
40 #endif
41 
42  return true;
43 }
44 
46 {
47  int i;
48  int coWeightSize = 0;
49  int weightSize = 0;
50 
51  DVector& weights = thesolver->weights;
52  DVector& coWeights = thesolver->coWeights;
53 
54  if(tp == SPxSolver::ENTER)
55  {
56  coWeights.reDim(thesolver->dim(), false);
57 
58  for(i = thesolver->dim() - 1; i >= coWeightSize; --i)
59  coWeights[i] = 2.0;
60 
61  weights.reDim(thesolver->coDim(), false);
62 
63  for(i = thesolver->coDim() - 1; i >= weightSize; --i)
64  weights[i] = 2.0;
65  }
66  else
67  {
68  coWeights.reDim(thesolver->dim(), false);
69 
70  for(i = thesolver->dim() - 1; i >= coWeightSize; --i)
71  coWeights[i] = 1.0;
72  }
73 
74  thesolver->weightsAreSetup = true;
75 }
76 
78 {
79  setupWeights(tp);
80  refined = false;
81 
82  bestPrices.clear();
85 
86  if(tp == SPxSolver::ENTER)
87  {
91  }
92 
93  assert(isConsistent());
94 }
95 
96 /**@todo suspicious: Shouldn't the relation between dim, coDim, Vecs,
97  * and CoVecs be influenced by the representation ?
98  */
100 {
101  if(thesolver != 0)
102  {
103  // resize weights and initialize new entries
106  assert(isConsistent());
107  }
108 }
109 
110 Real inline computePrice(Real viol, Real weight, Real tol)
111 {
112  if(weight < tol)
113  return viol * viol / tol;
114  else
115  return viol * viol / weight;
116 }
117 
118 
120 {
121  int idx;
122  int nsorted;
123  Real fTesti;
124  const Real* fTest = thesolver->fTest().get_const_ptr();
125  const Real* cpen = thesolver->coWeights.get_const_ptr();
126  IdxElement price;
127  prices.clear();
128  bestPrices.clear();
129 
130  // TODO we should check infeasiblities for duplicates or loop over dimension
131  // bestPrices may then also contain duplicates!
132  // construct vector of all prices
133  for(int i = thesolver->infeasibilities.size() - 1; i >= 0; --i)
134  {
135  idx = thesolver->infeasibilities.index(i);
136  fTesti = fTest[idx];
137 
138  if(fTesti < -feastol)
139  {
141  price.idx = idx;
142  price.val = computePrice(fTesti, cpen[idx], feastol);
143  prices.append(price);
144  }
145  }
146 
147  // set up structures for the quicksort implementation
149  // do a partial sort to move the best ones to the front
150  // TODO this can be done more efficiently, since we only need the indices
152 
153  // copy indices of best values to bestPrices
154  for(int i = 0; i < nsorted; ++i)
155  {
156  bestPrices.addIdx(prices[i].idx);
158  }
159 
160  if(nsorted > 0)
161  return prices[0].idx;
162  else
163  return -1;
164 }
165 
167 {
168  int retid;
169 
171  {
172  if(bestPrices.size() < 2 || thesolver->basis().lastUpdate() == 0)
173  {
174  // call init method to build up price-vector and return index of largest price
176  }
177  else
178  retid = selectLeaveHyper(theeps);
179  }
180  else if(thesolver->sparsePricingLeave)
181  retid = selectLeaveSparse(theeps);
182  else
183  retid = selectLeaveX(theeps);
184 
185  if(retid < 0 && !refined)
186  {
187  refined = true;
188  MSG_INFO3((*thesolver->spxout), (*thesolver->spxout) << "WDEVEX02 trying refinement step..\n";)
190  }
191 
192  assert(retid < thesolver->dim());
193 
194  return retid;
195 }
196 
197 int SPxDevexPR::selectLeaveX(Real feastol, int start, int incr)
198 {
199  Real x;
200 
201  const Real* fTest = thesolver->fTest().get_const_ptr();
202  const Real* cpen = thesolver->coWeights.get_const_ptr();
203  Real best = 0;
204  int bstI = -1;
205  int end = thesolver->coWeights.dim();
206 
207  for(; start < end; start += incr)
208  {
209  if(fTest[start] < -feastol)
210  {
211  x = computePrice(fTest[start], cpen[start], feastol);
212 
213  if(x > best)
214  {
215  best = x;
216  bstI = start;
217  last = cpen[start];
218  }
219  }
220  }
221 
222  return bstI;
223 }
224 
226 {
227  Real x;
228 
229  const Real* fTest = thesolver->fTest().get_const_ptr();
230  const Real* cpen = thesolver->coWeights.get_const_ptr();
231  Real best = 0;
232  int bstI = -1;
233  int idx = -1;
234 
235  for(int i = thesolver->infeasibilities.size() - 1; i >= 0; --i)
236  {
237  idx = thesolver->infeasibilities.index(i);
238  x = fTest[idx];
239 
240  if(x < -feastol)
241  {
242  x = computePrice(x, cpen[idx], feastol);
243 
244  if(x > best)
245  {
246  best = x;
247  bstI = idx;
248  last = cpen[idx];
249  }
250  }
251  else
252  {
254  assert(thesolver->isInfeasible[idx] == VIOLATED
257  }
258  }
259 
260  return bstI;
261 }
262 
264 {
265  Real x;
266 
267  const Real* fTest = thesolver->fTest().get_const_ptr();
268  const Real* cpen = thesolver->coWeights.get_const_ptr();
269  Real best = 0;
270  Real leastBest = infinity;
271  int bstI = -1;
272  int idx = -1;
273 
274  // find the best price from the short candidate list
275  for(int i = bestPrices.size() - 1; i >= 0; --i)
276  {
277  idx = bestPrices.index(i);
278  x = fTest[idx];
279 
280  if(x < -feastol)
281  {
282  x = computePrice(x, cpen[idx], feastol);
283 
284  if(x > best)
285  {
286  best = x;
287  bstI = idx;
288  last = cpen[idx];
289  }
290 
291  // get the smallest price of candidate list
292  if(x < leastBest)
293  leastBest = x;
294  }
295  else
296  {
297  bestPrices.remove(i);
299  }
300  }
301 
302  // make sure we do not skip potential candidates due to a high leastBest value
303  if(leastBest == infinity)
304  {
305  assert(bestPrices.size() == 0);
306  leastBest = 0;
307  }
308 
309  // scan the updated indices for a better price
310  for(int i = thesolver->updateViols.size() - 1; i >= 0; --i)
311  {
312  idx = thesolver->updateViols.index(i);
313 
314  // only look at indeces that were not checked already
315  if(thesolver->isInfeasible[idx] == VIOLATED)
316  {
317  x = fTest[idx];
318  assert(x < -feastol);
319  x = computePrice(x, cpen[idx], feastol);
320 
321  if(x > leastBest)
322  {
323  if(x > best)
324  {
325  best = x;
326  bstI = idx;
327  last = cpen[idx];
328  }
329 
330  // put index into candidate list
332  bestPrices.addIdx(idx);
333  }
334  }
335  }
336 
337  return bstI;
338 }
339 
340 void SPxDevexPR::left4(int n, SPxId id)
341 {
342  DVector& coWeights = thesolver->coWeights;
343 
344  if(id.isValid())
345  {
346  int i, j;
347  Real x;
348  const Real* rhoVec = thesolver->fVec().delta().values();
349  Real rhov_1 = 1 / rhoVec[n];
350  Real beta_q = thesolver->coPvec().delta().length2() * rhov_1 * rhov_1;
351 
352 #ifndef NDEBUG
353 
354  if(spxAbs(rhoVec[n]) < theeps)
355  {
356  MSG_INFO3((*thesolver->spxout), (*thesolver->spxout) << "WDEVEX01: rhoVec = "
357  << rhoVec[n] << " with smaller absolute value than theeps = " << theeps << std::endl;)
358  }
359 
360 #endif // NDEBUG
361 
362  // Update #coPenalty# vector
363  const IdxSet& rhoIdx = thesolver->fVec().idx();
364  int len = thesolver->fVec().idx().size();
365 
366  for(i = len - 1; i >= 0; --i)
367  {
368  j = rhoIdx.index(i);
369  x = rhoVec[j] * rhoVec[j] * beta_q;
370  // if(x > coPenalty[j])
371  coWeights[j] += x;
372  }
373 
374  coWeights[n] = beta_q;
375  }
376 }
377 
379 {
380  int idx;
381  int nsorted;
382  Real x;
383  const Real* coTest = thesolver->coTest().get_const_ptr();
384  const Real* cpen = thesolver->coWeights.get_const_ptr();
385  IdxElement price;
386  prices.clear();
387  bestPrices.clear();
388 
389  // construct vector of all prices
390  for(int i = thesolver->infeasibilities.size() - 1; i >= 0; --i)
391  {
392  idx = thesolver->infeasibilities.index(i);
393  x = coTest[idx];
394 
395  if(x < -feastol)
396  {
398  price.idx = idx;
399  price.val = computePrice(x, cpen[idx], feastol);
400  prices.append(price);
401  }
402  else
403  {
406  }
407  }
408 
409  // set up structures for the quicksort implementation
411  // do a partial sort to move the best ones to the front
412  // TODO this can be done more efficiently, since we only need the indices
414 
415  // copy indices of best values to bestPrices
416  for(int i = 0; i < nsorted; ++i)
417  {
418  bestPrices.addIdx(prices[i].idx);
420  }
421 
422  if(nsorted > 0)
423  {
424  best = prices[0].val;
425  return thesolver->coId(prices[0].idx);
426  }
427  else
428  return SPxId();
429 }
430 
432 {
433  int idx;
434  int nsorted;
435  Real x;
436  const Real* test = thesolver->test().get_const_ptr();
437  const Real* pen = thesolver->weights.get_const_ptr();
438  IdxElement price;
439  pricesCo.clear();
441 
442  // construct vector of all prices
443  for(int i = thesolver->infeasibilitiesCo.size() - 1; i >= 0; --i)
444  {
446  x = test[idx];
447 
448  if(x < -feastol)
449  {
451  price.idx = idx;
452  price.val = computePrice(x, pen[idx], feastol);
453  pricesCo.append(price);
454  }
455  else
456  {
459  }
460  }
461 
462  // set up structures for the quicksort implementation
464  // do a partial sort to move the best ones to the front
465  // TODO this can be done more efficiently, since we only need the indices
467 
468  // copy indices of best values to bestPrices
469  for(int i = 0; i < nsorted; ++i)
470  {
471  bestPricesCo.addIdx(pricesCo[i].idx);
473  }
474 
475  if(nsorted > 0)
476  {
477  best = pricesCo[0].val;
478  return thesolver->id(pricesCo[0].idx);
479  }
480  else
481  return SPxId();
482 }
483 
485 {
486  assert(thesolver != 0);
487 
488  SPxId enterId;
489 
490  enterId = selectEnterX(theeps);
491 
492  if(!enterId.isValid() && !refined)
493  {
494  refined = true;
495  MSG_INFO3((*thesolver->spxout), (*thesolver->spxout) << "WDEVEX02 trying refinement step..\n";)
496  enterId = selectEnterX(theeps / DEVEX_REFINETOL);
497  }
498 
499  return enterId;
500 }
501 
502 // choose the best entering index among columns and rows but prefer sparsity
504 {
505  SPxId enterId;
506  SPxId enterCoId;
507  Real best;
508  Real bestCo;
509 
510  best = 0;
511  bestCo = 0;
512  last = 1.0;
513 
514  // avoid uninitialized value later on in entered4X()
515  last = 1.0;
516 
518  {
519  if(bestPrices.size() < 2 || thesolver->basis().lastUpdate() == 0)
521  tol) : selectEnterDenseDim(best, tol);
522  else
523  enterCoId = (thesolver->sparsePricingEnter) ? selectEnterHyperDim(best,
524  tol) : selectEnterDenseDim(best, tol);
525 
526  if(bestPricesCo.size() < 2 || thesolver->basis().lastUpdate() == 0)
528  tol) : selectEnterDenseCoDim(bestCo, tol);
529  else
531  tol) : selectEnterDenseCoDim(bestCo, tol);
532  }
533  else
534  {
535  enterCoId = (thesolver->sparsePricingEnter
536  && !refined) ? selectEnterSparseDim(best, tol) : selectEnterDenseDim(best, tol);
537  enterId = (thesolver->sparsePricingEnterCo
538  && !refined) ? selectEnterSparseCoDim(bestCo, tol) : selectEnterDenseCoDim(bestCo, tol);
539  }
540 
541  // prefer coIds to increase the number of unit vectors in the basis matrix, i.e., rows in colrep and cols in rowrep
542  if(enterCoId.isValid() && (best > SPARSITY_TRADEOFF * bestCo || !enterId.isValid()))
543  return enterCoId;
544  else
545  return enterId;
546 }
547 
549 {
550  const Real* cTest = thesolver->coTest().get_const_ptr();
551  const Real* cpen = thesolver->coWeights.get_const_ptr();
552  Real leastBest = infinity;
553  Real x;
554  int enterIdx = -1;
555  int idx;
556 
557  // find the best price from short candidate list
558  for(int i = bestPrices.size() - 1; i >= 0; --i)
559  {
560  idx = bestPrices.index(i);
561  x = cTest[idx];
562 
563  if(x < -feastol)
564  {
565  x = computePrice(x, cpen[idx], feastol);
566 
567  if(x > best)
568  {
569  best = x;
570  enterIdx = idx;
571  last = cpen[idx];
572  }
573 
574  if(x < leastBest)
575  leastBest = x;
576  }
577  else
578  {
579  bestPrices.remove(i);
581  }
582  }
583 
584  // make sure we do not skip potential candidates due to a high leastBest value
585  if(leastBest == infinity)
586  {
587  assert(bestPrices.size() == 0);
588  leastBest = 0;
589  }
590 
591  // scan the updated indeces for a better price
592  for(int i = thesolver->updateViols.size() - 1; i >= 0; --i)
593  {
594  idx = thesolver->updateViols.index(i);
595 
596  // only look at indeces that were not checked already
597  if(thesolver->isInfeasible[idx] == VIOLATED)
598  {
599  x = cTest[idx];
600 
601  if(x < -feastol)
602  {
603  x = computePrice(x, cpen[idx], feastol);
604 
605  if(x > leastBest)
606  {
607  if(x > best)
608  {
609  best = x;
610  enterIdx = idx;
611  last = cpen[idx];
612  }
613 
614  // put index into candidate list
616  bestPrices.addIdx(idx);
617  }
618  }
619  else
620  {
622  }
623  }
624  }
625 
626  if(enterIdx >= 0)
627  return thesolver->coId(enterIdx);
628  else
629  return SPxId();
630 }
631 
632 
634 {
635  const Real* test = thesolver->test().get_const_ptr();
636  const Real* pen = thesolver->weights.get_const_ptr();
637  Real leastBest = infinity;
638  Real x;
639  int enterIdx = -1;
640  int idx;
641 
642  // find the best price from short candidate list
643  for(int i = bestPricesCo.size() - 1; i >= 0; --i)
644  {
645  idx = bestPricesCo.index(i);
646  x = test[idx];
647 
648  if(x < -feastol)
649  {
650  x = computePrice(x, pen[idx], feastol);
651 
652  if(x > best)
653  {
654  best = x;
655  enterIdx = idx;
656  last = pen[idx];
657  }
658 
659  if(x < leastBest)
660  leastBest = x;
661  }
662  else
663  {
664  bestPricesCo.remove(i);
666  }
667  }
668 
669  // make sure we do not skip potential candidates due to a high leastBest value
670  if(leastBest == infinity)
671  {
672  assert(bestPricesCo.size() == 0);
673  leastBest = 0;
674  }
675 
676  //scan the updated indeces for a better price
677  for(int i = thesolver->updateViolsCo.size() - 1; i >= 0; --i)
678  {
679  idx = thesolver->updateViolsCo.index(i);
680 
681  // only look at indeces that were not checked already
682  if(thesolver->isInfeasibleCo[idx] == VIOLATED)
683  {
684  x = test[idx];
685 
686  if(x < -feastol)
687  {
688  x = computePrice(x, pen[idx], feastol);
689 
690  if(x > leastBest)
691  {
692  if(x > best)
693  {
694  best = x;
695  enterIdx = idx;
696  last = pen[idx];
697  }
698 
699  // put index into candidate list
701  bestPricesCo.addIdx(idx);
702  }
703  }
704  else
705  {
707  }
708  }
709  }
710 
711  if(enterIdx >= 0)
712  return thesolver->id(enterIdx);
713  else
714  return SPxId();
715 }
716 
717 
719 {
720  const Real* cTest = thesolver->coTest().get_const_ptr();
721  const Real* cpen = thesolver->coWeights.get_const_ptr();
722  int enterIdx = -1;
723  int idx;
724  Real x;
725 
726  assert(thesolver->coWeights.dim() == thesolver->coTest().dim());
727 
728  for(int i = thesolver->infeasibilities.size() - 1; i >= 0; --i)
729  {
730  idx = thesolver->infeasibilities.index(i);
731  x = cTest[idx];
732 
733  if(x < -feastol)
734  {
735  x = computePrice(x, cpen[idx], feastol);
736 
737  if(x > best)
738  {
739  best = x;
740  enterIdx = idx;
741  last = cpen[idx];
742  }
743  }
744  else
745  {
748  }
749  }
750 
751  if(enterIdx >= 0)
752  return thesolver->coId(enterIdx);
753 
754  return SPxId();
755 }
756 
757 
759 {
760  const Real* test = thesolver->test().get_const_ptr();
761  const Real* pen = thesolver->weights.get_const_ptr();
762  int enterIdx = -1;
763  int idx;
764  Real x;
765 
766  assert(thesolver->weights.dim() == thesolver->test().dim());
767 
768  for(int i = thesolver->infeasibilitiesCo.size() - 1; i >= 0; --i)
769  {
771  x = test[idx];
772 
773  if(x < -feastol)
774  {
775  x = computePrice(x, pen[idx], feastol);
776 
777  if(x > best)
778  {
779  best = x;
780  enterIdx = idx;
781  last = pen[idx];
782  }
783  }
784  else
785  {
788  }
789  }
790 
791  if(enterIdx >= 0)
792  return thesolver->id(enterIdx);
793 
794  return SPxId();
795 }
796 
797 
798 SPxId SPxDevexPR::selectEnterDenseDim(Real& best, Real feastol, int start, int incr)
799 {
800  const Real* cTest = thesolver->coTest().get_const_ptr();
801  const Real* cpen = thesolver->coWeights.get_const_ptr();
802  int end = thesolver->coWeights.dim();
803  int enterIdx = -1;
804  Real x;
805 
806  assert(end == thesolver->coTest().dim());
807 
808  for(; start < end; start += incr)
809  {
810  x = cTest[start];
811 
812  if(x < -feastol)
813  {
814  x = computePrice(x, cpen[start], feastol);
815 
816  if(x > best)
817  {
818  best = x;
819  enterIdx = start;
820  last = cpen[start];
821  }
822  }
823  }
824 
825  if(enterIdx >= 0)
826  return thesolver->coId(enterIdx);
827 
828  return SPxId();
829 }
830 
831 
832 SPxId SPxDevexPR::selectEnterDenseCoDim(Real& best, Real feastol, int start, int incr)
833 {
834  const Real* test = thesolver->test().get_const_ptr();
835  const Real* pen = thesolver->weights.get_const_ptr();
836  int end = thesolver->weights.dim();
837  int enterIdx = -1;
838  Real x;
839 
840  assert(end == thesolver->test().dim());
841 
842  for(; start < end; start += incr)
843  {
844  x = test[start];
845 
846  if(test[start] < -feastol)
847  {
848  x = computePrice(x, pen[start], feastol);
849 
850  if(x > best)
851  {
852  best = x;
853  enterIdx = start;
854  last = pen[start];
855  }
856  }
857  }
858 
859  if(enterIdx >= 0)
860  return thesolver->id(enterIdx);
861 
862  return SPxId();
863 }
864 
865 
866 /**@todo suspicious: the pricer should be informed, that variable id
867  has entered the basis at position n, but the id is not used here
868  (this is true for all pricers)
869 */
870 void SPxDevexPR::entered4(SPxId /*id*/, int n)
871 {
872  DVector& weights = thesolver->weights;
873  DVector& coWeights = thesolver->coWeights;
874 
875  if(n >= 0 && n < thesolver->dim())
876  {
877  const Real* pVec = thesolver->pVec().delta().values();
878  const IdxSet& pIdx = thesolver->pVec().idx();
879  const Real* coPvec = thesolver->coPvec().delta().values();
880  const IdxSet& coPidx = thesolver->coPvec().idx();
881  Real xi_p = 1 / thesolver->fVec().delta()[n];
882  int i, j;
883 
884  assert(thesolver->fVec().delta()[n] > thesolver->epsilon()
885  || thesolver->fVec().delta()[n] < -thesolver->epsilon());
886 
887  xi_p = xi_p * xi_p * last;
888 
889  for(j = coPidx.size() - 1; j >= 0; --j)
890  {
891  i = coPidx.index(j);
892  coWeights[i] += xi_p * coPvec[i] * coPvec[i];
893 
894  if(coWeights[i] <= 1 || coWeights[i] > 1e+6)
895  {
897  return;
898  }
899  }
900 
901  for(j = pIdx.size() - 1; j >= 0; --j)
902  {
903  i = pIdx.index(j);
904  weights[i] += xi_p * pVec[i] * pVec[i];
905 
906  if(weights[i] <= 1 || weights[i] > 1e+6)
907  {
909  return;
910  }
911  }
912  }
913 }
914 
916 {
917  int initval = (thesolver->type() == SPxSolver::ENTER) ? 2 : 1;
918  DVector& weights = thesolver->weights;
919  n = weights.dim();
920  weights.reDim(thesolver->coDim());
921 
922  for(int i = weights.dim() - 1; i >= n; --i)
923  weights[i] = initval;
924 }
925 
927 {
928  int initval = (thesolver->type() == SPxSolver::ENTER) ? 2 : 1;
929  DVector& coWeights = thesolver->coWeights;
930  n = coWeights.dim();
931  coWeights.reDim(thesolver->dim());
932 
933  for(int i = coWeights.dim() - 1; i >= n; --i)
934  coWeights[i] = initval;
935 }
936 
937 } // namespace soplex
Rational spxAbs(const Rational &r)
Absolute.
Definition: rational.cpp:4102
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1117
virtual SPxId selectEnter()
Definition: spxdevexpr.cpp:484
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:253
SPxId buildBestPriceVectorEnterCoDim(Real &best, Real feastol)
Definition: spxdevexpr.cpp:431
const Vector & fTest() const
Violations of fVec.
Definition: spxsolver.h:1385
DIdxSet updateViols
store indices that were changed in the previous iteration and must be checked in hyper pricing ...
Definition: spxsolver.h:435
SPxOut * spxout
message handler
Definition: spxsolver.h:463
bool sparsePricingLeave
These values enable or disable sparse pricing.
Definition: spxsolver.h:448
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:450
Real computePrice(Real viol, Real weight, Real tol)
Definition: spxdevexpr.cpp:110
DataArray< int > isInfeasible
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:443
virtual void left4(int n, SPxId id)
Definition: spxdevexpr.cpp:340
SPxId selectEnterDenseCoDim(Real &best, Real feastol, int start=0, int incr=1)
SPxPricer::selectEnter() in dense case.
Definition: spxdevexpr.cpp:832
void clear()
removes all indices.
Definition: idxset.h:184
int lastUpdate() const
returns number of basis changes since last refactorization.
Definition: spxbasis.h:540
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1075
void clear()
remove all elements.
Definition: dataarray.h:208
SPxId buildBestPriceVectorEnterDim(Real &best, Real feastol)
build up vector of pricing values for later use
Definition: spxdevexpr.cpp:378
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:758
int buildBestPriceVectorLeave(Real feastol)
build up vector of pricing values for later use
Definition: spxdevexpr.cpp:119
const R * get_const_ptr() const
Conversion to C-style pointer.
Definition: vectorbase.h:455
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:1398
void remove(int n, int m)
removes indices at position numbers n through m.
Definition: idxset.cpp:51
DataArray< IdxElement > prices
temporary array of precomputed pricing values
Definition: spxdevexpr.h:51
double Real
Definition: spxdefines.h:218
int selectLeaveSparse(Real feastol)
implementation of sparse pricing in the leaving Simplex
Definition: spxdevexpr.cpp:225
const R * values() const
Returns array values.
Definition: ssvectorbase.h:300
virtual void setType(SPxSolver::Type)
set entering/leaving algorithm
Definition: spxdevexpr.cpp:77
virtual void setRep(SPxSolver::Representation)
set row/column representation
Definition: spxdevexpr.cpp:99
#define HYPERPRICINGSIZE
Definition: spxsolver.h:39
int size() const
returns the number of used indices.
Definition: idxset.h:124
void setupWeights(SPxSolver::Type)
set entering/leaving algorithm
Definition: spxdevexpr.cpp:45
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:1098
UpdateVector & fVec() const
feasibility vector.
Definition: spxsolver.h:1323
void addIdx(int i)
adds index i to the index set
Definition: didxset.h:79
const T * get_const_ptr() const
get a const C pointer to the data.
Definition: dataarray.h:115
DVector coWeights
store dual norms
Definition: spxsolver.h:460
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:633
bool sparsePricingEnter
true if sparsePricing is turned on in the entering Simplex for slack variables
Definition: spxsolver.h:449
const Vector & test() const
Violations of pVec.
Definition: spxsolver.h:1531
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:122
Real epsilon() const
values are considered to be 0.
Definition: spxsolver.h:784
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:85
UpdateVector & pVec() const
pricing vector.
Definition: spxsolver.h:1478
DIdxSet infeasibilities
Definition: spxsolver.h:429
R length2() const
Squared euclidian norm.
Definition: ssvectorbase.h:535
int dim() const
Dimension of vector.
Definition: vectorbase.h:217
Everything should be within this namespace.
const IdxSet & idx() const
nonzero indices of update vector
Definition: updatevector.h:133
IdxCompare compare
Definition: spxpricer.h:88
int selectLeaveHyper(Real feastol)
implementation of hyper sparse pricing in the leaving Simplex
Definition: spxdevexpr.cpp:263
virtual int selectLeave()
Definition: spxdevexpr.cpp:166
bool refined
has a refinement step already been tried?
Definition: spxdevexpr.h:55
#define SPARSITY_TRADEOFF
Definition: spxsolver.h:42
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:227
SPxId selectEnterHyperDim(Real &best, Real feastol)
implementation of hyper sparse pricing in the entering Simplex
Definition: spxdevexpr.cpp:548
Real theeps
violation bound
Definition: spxpricer.h:58
const Vector & coTest() const
violations of coPvec.
Definition: spxsolver.h:1465
int selectLeaveX(Real feastol, int start=0, int incr=1)
internal implementation of SPxPricer::selectLeave()
Definition: spxdevexpr.cpp:197
bool isValid() const
returns TRUE iff the id is a valid column or row identifier.
Definition: spxid.h:151
virtual void entered4(SPxId id, int n)
Definition: spxdevexpr.cpp:870
int size() const
return nr. of elements.
Definition: dataarray.h:214
Type type() const
return current Type.
Definition: spxsolver.h:512
DataArray< int > isInfeasibleCo
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:445
int coDim() const
codimension.
Definition: spxsolver.h:1080
bool hyperPricingEnter
true if hyper sparse pricing is turned on in the entering Simplex
Definition: spxsolver.h:452
virtual void addedCoVecs(int n)
n covectors have been added to loaded LP.
Definition: spxdevexpr.cpp:926
DVector weights
dual pricing norms
Definition: spxsolver.h:459
#define MSGinconsistent(name)
Definition: spxdefines.h:126
bool weightsAreSetup
are the dual norms already set up?
Definition: spxsolver.h:461
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:436
void reMax(int newMax=1, int newSize=-1)
reset maximum number of elements.
Definition: dataarray.h:258
SPxId selectEnterSparseDim(Real &best, Real feastol)
implementation of sparse pricing in the entering Simplex (slack variables)
Definition: spxdevexpr.cpp:718
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:798
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:1761
DIdxSet infeasibilitiesCo
Definition: spxsolver.h:432
bool hyperPricingLeave
true if hyper sparse pricing is turned on in the leaving Simplex
Definition: spxsolver.h:451
const IdxElement * elements
Definition: spxpricer.h:77
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:506
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:915
SPxId selectEnterX(Real tol)
choose the best entering index among columns and rows but prefer sparsity
Definition: spxdevexpr.cpp:503