Scippy

SoPlex

Sequential object-oriented simPlex

spxshift.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 <assert.h>
17 #include <iostream>
18 
19 #include "spxdefines.h"
20 #include "spxsolver.h"
21 #include "spxout.h"
22 
23 namespace soplex
24 {
26 {
27 
28  /* the allowed tolerance is (rep() == COLUMN) ? feastol() : opttol() because theFvec is the primal vector in COLUMN
29  * and the dual vector in ROW representation; this is equivalent to entertol()
30  */
31  Real minrandom = 10.0 * entertol();
32  Real maxrandom = 100.0 * entertol();
33  Real allow = entertol() - epsilon();
34 
35  assert(type() == ENTER);
36  assert(allow > 0);
37 
38  for (int i = dim() - 1; i >= 0; --i)
39  {
40  if (theUBbound[i] + allow < (*theFvec)[i])
41  {
42  MSG_DEBUG( std::cout << "DSHIFT08 theUBbound[" << i << "] violated by " << (*theFvec)[i] - theUBbound[i] - allow << std::endl );
43 
44  if (theUBbound[i] != theLBbound[i])
45  shiftUBbound(i, (*theFvec)[i] + random.next(minrandom, maxrandom));
46  else
47  {
48  shiftUBbound(i, (*theFvec)[i]);
49  theLBbound[i] = theUBbound[i];
50  }
51  }
52  else if ((*theFvec)[i] < theLBbound[i] - allow)
53  {
54  MSG_DEBUG( std::cout << "DSHIFT08 theLBbound[" << i << "] violated by " << theLBbound[i] - (*theFvec)[i] - allow << std::endl );
55 
56  if (theUBbound[i] != theLBbound[i])
57  shiftLBbound(i, (*theFvec)[i] - random.next(minrandom, maxrandom));
58  else
59  {
60  shiftLBbound(i, (*theFvec)[i]);
61  theUBbound[i] = theLBbound[i];
62  }
63  }
64  }
65 
66 #ifndef NDEBUG
67  testBounds();
68  MSG_DEBUG( std::cout << "DSHIFT01 shiftFvec: OK" << std::endl; )
69 #endif
70 }
71 
72 // -----------------------------------------------------------------
73 
74 /*
75  This methods assumes correctly setup vectors |pVec| and |coPvec| and bound
76  vectors for leaving simplex. Then it checks all values of |pVec| and
77  |coPvec| to obey these bounds and enlarges them if neccessary.
78  */
80 {
81 
82  /* the allowed tolerance is (rep() == ROW) ? feastol() : opttol() because thePvec is the primal vector in ROW and the
83  * dual vector in COLUMN representation; this is equivalent to leavetol()
84  */
85  Real minrandom = 10.0 * leavetol();
86  Real maxrandom = 100.0 * leavetol();
87  Real allow = leavetol() - epsilon();
88  bool tmp;
89  int i;
90 
91  assert(type() == LEAVE);
92  assert(allow > 0.0);
93 
94  for (i = dim() - 1; i >= 0; --i)
95  {
96  tmp = !isBasic(coId(i));
97  if ((*theCoUbound)[i] + allow <= (*theCoPvec)[i] && tmp)
98  {
99  if ((*theCoUbound)[i] != (*theCoLbound)[i])
100  shiftUCbound(i, (*theCoPvec)[i] + random.next(minrandom,maxrandom));
101  else
102  {
103  shiftUCbound(i, (*theCoPvec)[i]);
104  (*theCoLbound)[i] = (*theCoUbound)[i];
105  }
106  }
107  else if ((*theCoLbound)[i] - allow >= (*theCoPvec)[i] && tmp)
108  {
109  if ((*theCoUbound)[i] != (*theCoLbound)[i])
110  shiftLCbound(i, (*theCoPvec)[i] - random.next(minrandom,maxrandom));
111  else
112  {
113  shiftLCbound(i, (*theCoPvec)[i]);
114  (*theCoUbound)[i] = (*theCoLbound)[i];
115  }
116  }
117  }
118 
119  for (i = coDim() - 1; i >= 0; --i)
120  {
121  tmp = !isBasic(id(i));
122  if ((*theUbound)[i] + allow <= (*thePvec)[i] && tmp)
123  {
124  if ((*theUbound)[i] != (*theLbound)[i])
125  shiftUPbound(i, (*thePvec)[i] + random.next(minrandom,maxrandom));
126  else
127  {
128  shiftUPbound(i, (*thePvec)[i]);
129  (*theLbound)[i] = (*theUbound)[i];
130  }
131  }
132  else if ((*theLbound)[i] - allow >= (*thePvec)[i] && tmp)
133  {
134  if ((*theUbound)[i] != (*theLbound)[i])
135  shiftLPbound(i, (*thePvec)[i] - random.next(minrandom,maxrandom));
136  else
137  {
138  shiftLPbound(i, (*thePvec)[i]);
139  (*theUbound)[i] = (*theLbound)[i];
140  }
141  }
142  }
143 
144 #ifndef NDEBUG
145  testBounds();
146  MSG_DEBUG( std::cout << "DSHIFT02 shiftPvec: OK" << std::endl; )
147 #endif
148 }
149 // -----------------------------------------------------------------
151  const UpdateVector& uvec,
152  Vector& p_low,
153  Vector& p_up,
154  Real eps,
155  Real p_delta,
156  int start,
157  int incr)
158 {
159  assert(uvec.dim() == p_low.dim());
160  assert(uvec.dim() == p_up.dim());
161 
162  const Real* vec = uvec.get_const_ptr();
163  Real minrandom = 10.0 * p_delta;
164  Real maxrandom = 100.0 * p_delta;
165  Real x, l, u;
166  int i;
167 
168  if( fullPerturbation )
169  {
170  eps = p_delta;
171 
172  for( i = uvec.dim() - start - 1; i >= 0; i -= incr )
173  {
174  u = p_up[i];
175  l = p_low[i];
176  x = vec[i];
177 
178  if( LT(u, infinity) && NE(l, u) && u <= x + eps )
179  {
180  p_up[i] = x + random.next(minrandom,maxrandom);
181  theShift += p_up[i] - u;
182  }
183  if( GT(l, -infinity) && NE(l, u) && l >= x - eps )
184  {
185  p_low[i] = x - random.next(minrandom,maxrandom);
186  theShift -= p_low[i] - l;
187  }
188  }
189  }
190  else
191  {
192  const Real* upd = uvec.delta().values();
193  const IdxSet& idx = uvec.delta().indices();
194 
195  for( int j = uvec.delta().size() - start - 1; j >= 0; j -= incr )
196  {
197  i = idx.index(j);
198  x = upd[i];
199  u = p_up[i];
200  l = p_low[i];
201 
202  // do not permute these bounds! c.f. with computeFrhs2() in spxvecs.cpp
204  {
205  continue;
206  }
207 
208  if (x < -eps)
209  {
210  if( LT(u, infinity) && NE(l, u) && vec[i] >= u - eps )
211  {
212  p_up[i] = vec[i] + random.next(minrandom,maxrandom);
213  theShift += p_up[i] - u;
214  }
215  }
216  else if (x > eps)
217  {
218  if( GT(l, -infinity) && NE(l, u) && vec[i] <= l + eps )
219  {
220  p_low[i] = vec[i] - random.next(minrandom,maxrandom);
221  theShift -= p_low[i] - l;
222  }
223  }
224  }
225  }
226 }
227 // -----------------------------------------------------------------
229  const UpdateVector& uvec,
230  Vector& p_low,
231  Vector& p_up,
232  Real eps,
233  Real p_delta,
234  int start,
235  int incr)
236 {
237  assert(uvec.dim() == p_low.dim());
238  assert(uvec.dim() == p_up.dim());
239 
240  const Real* vec = uvec.get_const_ptr();
241  Real minrandom = 10.0 * p_delta;
242  Real maxrandom = 100.0 * p_delta;
243  Real x, l, u;
244  int i;
245 
246  if( fullPerturbation )
247  {
248  eps = p_delta;
249  for (i = uvec.dim() - start - 1; i >= 0; i -= incr)
250  {
251  u = p_up[i];
252  l = p_low[i];
253  x = vec[i];
254 
255  if( LT(u, infinity) && NE(l, u) && u <= x + eps )
256  {
257  p_up[i] = x + random.next(minrandom,maxrandom);
258  theShift += p_up[i] - u;
259  }
260  if( GT(l, -infinity) && NE(l, u) && l >= x - eps )
261  {
262  p_low[i] = x - random.next(minrandom,maxrandom);
263  theShift -= p_low[i] - l;
264  }
265  }
266  }
267  else
268  {
269  const Real* upd = uvec.delta().values();
270  const IdxSet& idx = uvec.delta().indices();
271 
272  for( int j = uvec.delta().size() - start - 1; j >= 0; j -= incr )
273  {
274  i = idx.index(j);
275  x = upd[i];
276  u = p_up[i];
277  l = p_low[i];
278 
279  // do not permute these bounds! c.f. computeFrhs2() in spxvecs.cpp
281  {
282  continue;
283  }
284 
285  if (x > eps)
286  {
287  if( LT(u, infinity) && NE(l, u) && vec[i] >= u - eps )
288  {
289  p_up[i] = vec[i] + random.next(minrandom,maxrandom);
290  theShift += p_up[i] - u;
291  }
292  }
293  else if (x < -eps)
294  {
295  if( GT(l, -infinity) && NE(l, u) && vec[i] <= l + eps )
296  {
297  p_low[i] = vec[i] - random.next(minrandom,maxrandom);
298  theShift -= p_low[i] - l;
299  }
300  }
301  }
302  }
303 }
304 
306 {
307  MSG_DEBUG( std::cout << "DSHIFT03 iteration= " << iteration() << ": perturbing " << shift(); )
308  fVec().delta().setup();
310  MSG_DEBUG( std::cout << "\t->" << shift() << std::endl; )
311 }
312 
313 
315 {
316  MSG_DEBUG( std::cout << "DSHIFT04 iteration= " << iteration() << ": perturbing " << shift(); )
317  fVec().delta().setup();
319  MSG_DEBUG( std::cout << "\t->" << shift() << std::endl; )
320 }
321 
322 
324  const UpdateVector& uvec,
325  Vector& p_low,
326  Vector& p_up,
327  Real eps,
328  Real p_delta,
329  const SPxBasis::Desc::Status* stat,
330  int start,
331  int incr)
332 {
333  assert(uvec.dim() == p_low.dim());
334  assert(uvec.dim() == p_up.dim());
335 
336  const Real* vec = uvec.get_const_ptr();
337  Real minrandom = 10.0 * p_delta;
338  Real maxrandom = 100.0 * p_delta;
339  Real x, l, u;
340  int i;
341  Real l_theShift = 0;
342 
343  if( fullPerturbation )
344  {
345  eps = p_delta;
346  for( i = uvec.dim() - start - 1; i >= 0; i -= incr )
347  {
348  u = p_up[i];
349  l = p_low[i];
350  x = vec[i];
351 
352  if( LT(u, infinity) && NE(l, u) && u <= x + eps && rep() * stat[i] < 0 )
353  {
354  p_up[i] = vec[i] + random.next(minrandom,maxrandom);
355  l_theShift += p_up[i] - u;
356  }
357  if( GT(l, -infinity) && NE(l, u) && l >= x - eps && rep() * stat[i] < 0 )
358  {
359  p_low[i] = vec[i] - random.next(minrandom,maxrandom);
360  l_theShift -= p_low[i] - l;
361  }
362  }
363  }
364  else
365  {
366  const Real* upd = uvec.delta().values();
367  const IdxSet& idx = uvec.delta().indices();
368 
369  for( int j = uvec.delta().size() - start - 1; j >= 0; j -= incr )
370  {
371  i = idx.index(j);
372  x = upd[i];
373  u = p_up[i];
374  l = p_low[i];
375  if (x < -eps)
376  {
377  if( LT(u, infinity) && NE(l, u) && vec[i] >= u - eps && rep() * stat[i] < 0 )
378  {
379  p_up[i] = vec[i] + random.next(minrandom,maxrandom);
380  l_theShift += p_up[i] - u;
381  }
382  }
383  else if (x > eps)
384  {
385  if( GT(l, -infinity) && NE(l, u) && vec[i] <= l + eps && rep() * stat[i] < 0 )
386  {
387  p_low[i] = vec[i] - random.next(minrandom,maxrandom);
388  l_theShift -= p_low[i] - l;
389  }
390  }
391  }
392  }
393  return l_theShift;
394 }
395 
397  const UpdateVector& uvec,
398  Vector& p_low,
399  Vector& p_up,
400  Real eps,
401  Real p_delta,
402  const SPxBasis::Desc::Status* stat,
403  int start,
404  int incr)
405 {
406  assert(uvec.dim() == p_low.dim());
407  assert(uvec.dim() == p_up.dim());
408 
409  const Real* vec = uvec.get_const_ptr();
410  Real minrandom = 10.0 * p_delta;
411  Real maxrandom = 100.0 * p_delta;
412  Real x, l, u;
413  int i;
414  Real l_theShift = 0;
415 
416  if( fullPerturbation )
417  {
418  eps = p_delta;
419  for( i = uvec.dim() - start - 1; i >= 0; i -= incr )
420  {
421  u = p_up[i];
422  l = p_low[i];
423  x = vec[i];
424 
425  if( LT(u, infinity) && NE(l, u) && u <= x + eps && rep() * stat[i] < 0 )
426  {
427  p_up[i] = vec[i] + random.next(minrandom,maxrandom);
428  l_theShift += p_up[i] - u;
429  }
430  if( GT(l, -infinity) && NE(l, u) && l >= x - eps && rep() * stat[i] < 0 )
431  {
432  p_low[i] = vec[i] - random.next(minrandom,maxrandom);
433  l_theShift -= p_low[i] - l;
434  }
435  }
436  }
437  else
438  {
439  const Real* upd = uvec.delta().values();
440  const IdxSet& idx = uvec.delta().indices();
441 
442  for( int j = uvec.delta().size() - start - 1; j >= 0; j -= incr )
443  {
444  i = idx.index(j);
445  x = upd[i];
446  u = p_up[i];
447  l = p_low[i];
448  if( x > eps )
449  {
450  if( LT(u, infinity) && NE(l, u) && vec[i] >= u - eps && rep() * stat[i] < 0 )
451  {
452  p_up[i] = vec[i] + random.next(minrandom,maxrandom);
453  l_theShift += p_up[i] - u;
454  }
455  }
456  else if( x < -eps )
457  {
458  if( GT(l, -infinity) && NE(l, u) && vec[i] <= l + eps && rep() * stat[i] < 0 )
459  {
460  p_low[i] = vec[i] - random.next(minrandom,maxrandom);
461  l_theShift -= p_low[i] - l;
462  }
463  }
464  }
465  }
466  return l_theShift;
467 }
468 
469 
471 {
472  MSG_DEBUG( std::cout << "DSHIFT05 iteration= " << iteration() << ": perturbing " << shift(); )
473  pVec().delta().setup();
474  coPvec().delta().setup();
476  desc().status(), 0, 1);
478  desc().coStatus(), 0, 1);
479  MSG_DEBUG( std::cout << "\t->" << shift() << std::endl; )
480 }
481 
482 
484 {
485  MSG_DEBUG( std::cout << "DSHIFT06 iteration= " << iteration() << ": perturbing " << shift(); )
486  pVec().delta().setup();
487  coPvec().delta().setup();
489  desc().status(), 0, 1);
491  desc().coStatus(), 0, 1);
492  MSG_DEBUG( std::cout << "\t->" << shift() << std::endl; )
493 }
494 
495 
497 {
498  MSG_INFO3( (*spxout), (*spxout) << "DSHIFT07 = " << "unshifting ..." << std::endl; );
499 
500  if (isInitialized())
501  {
502  int i;
503  Real t_up, t_low;
504  const SPxBasis::Desc& ds = desc();
505 
506  theShift = 0;
507  if (type() == ENTER)
508  {
509  Real eps = entertol();
510 
511  if (rep() == COLUMN)
512  {
513  for (i = dim(); i-- > 0;)
514  {
515  SPxId l_id = baseId(i);
516  int l_num = number(l_id);
517  if (l_id.type() == SPxId::ROW_ID)
518  {
519  t_up = -lhs(l_num);
520  t_low = -rhs(l_num);
521  }
522  else
523  {
524  assert(l_id.type() == SPxId::COL_ID);
525  t_up = upper(l_num);
526  t_low = lower(l_num);
527  }
528  if (t_up != t_low)
529  {
530  if ((*theFvec)[i] < t_up + eps) // check allowed violation
531  theUBbound[i] = t_up; // reset shifted bound to original
532  else if ((*theFvec)[i] > t_up) // shifted bound is required for feasibility
533  theShift += theUBbound[i] - t_up;
534  if ((*theFvec)[i] > t_low - eps) // check allowed violation
535  theLBbound[i] = t_low; // reset shifted bound to original
536  else if ((*theFvec)[i] < t_low) // shifted bound is required for feasibility
537  theShift -= theLBbound[i] - t_low;
538  }
539  else
540  {
541  if (theUBbound[i] > t_up)
542  theShift += theUBbound[i] - t_up;
543  else if (theLBbound[i] < t_low)
544  theShift += t_low - theLBbound[i];
545  }
546  }
547  for (i = nRows(); i-- > 0;)
548  {
549  if (!isBasic(ds.rowStatus(i)))
550  {
551  t_up = -lhs(i);
552  t_low = -rhs(i);
553  if (theURbound[i] > t_up) // what about t_up == t_low ?
554  theShift += theURbound[i] - t_up;
555  if (t_low > theLRbound[i]) // what about t_up == t_low ?
556  theShift += t_low - theLRbound[i];
557  }
558  }
559  for (i = nCols(); i-- > 0;)
560  {
561  if (!isBasic(ds.colStatus(i)))
562  {
563  t_up = upper(i);
564  t_low = lower(i);
565  if (theUCbound[i] > t_up) // what about t_up == t_low ?
566  theShift += theUCbound[i] - t_up;
567  if (t_low > theLCbound[i]) // what about t_up == t_low ?
568  theShift += t_low - theLCbound[i];
569  }
570  }
571  }
572  else
573  {
574  assert(rep() == ROW);
575  for (i = dim(); i-- > 0;)
576  {
577  SPxId l_id = baseId(i);
578  int l_num = number(l_id);
579  t_up = t_low = 0;
580  if (l_id.type() == SPxId::ROW_ID)
581  clearDualBounds(ds.rowStatus(l_num), t_up, t_low);
582  else
583  clearDualBounds(ds.colStatus(l_num), t_up, t_low);
584  if (theUBbound[i] != theLBbound[i])
585  {
586  if (theUBbound[i] > t_up)
587  theShift += theUBbound[i] - t_up;
588  else
589  theShift -= theUBbound[i] - t_up;
590  }
591  else
592  {
593  /* if the basic (primal or dual) variable is fixed (e.g., basis status P_FREE in row representation)
594  * then shiftFvec() and shiftPvec() do not relax the bounds, but shift both, hence they may be outside
595  * of [t_low,t_up] */
596  assert(theLBbound[i] == theUBbound[i] || theUBbound[i] >= t_up);
597  assert(theLBbound[i] == theUBbound[i] || theLBbound[i] <= t_low);
598 
599  if ((*theFvec)[i] < t_up - eps)
600  theUBbound[i] = t_up;
601  else if ((*theFvec)[i] > t_up)
602  theShift += theUBbound[i] - t_up;
603 
604  if ((*theFvec)[i] > t_low + eps)
605  theLBbound[i] = t_low;
606  else if ((*theFvec)[i] < t_low)
607  theShift -= theLBbound[i] - t_low;
608  }
609  }
610  for (i = nRows(); i-- > 0;)
611  {
612  if (!isBasic(ds.rowStatus(i)))
613  {
614  t_up = t_low = 0;
615  clearDualBounds(ds.rowStatus(i), t_up, t_low);
616  if (theURbound[i] > t_up) // what about t_up == t_low ?
617  theShift += theURbound[i] - t_up;
618  if (t_low > theLRbound[i]) // what about t_up == t_low ?
619  theShift += t_low - theLRbound[i];
620  }
621  }
622  for (i = nCols(); i-- > 0;)
623  {
624  if (!isBasic(ds.colStatus(i)))
625  {
626  t_up = t_low = 0;
627  clearDualBounds(ds.colStatus(i), t_up, t_low);
628  if (theUCbound[i] > t_up) // what about t_up == t_low ?
629  theShift += theUCbound[i] - t_up;
630  if (t_low > theLCbound[i]) // what about t_up == t_low ?
631  theShift += t_low - theLCbound[i];
632  }
633  }
634  }
635  }
636  else
637  {
638  assert(type() == LEAVE);
639 
640  Real eps = leavetol();
641 
642  if (rep() == COLUMN)
643  {
644  for (i = nRows(); i-- > 0;)
645  {
646  t_up = t_low = maxRowObj(i);
647  clearDualBounds(ds.rowStatus(i), t_up, t_low);
648  if (!isBasic(ds.rowStatus(i)))
649  {
650  if ((*theCoPvec)[i] < t_up + eps)
651  {
652  theURbound[i] = t_up; // reset bound to original value
653  if( t_up == t_low )
654  theLRbound[i] = t_low; // for fixed rows we change both bounds
655  }
656  else
657  theShift += theURbound[i] - t_up;
658  if ((*theCoPvec)[i] > t_low - eps)
659  {
660  theLRbound[i] = t_low; // reset bound to original value
661  if( t_up == t_low )
662  theURbound[i] = t_up; // for fixed rows we change both bounds
663  }
664  else
665  theShift += t_low - theLRbound[i];
666  }
667  else if (theURbound[i] > t_up)
668  theShift += theURbound[i] - t_up;
669  else if (theLRbound[i] < t_low)
670  theShift += t_low - theLRbound[i];
671  }
672  for (i = nCols(); i-- > 0;)
673  {
674  t_up = t_low = -maxObj(i);
675  clearDualBounds(ds.colStatus(i), t_low, t_up);
676  if (!isBasic(ds.colStatus(i)))
677  {
678  if ((*thePvec)[i] < -t_up + eps)
679  {
680  theUCbound[i] = -t_up; // reset bound to original value
681  if( t_up == t_low )
682  theLCbound[i] = -t_low; // for fixed variables we change both bounds
683  }
684  else
685  theShift += theUCbound[i] - (-t_up);
686  if ((*thePvec)[i] > -t_low - eps)
687  {
688  theLCbound[i] = -t_low; // reset bound to original value
689  if( t_up == t_low )
690  theUCbound[i] = -t_up; // for fixed variables we change both bounds
691  }
692  else
693  theShift += (-t_low) - theLCbound[i];
694  }
695  else if (theUCbound[i] > -t_up)
696  theShift += theUCbound[i] - (-t_up);
697  else if (theLCbound[i] < -t_low)
698  theShift += (-t_low) - theLCbound[i];
699  }
700  }
701  else
702  {
703  assert(rep() == ROW);
704  for (i = nRows(); i-- > 0;)
705  {
706  t_up = rhs(i);
707  t_low = lhs(i);
708  if (t_up == t_low)
709  {
710  if (theURbound[i] > t_up)
711  theShift += theURbound[i] - t_up;
712  else
713  theShift += t_low - theLRbound[i];
714  }
715  else
716  if (!isBasic(ds.rowStatus(i)))
717  {
718  if ((*thePvec)[i] < t_up + eps)
719  theURbound[i] = t_up; // reset bound to original value
720  else
721  theShift += theURbound[i] - t_up;
722  if ((*thePvec)[i] > t_low - eps)
723  theLRbound[i] = t_low; // reset bound to original value
724  else
725  theShift += t_low - theLRbound[i];
726  }
727  else if (theURbound[i] > t_up)
728  theShift += theURbound[i] - t_up;
729  else if (theLRbound[i] < t_low)
730  theShift += t_low - theLRbound[i];
731  }
732  for (i = nCols(); i-- > 0;)
733  {
734  t_up = upper(i);
735  t_low = lower(i);
736  if (t_up == t_low)
737  {
738  if (theUCbound[i] > t_up)
739  theShift += theUCbound[i] - t_up;
740  else
741  theShift += t_low - theLCbound[i];
742  }
743  else
744  if (!isBasic(ds.colStatus(i)))
745  {
746  if ((*theCoPvec)[i] < t_up + eps)
747  theUCbound[i] = t_up; // reset bound to original value
748  else
749  theShift += theUCbound[i] - t_up;
750  if ((*theCoPvec)[i] > t_low - eps)
751  theLCbound[i] = t_low; // reset bound to original value
752  else
753  theShift += t_low - theLCbound[i];
754  }
755  else if (theUCbound[i] > t_up)
756  theShift += theUCbound[i] - t_up;
757  else if (theLCbound[i] < t_low)
758  theShift += t_low - theLCbound[i];
759  }
760  }
761  }
762  }
763 }
764 } // namespace soplex
virtual void unShift(void)
remove shift as much as possible.
Definition: spxshift.cpp:496
const VectorBase< Real > & rhs() const
Returns right hand side vector.
Definition: spxlpbase.h:219
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1098
const Vector & ucBound() const
Definition: spxsolver.h:1398
int iteration() const
returns number of basis changes since last load().
Definition: spxbasis.h:545
virtual Real shift() const
total current shift amount.
Definition: spxsolver.h:1602
const VectorBase< Real > & upper() const
Returns upper bound vector.
Definition: spxlpbase.h:456
SPxOut * spxout
message handler
Definition: spxsolver.h:436
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
DVector * theUbound
Upper bound for vars.
Definition: spxsolver.h:357
void testBounds() const
Definition: spxbounds.cpp:311
Real leavetol() const
feasibility tolerance maintained by ratio test during LEAVE algorithm.
Definition: spxsolver.h:779
DVector * theCoUbound
Upper bound for covars.
Definition: spxsolver.h:359
Status & rowStatus(int i)
Definition: spxbasis.h:239
bool LT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a < b + eps
Definition: spxdefines.h:392
void clearDualBounds(SPxBasis::Desc::Status, Real &, Real &) const
Definition: spxbounds.cpp:76
virtual void perturbMaxLeave(void)
perturb nonbasic bounds.
Definition: spxshift.cpp:483
bool NE(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| > eps
Definition: spxdefines.h:386
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
Definition: spxlpbase.h:522
const Vector & lcBound() const
Definition: spxsolver.h:1419
virtual void perturbMinEnter(void)
Definition: spxshift.cpp:305
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1056
void shiftLBbound(int i, Real to)
shift i &#39;th lbBound to to.
Definition: spxsolver.h:1564
virtual void perturbMaxEnter(void)
perturb basis bounds.
Definition: spxshift.cpp:314
Desc::Status dualStatus(const SPxColId &id) const
dual Status for the column variable with ID id of the loaded LP.
Definition: spxbasis.cpp:34
rowwise representation.
Definition: spxsolver.h:107
const R * get_const_ptr() const
Conversion to C-style pointer.
Definition: vectorbase.h:453
Wrapper for different output streams and verbosity levels.
int nRows() const
Returns number of rows in LP.
Definition: spxlpbase.h:151
const Vector & ubBound() const
upper bound for fVec.
Definition: spxsolver.h:1322
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:1379
Leaving Simplex.
Definition: spxsolver.h:143
double Real
Definition: spxdefines.h:218
const R * values() const
Returns array values.
Definition: ssvectorbase.h:299
#define MSG_DEBUG(x)
Definition: spxdefines.h:132
Status status() const
Status of solution process.
Definition: spxsolve.cpp:1910
void shiftLPbound(int i, Real to)
shift i &#39;th lpBound to to.
Definition: spxsolver.h:1578
bool GT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a > b + eps
Definition: spxdefines.h:404
DVector * theLbound
Lower bound for vars.
Definition: spxsolver.h:358
Real entertol() const
feasibility tolerance maintained by ratio test during ENTER algorithm.
Definition: spxsolver.h:772
UpdateVector * thePvec
Definition: spxsolver.h:350
const Vector & lbBound() const
lower bound for fVec.
Definition: spxsolver.h:1340
const IdxSet & indices() const
Returns indices.
Definition: ssvectorbase.h:305
UpdateVector & fVec() const
feasibility vector.
Definition: spxsolver.h:1304
DVector theLBbound
Lower Basic Feasibility bound.
Definition: spxsolver.h:339
main LP solver class
bool isBasic(SPxBasis::Desc::Status stat) const
does stat describe a basic index ?
Definition: spxsolver.h:1244
Real next(Real minimum=0.0, Real maximum=1.0)
returns next random number.
Definition: random.h:102
const VectorBase< Real > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:253
void shiftPvec()
Perform initial shifting to optain an feasible or pricable basis.
Definition: spxshift.cpp:79
Dense vector with semi-sparse vector for updatesIn many algorithms vectors are updated in every itera...
Definition: updatevector.h:53
void shiftUCbound(int i, Real to)
shift i &#39;th ucBound to to.
Definition: spxsolver.h:1585
Basis descriptor.
Definition: spxbasis.h:104
DVector theURbound
Upper Row Feasibility bound.
Definition: spxsolver.h:328
row identifier.
Definition: spxid.h:97
column identifier.
Definition: spxid.h:99
const VectorBase< Real > & maxRowObj() const
Definition: spxlpbase.h:297
void shiftUBbound(int i, Real to)
shift i &#39;th ubBound to to.
Definition: spxsolver.h:1557
Status & colStatus(int i)
Definition: spxbasis.h:254
SPxId & baseId(int i)
Definition: spxbasis.h:503
DVector theUBbound
Upper Basic Feasibility bound.
Definition: spxsolver.h:338
#define MSG_INFO3(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO3.
Definition: spxdefines.h:122
DVector * theCoLbound
Lower bound for covars.
Definition: spxsolver.h:360
Real epsilon() const
values are considered to be 0.
Definition: spxsolver.h:767
Debugging, floating point type and parameter definitions.
UpdateVector & pVec() const
pricing vector.
Definition: spxsolver.h:1459
bool fullPerturbation
whether to perturb the entire problem or just the bounds relevant for the current pivot ...
Definition: spxsolver.h:308
const Vector & lpBound() const
Definition: spxsolver.h:1485
DVector theLRbound
Lower Row Feasibility bound.
Definition: spxsolver.h:329
void perturbMin(const UpdateVector &vec, Vector &low, Vector &up, Real eps, Real delta, int start=0, int incr=1)
Definition: spxshift.cpp:150
DVector theUCbound
Upper Column Feasibility bound.
Definition: spxsolver.h:330
bool isInitialized() const
has the internal data been initialized?
Definition: spxsolver.h:1825
int dim() const
Dimension of vector.
Definition: vectorbase.h:215
int size() const
Returns the number of nonzeros.
Definition: ssvectorbase.h:199
Everything should be within this namespace.
void shiftUPbound(int i, Real to)
shift i &#39;th upBound to to.
Definition: spxsolver.h:1571
void shiftLCbound(int i, Real to)
shift i &#39;th lcBound to to.
Definition: spxsolver.h:1592
UpdateVector * theFvec
Definition: spxsolver.h:344
const VectorBase< Real > & maxObj() const
Returns objective vector for maximization problem.
Definition: spxlpbase.h:429
void setup()
Initializes nonzero indices for elements with absolute values above epsilon and sets all other elemen...
Definition: ssvectorbase.h:132
DVector theLCbound
Lower Column Feasibility bound.
Definition: spxsolver.h:331
const Vector & upBound() const
Definition: spxsolver.h:1464
virtual void perturbMinLeave(void)
Definition: spxshift.cpp:470
void shiftFvec()
Perform initial shifting to optain an feasible or pricable basis.
Definition: spxshift.cpp:25
Type type() const
returns the type of the id.
Definition: spxid.h:145
Type type() const
return current Type.
Definition: spxsolver.h:484
Real theShift
sum of all shifts applied to any bound.
Definition: spxsolver.h:266
int coDim() const
codimension.
Definition: spxsolver.h:1061
Random random
The random number generator used throughout the whole computation. Its seed can be modified...
Definition: spxsolver.h:399
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:157
dual variable has two bounds
Definition: spxbasis.h:194
void perturbMax(const UpdateVector &vec, Vector &low, Vector &up, Real eps, Real delta, int start=0, int incr=1)
Definition: spxshift.cpp:228
SSVector & delta()
update vector , writeable
Definition: updatevector.h:122
int index(int n) const
access n &#39;th index.
Definition: idxset.h:118
UpdateVector * theCoPvec
Definition: spxsolver.h:348
Status
Status of a variable.
Definition: spxbasis.h:185
const VectorBase< Real > & lower() const
Returns (internal and possibly scaled) lower bound vector.
Definition: spxlpbase.h:483
const Desc & desc() const
Definition: spxbasis.h:463
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:478
Set of indices.Class IdxSet provides a set of indices. At construction it must be given an array of i...
Definition: idxset.h:56
columnwise representation.
Definition: spxsolver.h:108