Scippy

SoPlex

Sequential object-oriented simPlex

slufactor.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 /**@file slufactor.cpp
17  * @todo SLUfactor seems to be partly an wrapper for CLUFactor (was C).
18  * This should be properly integrated and demangled.
19  * @todo Does is make sense, to call x.clear() when next x.altValues()
20  * is called.
21  */
22 
23 #include <assert.h>
24 #include <sstream>
25 
26 #include "spxdefines.h"
27 #include "slufactor.h"
28 #include "cring.h"
29 #include "spxalloc.h"
30 #include "spxout.h"
31 #include "exceptions.h"
32 
33 #ifdef SOPLEX_DEBUG
34 #include <stdio.h>
35 #endif
36 
37 namespace soplex
38 {
39 #define MINSTABILITY REAL(4e-2)
40 
41 void SLUFactor::solveRight(Vector& x, const Vector& b) //const
42 {
43 
44  solveTime->start();
45 
46  vec = b;
47  x.clear();
49 
50  solveCount++;
51  solveTime->stop();
52 }
53 
54 void SLUFactor::solveRight(SSVector& x, const SVector& b) //const
55 {
56 
57  solveTime->start();
58 
59  vec.assign(b);
60  x.clear();
62 
63  solveCount++;
64  solveTime->stop();
65 }
66 
68 {
69 
70  solveTime->start();
71 
72  int m;
73  int n;
74  int f;
75 
76  x.clear();
77  ssvec = b;
78  n = ssvec.size();
79  if (l.updateType == ETA)
80  {
82  ssvec.altValues(), ssvec.altIndexMem(), n, 0, 0, 0);
83  x.setSize(m);
84  //x.forceSetup();
85  x.unSetup();
87  }
88  else
89  {
90  forest.clear();
94  forest.setSize(f);
96  x.setSize(m);
97  x.forceSetup();
98  }
99  usetup = true;
100  ssvec.setSize(0);
101  ssvec.forceSetup();
102 
103  solveCount++;
104  solveTime->stop();
105 }
106 
108  SSVector& x,
109  Vector& y,
110  const SVector& b,
111  SSVector& rhs)
112 {
113 
114  solveTime->start();
115 
116  int m;
117  int n;
118  int f;
119  int* sidx = ssvec.altIndexMem();
120  ssvec.setSize(0);
121  ssvec.forceSetup();
122  int rsize = rhs.size();
123  int* ridx = rhs.altIndexMem();
124 
125  x.clear();
126  y.clear();
127  usetup = true;
128  ssvec = b;
129 
130  if (l.updateType == ETA)
131  {
132  n = ssvec.size();
134  ssvec.get_ptr(), sidx, n, y.get_ptr(),
135  rhs.getEpsilon(), rhs.altValues(), ridx, rsize, 0, 0, 0);
136  x.setSize(m);
137  // x.forceSetup();
138  x.unSetup();
140  }
141  else
142  {
143  forest.clear();
144  n = ssvec.size();
146  ssvec.get_ptr(), sidx, n, y.get_ptr(),
147  rhs.getEpsilon(), rhs.altValues(), ridx, rsize,
149  x.setSize(m);
150  x.forceSetup();
151  forest.setSize(f);
152  forest.forceSetup();
153  }
154  rhs.forceSetup();
155  ssvec.setSize(0);
156  ssvec.forceSetup();
157 
158  solveCount += 2;
159  solveTime->stop();
160 }
161 
163  SSVector& x,
164  SSVector& y,
165  const SVector& b,
166  SSVector& rhs)
167 {
168 
169  solveTime->start();
170 
171  int n;
172  int f;
173  int* sidx = ssvec.altIndexMem();
174  ssvec.setSize(0);
175  ssvec.forceSetup();
176  int rsize = rhs.size();
177  int* ridx = rhs.altIndexMem();
178 
179  x.clear();
180  y.clear();
181  usetup = true;
182  ssvec = b;
183 
184  if (l.updateType == ETA)
185  {
186  n = ssvec.size();
188  ssvec.get_ptr(), sidx, n,
189  y.getEpsilon(), y.altValues(), y.altIndexMem(),
190  rhs.altValues(), ridx, rsize,
191  0, 0, 0);
192  x.setSize(n);
193  // x.forceSetup();
194  x.unSetup();
195  y.setSize(rsize);
196  y.unSetup();
198  }
199  else
200  {
201  forest.clear();
202  n = ssvec.size();
204  ssvec.get_ptr(), sidx, n,
205  y.getEpsilon(), y.altValues(), y.altIndexMem(),
206  rhs.altValues(), ridx, rsize,
208  x.setSize(n);
209  x.forceSetup();
210  y.setSize(rsize);
211  y.forceSetup();
212  forest.setSize(f);
213  forest.forceSetup();
214  }
215  rhs.forceSetup();
216  ssvec.setSize(0);
217  ssvec.forceSetup();
218 
219  solveCount += 2;
220  solveTime->stop();
221 }
222 
223 
225  SSVector& x,
226  Vector& y,
227  Vector& y2,
228  const SVector& b,
229  SSVector& rhs,
230  SSVector& rhs2)
231 {
232 
233  solveTime->start();
234 
235  int m;
236  int n;
237  int f;
238  int* sidx = ssvec.altIndexMem();
239  ssvec.setSize(0);
240  ssvec.forceSetup();
241  int rsize = rhs.size();
242  int* ridx = rhs.altIndexMem();
243  int rsize2 = rhs2.size();
244  int* ridx2 = rhs2.altIndexMem();
245 
246  x.clear();
247  y.clear();
248  y2.clear();
249  usetup = true;
250  ssvec = b;
251 
252  if (l.updateType == ETA)
253  {
254  n = ssvec.size();
256  x.altValues(), x.altIndexMem(), ssvec.get_ptr(), sidx, n,
257  y.get_ptr(), rhs.getEpsilon(), rhs.altValues(), ridx, rsize,
258  y2.get_ptr(), rhs2.getEpsilon(),rhs2.altValues(), ridx2, rsize2,
259  0, 0, 0);
260  x.setSize(m);
261  // x.forceSetup();
262  x.unSetup();
264  }
265  else
266  {
267  forest.clear();
268  n = ssvec.size();
270  x.altValues(), x.altIndexMem(), ssvec.get_ptr(), sidx, n,
271  y.get_ptr(), rhs.getEpsilon(), rhs.altValues(), ridx, rsize,
272  y2.get_ptr(), rhs2.getEpsilon(),rhs2.altValues(), ridx2, rsize2,
274  x.setSize(m);
275  x.forceSetup();
276  forest.setSize(f);
277  forest.forceSetup();
278  }
279  rhs.forceSetup();
280  rhs2.forceSetup();
281  ssvec.setSize(0);
282  ssvec.forceSetup();
283 
284  solveCount += 3;
285  solveTime->stop();
286 }
287 
289  SSVector& x,
290  SSVector& y,
291  SSVector& y2,
292  const SVector& b,
293  SSVector& rhs,
294  SSVector& rhs2)
295 {
296  solveTime->start();
297 
298  int n;
299  int f;
300  int* sidx = ssvec.altIndexMem();
301  ssvec.setSize(0);
302  ssvec.forceSetup();
303  int rsize = rhs.size();
304  int* ridx = rhs.altIndexMem();
305  int rsize2 = rhs2.size();
306  int* ridx2 = rhs2.altIndexMem();
307 
308  x.clear();
309  y.clear();
310  y2.clear();
311  usetup = true;
312  ssvec = b;
313 
314  if (l.updateType == ETA)
315  {
316  n = ssvec.size();
318  ssvec.get_ptr(), sidx, n,
319  y.getEpsilon(), y.altValues(), y.altIndexMem(),
320  rhs.altValues(), ridx, rsize,
321  y2.getEpsilon(), y2.altValues(), y2.altIndexMem(),
322  rhs2.altValues(), ridx2, rsize2,
323  0, 0, 0);
324  x.setSize(n);
325  // x.forceSetup();
326  x.unSetup();
327  y.setSize(rsize);
328  y.unSetup();
329  y2.setSize(rsize2);
330  y2.unSetup();
332  }
333  else
334  {
335  forest.clear();
336  n = ssvec.size();
338  ssvec.get_ptr(), sidx, n,
339  y.getEpsilon(), y.altValues(), y.altIndexMem(),
340  rhs.altValues(), ridx, rsize,
341  y2.getEpsilon(), y2.altValues(), y2.altIndexMem(),
342  rhs2.altValues(), ridx2, rsize2,
344  x.setSize(n);
345  x.forceSetup();
346  y.setSize(rsize);
347  y.forceSetup();
348  y2.setSize(rsize2);
349  y2.forceSetup();
350 
351  forest.setSize(f);
352  forest.forceSetup();
353  }
354  rhs.forceSetup();
355  rhs2.forceSetup();
356  ssvec.setSize(0);
357  ssvec.forceSetup();
358 
359  solveCount += 3;
360  solveTime->stop();
361 }
362 
363 
364 void SLUFactor::solveLeft(Vector& x, const Vector& b) //const
365 {
366 
367  solveTime->start();
368 
369  vec = b;
370  x.clear();
372 
373  solveCount++;
374  solveTime->stop();
375 }
376 
377 void SLUFactor::solveLeft(SSVector& x, const SVector& b) //const
378 {
379 
380  solveTime->start();
381 
382  // copy to SSVec is done to avoid having to deal with the Nonzero datatype
383  // TODO change SVec to standard sparse format
384  ssvec.assign(b);
385 
386  x.clear();
387  int sz = ssvec.size(); // see .altValues()
388  int n = vSolveLeft(x.getEpsilon(), x.altValues(), x.altIndexMem(),
389  ssvec.altValues(), ssvec.altIndexMem(), sz);
390 
391  if (n > 0)
392  {
393  x.setSize(n);
394  x.forceSetup();
395  }
396  else
397  x.unSetup();
398 
399  ssvec.setSize(0);
400  ssvec.forceSetup();
401 
402  solveCount++;
403  solveTime->stop();
404 }
405 
407  SSVector& x,
408  Vector& y,
409  const SVector& rhs1,
410  SSVector& rhs2) //const
411 {
412 
413  solveTime->start();
414 
415  int n;
416  Real* svec = ssvec.altValues();
417  int* sidx = ssvec.altIndexMem();
418  int rn = rhs2.size();
419  int* ridx = rhs2.altIndexMem();
420 
421  x.clear();
422  y.clear();
423  ssvec.assign(rhs1);
424  n = ssvec.size(); // see altValues();
425  n = vSolveLeft2(x.getEpsilon(), x.altValues(), x.altIndexMem(), svec, sidx, n,
426  y.get_ptr(), rhs2.altValues(), ridx, rn);
427 
428  // this will unsetup x
429  x.setSize(n);
430 
431  if (n > 0)
432  x.forceSetup();
433 
434  ssvec.setSize(0);
435  ssvec.forceSetup();
436 
437  solveCount += 2;
438  solveTime->stop();
439 }
440 
442  SSVector& x,
443  SSVector& y,
444  const SVector& rhs1,
445  SSVector& rhs2) //const
446 {
447 
448  solveTime->start();
449 
450  int n1, n2;
451  Real* svec = ssvec.altValues();
452  int* sidx = ssvec.altIndexMem();
453 
454  x.clear();
455  y.clear();
456  ssvec.assign(rhs1);
457  n1 = ssvec.size(); // see altValues();
458  n2 = rhs2.size();
459  if( n2 < 10 )
460  {
462  x.altValues(), x.altIndexMem(),
463  svec, sidx, n1,
464  y.altValues(), y.altIndexMem(),
465  rhs2.altValues(), rhs2.altIndexMem(), n2);
466  y.setSize(n2);
467  if( n2 > 0 )
468  y.forceSetup();
469  }
470  else
471  {
472  n1 = vSolveLeft2(x.getEpsilon(), x.altValues(), x.altIndexMem(), svec, sidx, n1,
473  y.altValues(), rhs2.altValues(), rhs2.altIndexMem(), n2);
474 // y.setup();
475  }
476  x.setSize(n1);
477 
478  if (n1 > 0)
479  x.forceSetup();
480 // if (n2 > 0)
481 // y.forceSetup();
482 
483  ssvec.setSize(0);
484  ssvec.forceSetup();
485 
486  solveCount += 2;
487  solveTime->stop();
488 }
489 
490 
492  SSVector& x,
493  Vector& y,
494  Vector& z,
495  const SVector& rhs1,
496  SSVector& rhs2,
497  SSVector& rhs3)
498 {
499 
500  solveTime->start();
501 
502  int n, n2, n3;
503  Real* svec = ssvec.altValues();
504  int* sidx = ssvec.altIndexMem();
505 
506  x.clear();
507  y.clear();
508  z.clear();
509  ssvec.assign(rhs1);
510  n = ssvec.size(); // see altValues();
511  n2 = rhs2.size();
512  n3 = rhs3.size();
513 
514  n = vSolveLeft3(x.getEpsilon(), x.altValues(), x.altIndexMem(), svec, sidx, n,
515  y.get_ptr(), rhs2.altValues(), rhs2.altIndexMem(), n2,
516  z.get_ptr(), rhs3.altValues(), rhs3.altIndexMem(), n3);
517 
518  x.setSize(n);
519 
520  if (n > 0)
521  x.forceSetup();
522 
523  ssvec.setSize(0);
524  ssvec.forceSetup();
525 
526  solveCount += 3;
527  solveTime->stop();
528 }
529 
531  SSVector& x,
532  SSVector& y,
533  SSVector& z,
534  const SVector& rhs1,
535  SSVector& rhs2,
536  SSVector& rhs3)
537 {
538 
539  solveTime->start();
540 
541  int n1, n2, n3;
542  Real* svec = ssvec.altValues();
543  int* sidx = ssvec.altIndexMem();
544 
545  x.clear();
546  y.clear();
547  z.clear();
548  ssvec.assign(rhs1);
549  n1 = ssvec.size(); // see altValues();
550  n2 = rhs2.size();
551  n3 = rhs3.size();
553  x.altValues(), x.altIndexMem(),
554  svec, sidx, n1,
555  y.altValues(), y.altIndexMem(),
556  rhs2.altValues(), rhs2.altIndexMem(), n2,
557  z.altValues(), z.altIndexMem(),
558  rhs3.altValues(), rhs3.altIndexMem(), n3);
559  x.setSize(n1);
560  y.setSize(n2);
561  z.setSize(n3);
562 
563  if (n1 > 0)
564  x.forceSetup();
565  if (n2 > 0)
566  y.forceSetup();
567  if (n3 > 0)
568  z.forceSetup();
569 
570  ssvec.setSize(0);
571  ssvec.forceSetup();
572 
573  solveCount += 3;
574  solveTime->stop();
575 }
576 
577 
579 {
580  if (status() != OK)
581  return 0;
582 
583  if (maxabs < initMaxabs)
584  return 1;
585 
586  assert(maxabs != 0.0);
587  return initMaxabs / maxabs;
588 }
589 
591 {
592  Real result = 0.0;
593 
594  // catch corner case of empty matrix
595  if( dim() == 0 )
596  return 1.0;
597 
598  switch( type )
599  {
600  // compute estimate by ratio of max/min of elements on the diagonal
601  case 0:
602  {
603  Real mindiag = spxAbs(diag[0]);
604  Real maxdiag = spxAbs(diag[0]);
605 
606  for( int i = 1; i < dim(); ++i)
607  {
608  Real absdiag = spxAbs(diag[i]);
609  if( absdiag < mindiag )
610  mindiag = absdiag;
611  if( absdiag > maxdiag )
612  maxdiag = absdiag;
613  }
614  result = maxdiag/mindiag;
615  break;
616  }
617  // compute estimate by summing up the elements on the diagonal
618  case 1:
619  result = diag[0];
620  for( int i = 1; i < dim(); ++i)
621  result += spxAbs(diag[i]);
622  break;
623  // compute estimate by multiplying the elements on the diagonal
624  case 2:
625  result = diag[0];
626  for( int i = 1; i < dim(); ++i)
627  result *= spxAbs(diag[i]);
628  break;
629  }
630 
631  return result;
632 }
633 
634 std::string SLUFactor::statistics() const
635 {
636  std::stringstream s;
637  s << "Factorizations : " << std::setw(10) << getFactorCount() << std::endl
638  << " Time spent : " << std::setw(10) << std::fixed << std::setprecision(2) << getFactorTime() << std::endl
639  << "Solves : " << std::setw(10) << getSolveCount() << std::endl
640  << " Time spent : " << std::setw(10) << getSolveTime() << std::endl;
641 
642  return s.str();
643 }
644 
645 void SLUFactor::changeEta(int idx, SSVector& et)
646 {
647 
648  int es = et.size(); // see altValues()
649  update(idx, et.altValues(), et.altIndexMem(), es);
650  et.setSize(0);
651  et.forceSetup();
652 }
653 
655  int idx,
656  const SVector& subst,
657  const SSVector* e)
658 {
659 
660  // BH 2005-08-23: The boolean usetup indicates that an "update vector"
661  // has been set up. I suppose that SSVector forest is this
662  // update vector, which is set up by solveRight4update() and
663  // solve2right4update() in order to optimize the basis update.
664 
665  if (usetup)
666  {
667  if (l.updateType == FOREST_TOMLIN) // FOREST_TOMLIN updates
668  {
669  // BH 2005-08-19: The size of a SSVector is the size of the
670  // index set, i.e. the number of nonzeros which is only
671  // defined if the SSVector is set up. Since
672  // SSVector::altValues() calls unSetup() the size needs to be
673  // stored before the following call.
674  int fsize = forest.size(); // see altValues()
675  forestUpdate(idx, forest.altValues(), fsize, forest.altIndexMem());
676  forest.setSize(0);
677  forest.forceSetup();
678  }
679  else
680  {
681  assert(l.updateType == ETA);
682  changeEta(idx, eta);
683  }
684  }
685  else if (e != 0) // ETA updates
686  {
687  l.updateType = ETA;
688  updateNoClear(idx, e->values(), e->indexMem(), e->size());
689  l.updateType = uptype;
690  }
691  else if (l.updateType == FOREST_TOMLIN) // FOREST_TOMLIN updates
692  {
693  assert(0); // probably this part is never called.
694  // forestUpdate() with the last parameter set to NULL should fail.
695  forest = subst;
697  forestUpdate(idx, forest.altValues(), 0, 0);
698  forest.setSize(0);
699  forest.forceSetup();
700  }
701  else // ETA updates
702  {
703  assert(l.updateType == ETA);
704  vec = subst;
705  eta.clear();
707  changeEta(idx, eta);
708  }
709  usetup = false;
710 
711  MSG_DEBUG( std::cout << "DSLUFA01\tupdated\t\tstability = " << stability()
712  << std::endl; )
713 
714  return status();
715 }
716 
718 {
719 
720  rowMemMult = 5; /* factor of minimum Memory * #of nonzeros */
721  colMemMult = 5; /* factor of minimum Memory * #of nonzeros */
722  lMemMult = 1; /* factor of minimum Memory * #of nonzeros */
723 
724  l.firstUpdate = 0;
725  l.firstUnused = 0;
726  thedim = 0;
727 
729  usetup = false;
730  maxabs = 1;
731  initMaxabs = 1;
734  stat = UNLOADED;
735 
736  vec.clear();
737  eta.clear();
738  ssvec.clear();
739  forest.clear();
740 
741  u.row.size = 100;
742  u.col.size = 100;
743  l.size = 100;
744  l.startSize = 100;
745 
746  if (l.rval)
747  spx_free(l.rval);
748  if(l.ridx)
749  spx_free(l.ridx);
750  if(l.rbeg)
751  spx_free(l.rbeg);
752  if(l.rorig)
753  spx_free(l.rorig);
754  if(l.rperm)
755  spx_free(l.rperm);
756 
757  if(u.row.val)
758  spx_free(u.row.val);
759  if(u.row.idx)
760  spx_free(u.row.idx);
761  if(u.col.idx)
762  spx_free(u.col.idx);
763  if(l.val)
764  spx_free(l.val);
765  if(l.idx)
766  spx_free(l.idx);
767  if(l.start)
768  spx_free(l.start);
769  if(l.row)
770  spx_free(l.row);
771 
772  // G clear() is used in constructor of SLUFactor so we have to
773  // G clean up if anything goes wrong here
774  try
775  {
776  spx_alloc(u.row.val, u.row.size);
777  spx_alloc(u.row.idx, u.row.size);
778  spx_alloc(u.col.idx, u.col.size);
779 
780  spx_alloc(l.val, l.size);
781  spx_alloc(l.idx, l.size);
784  }
785  catch(const SPxMemoryException& x)
786  {
787  freeAll();
788  throw x;
789  }
790 }
791 
792 /** assignment used to implement operator=() and copy constructor.
793  * If this is initialised, freeAll() has to be called before.
794  * Class objects from SLUFactor are not copied here.
795  */
796 void SLUFactor::assign(const SLUFactor& old)
797 {
798  spxout = old.spxout;
799 
802 
803  // slufactor
804  uptype = old.uptype;
807  epsilon = old.epsilon;
809 
810  // clufactor
811  stat = old.stat;
812  thedim = old.thedim;
813  nzCnt = old.nzCnt;
814  initMaxabs = old.initMaxabs;
815  maxabs = old.maxabs;
816  rowMemMult = old.rowMemMult;
817  colMemMult = old.colMemMult;
818  lMemMult = old.lMemMult;
819 
825 
826  memcpy(row.perm, old.row.perm, (unsigned int)thedim * sizeof(*row.perm));
827  memcpy(row.orig, old.row.orig, (unsigned int)thedim * sizeof(*row.orig));
828  memcpy(col.perm, old.col.perm, (unsigned int)thedim * sizeof(*col.perm));
829  memcpy(col.orig, old.col.orig, (unsigned int)thedim * sizeof(*col.orig));
830  memcpy(diag, old.diag, (unsigned int)thedim * sizeof(*diag));
831 
832  work = vec.get_ptr();
833 
834  /* setup U
835  */
836  u.row.size = old.u.row.size;
837  u.row.used = old.u.row.used;
838 
840  spx_alloc(u.row.val, u.row.size);
841  spx_alloc(u.row.idx, u.row.size);
842  spx_alloc(u.row.start, thedim + 1);
843  spx_alloc(u.row.len, thedim + 1);
844  spx_alloc(u.row.max, thedim + 1);
845 
846  memcpy(u.row.elem, old.u.row.elem, (unsigned int)thedim * sizeof(*u.row.elem));
847  memcpy(u.row.val, old.u.row.val, (unsigned int)u.row.size * sizeof(*u.row.val));
848  memcpy(u.row.idx, old.u.row.idx, (unsigned int)u.row.size * sizeof(*u.row.idx));
849  memcpy(u.row.start, old.u.row.start, (unsigned int)(thedim + 1) * sizeof(*u.row.start));
850  memcpy(u.row.len, old.u.row.len, (unsigned int)(thedim + 1) * sizeof(*u.row.len));
851  memcpy(u.row.max, old.u.row.max, (unsigned int)(thedim + 1) * sizeof(*u.row.max));
852 
853  // need to make row list ok ?
854  if (thedim > 0 && stat == OK)
855  {
856  u.row.list.idx = old.u.row.list.idx; // .idx neu
857 
858  const Dring* oring = &old.u.row.list;
859  Dring* ring = &u.row.list;
860 
861  while(oring->next != &old.u.row.list)
862  {
863  ring->next = &u.row.elem[oring->next->idx];
864  ring->next->prev = ring;
865  oring = oring->next;
866  ring = ring->next;
867  }
868  ring->next = &u.row.list;
869  ring->next->prev = ring;
870  }
871 
872  u.col.size = old.u.col.size;
873  u.col.used = old.u.col.used;
874 
876  spx_alloc(u.col.idx, u.col.size);
877  spx_alloc(u.col.start, thedim + 1);
878  spx_alloc(u.col.len, thedim + 1);
879  spx_alloc(u.col.max, thedim + 1);
880 
881  if (old.u.col.val != 0)
882  {
883  spx_alloc(u.col.val, u.col.size);
884  memcpy(u.col.val, old.u.col.val, (unsigned int)u.col.size * sizeof(*u.col.val));
885  }
886  else
887  u.col.val = 0;
888 
889  memcpy(u.col.elem, old.u.col.elem, (unsigned int)thedim * sizeof(*u.col.elem));
890  memcpy(u.col.idx, old.u.col.idx, (unsigned int)u.col.size * sizeof(*u.col.idx));
891  memcpy(u.col.start, old.u.col.start, (unsigned int)(thedim + 1) * sizeof(*u.col.start));
892  memcpy(u.col.len, old.u.col.len, (unsigned int)(thedim + 1) * sizeof(*u.col.len));
893  memcpy(u.col.max, old.u.col.max, (unsigned int)(thedim + 1) * sizeof(*u.col.max));
894 
895  // need to make col list ok
896  if (thedim > 0 && stat == OK)
897  {
898  u.col.list.idx = old.u.col.list.idx; // .idx neu
899 
900  const Dring* oring = &old.u.col.list;
901  Dring* ring = &u.col.list;
902 
903  while(oring->next != &old.u.col.list)
904  {
905  ring->next = &u.col.elem[oring->next->idx];
906  ring->next->prev = ring;
907  oring = oring->next;
908  ring = ring->next;
909  }
910  ring->next = &u.col.list;
911  ring->next->prev = ring;
912  }
913 
914  /* Setup L
915  */
916  l.size = old.l.size;
917  l.startSize = old.l.startSize;
918  l.firstUpdate = old.l.firstUpdate;
919  l.firstUnused = old.l.firstUnused;
920  l.updateType = old.l.updateType;
921 
922  spx_alloc(l.val, l.size);
923  spx_alloc(l.idx, l.size);
926 
927  memcpy(l.val, old.l.val, (unsigned int)l.size * sizeof(*l.val));
928  memcpy(l.idx, old.l.idx, (unsigned int)l.size * sizeof(*l.idx));
929  memcpy(l.start, old.l.start, (unsigned int)l.startSize * sizeof(*l.start));
930  memcpy(l.row, old.l.row, (unsigned int)l.startSize * sizeof(*l.row));
931 
932  if (old.l.rval != 0)
933  {
934  assert(old.l.ridx != 0);
935  assert(old.l.rbeg != 0);
936  assert(old.l.rorig != 0);
937  assert(old.l.rperm != 0);
938 
939  int memsize = l.start[l.firstUpdate];
940 
941  spx_alloc(l.rval, memsize);
942  spx_alloc(l.ridx, memsize);
943  spx_alloc(l.rbeg, thedim + 1);
946 
947  memcpy(l.rval, old.l.rval, (unsigned int)memsize * sizeof(*l.rval));
948  memcpy(l.ridx, old.l.ridx, (unsigned int)memsize * sizeof(*l.ridx));
949  memcpy(l.rbeg, old.l.rbeg, (unsigned int)(thedim + 1) * sizeof(*l.rbeg));
950  memcpy(l.rorig, old.l.rorig, (unsigned int)thedim * sizeof(*l.rorig));
951  memcpy(l.rperm, old.l.rperm, (unsigned int)thedim * sizeof(*l.rperm));
952  }
953  else
954  {
955  assert(old.l.ridx == 0);
956  assert(old.l.rbeg == 0);
957  assert(old.l.rorig == 0);
958  assert(old.l.rperm == 0);
959 
960  l.rval = 0;
961  l.ridx = 0;
962  l.rbeg = 0;
963  l.rorig = 0;
964  l.rperm = 0;
965  }
966 
967  assert(row.perm != 0);
968  assert(row.orig != 0);
969  assert(col.perm != 0);
970  assert(col.orig != 0);
971  assert(diag != 0);
972 
973  assert(u.row.elem != 0);
974  assert(u.row.val != 0);
975  assert(u.row.idx != 0);
976  assert(u.row.start != 0);
977  assert(u.row.len != 0);
978  assert(u.row.max != 0);
979 
980  assert(u.col.elem != 0);
981  assert(u.col.idx != 0);
982  assert(u.col.start != 0);
983  assert(u.col.len != 0);
984  assert(u.col.max != 0);
985 
986  assert(l.val != 0);
987  assert(l.idx != 0);
988  assert(l.start != 0);
989  assert(l.row != 0);
990 
991 }
992 
994 {
995 
996  if (this != &old)
997  {
998  // we don't need to copy them, because they are temporary vectors
999  vec.clear();
1000  ssvec.clear();
1001 
1002  eta = old.eta;
1003  forest = old.forest;
1004 
1005  timerType = old.timerType;
1006 
1007  freeAll();
1008  try
1009  {
1010  assign(old);
1011  }
1012  catch(const SPxMemoryException& x)
1013  {
1014  freeAll();
1015  throw x;
1016  }
1017  assert(isConsistent());
1018  }
1019  return *this;
1020 }
1021 
1023  : vec (1)
1024  , ssvec (1)
1025  , usetup (false)
1026  , uptype (FOREST_TOMLIN)
1027  , eta (1)
1028  , forest (1)
1029  , minThreshold (0.01)
1030  , timerType(Timer::USER_TIME)
1031 {
1032  row.perm = 0;
1033  row.orig = 0;
1034  col.perm = 0;
1035  col.orig = 0;
1036  diag = 0;
1037  u.row.elem = 0;
1038  u.row.val = 0;
1039  u.row.idx = 0;
1040  u.row.start = 0;
1041  u.row.len = 0;
1042  u.row.max = 0;
1043  u.col.elem = 0;
1044  u.col.idx = 0;
1045  u.col.start = 0;
1046  u.col.len = 0;
1047  u.col.max = 0;
1048  u.col.val = 0;
1049  l.val = 0;
1050  l.idx = 0;
1051  l.start = 0;
1052  l.row = 0;
1053  l.rval = 0;
1054  l.ridx = 0;
1055  l.rbeg = 0;
1056  l.rorig = 0;
1057  l.rperm = 0;
1058 
1059  nzCnt = 0;
1060  thedim = 0;
1061  try
1062  {
1069  spx_alloc(diag, thedim);
1070 
1071  work = vec.get_ptr();
1072 
1073  u.row.size = 1;
1074  u.row.used = 0;
1076  spx_alloc(u.row.val, u.row.size);
1077  spx_alloc(u.row.idx, u.row.size);
1078  spx_alloc(u.row.start, thedim + 1);
1079  spx_alloc(u.row.len, thedim + 1);
1080  spx_alloc(u.row.max, thedim + 1);
1081 
1082  u.row.list.idx = thedim;
1083  u.row.start[thedim] = 0;
1084  u.row.max [thedim] = 0;
1085  u.row.len [thedim] = 0;
1086 
1087  u.col.size = 1;
1088  u.col.used = 0;
1090  spx_alloc(u.col.idx, u.col.size);
1091  spx_alloc(u.col.start, thedim + 1);
1092  spx_alloc(u.col.len, thedim + 1);
1093  spx_alloc(u.col.max, thedim + 1);
1094  u.col.val = 0;
1095 
1096  u.col.list.idx = thedim;
1097  u.col.start[thedim] = 0;
1098  u.col.max[thedim] = 0;
1099  u.col.len[thedim] = 0;
1100 
1101  l.size = 1;
1102 
1103  spx_alloc(l.val, l.size);
1104  spx_alloc(l.idx, l.size);
1105 
1106  l.startSize = 1;
1107  l.firstUpdate = 0;
1108  l.firstUnused = 0;
1109 
1112  }
1113  catch(const SPxMemoryException& x)
1114  {
1115  freeAll();
1116  throw x;
1117  }
1118 
1119  l.rval = 0;
1120  l.ridx = 0;
1121  l.rbeg = 0;
1122  l.rorig = 0;
1123  l.rperm = 0;
1124 
1125  SLUFactor::clear(); // clear() is virtual
1126 
1127  factorCount = 0;
1128  solveCount = 0;
1129 
1130  assert(row.perm != 0);
1131  assert(row.orig != 0);
1132  assert(col.perm != 0);
1133  assert(col.orig != 0);
1134  assert(diag != 0);
1135 
1136  assert(u.row.elem != 0);
1137  assert(u.row.val != 0);
1138  assert(u.row.idx != 0);
1139  assert(u.row.start != 0);
1140  assert(u.row.len != 0);
1141  assert(u.row.max != 0);
1142 
1143  assert(u.col.elem != 0);
1144  assert(u.col.idx != 0);
1145  assert(u.col.start != 0);
1146  assert(u.col.len != 0);
1147  assert(u.col.max != 0);
1148 
1149  assert(l.val != 0);
1150  assert(l.idx != 0);
1151  assert(l.start != 0);
1152  assert(l.row != 0);
1153 
1154  assert(SLUFactor::isConsistent());
1155 }
1156 
1158  : SLinSolver( old )
1159  , vec(1) // we don't need to copy it, because they are temporary vectors
1160  , ssvec(1) // we don't need to copy it, because they are temporary vectors
1161  , usetup(old.usetup)
1162  , eta (old.eta)
1163  , forest(old.forest)
1164  , timerType(old.timerType)
1165 {
1166  row.perm = 0;
1167  row.orig = 0;
1168  col.perm = 0;
1169  col.orig = 0;
1170  diag = 0;
1171  u.row.elem = 0;
1172  u.row.val = 0;
1173  u.row.idx = 0;
1174  u.row.start = 0;
1175  u.row.len = 0;
1176  u.row.max = 0;
1177  u.col.elem = 0;
1178  u.col.idx = 0;
1179  u.col.start = 0;
1180  u.col.len = 0;
1181  u.col.max = 0;
1182  u.col.val = 0;
1183  l.val = 0;
1184  l.idx = 0;
1185  l.start = 0;
1186  l.row = 0;
1187  l.rval = 0;
1188  l.ridx = 0;
1189  l.rbeg = 0;
1190  l.rorig = 0;
1191  l.rperm = 0;
1192 
1193  solveCount = 0;
1196 
1197  try
1198  {
1199  assign(old);
1200  }
1201  catch(const SPxMemoryException& x)
1202  {
1203  freeAll();
1204  throw x;
1205  }
1206  assert(SLUFactor::isConsistent());
1207 }
1208 
1210 {
1211 
1212  if(row.perm) spx_free(row.perm);
1213  if(row.orig) spx_free(row.orig);
1214  if(col.perm) spx_free(col.perm);
1215  if(col.orig) spx_free(col.orig);
1216  if(u.row.elem) spx_free(u.row.elem);
1217  if(u.row.val) spx_free(u.row.val);
1218  if(u.row.idx) spx_free(u.row.idx);
1219  if(u.row.start) spx_free(u.row.start);
1220  if(u.row.len) spx_free(u.row.len);
1221  if(u.row.max) spx_free(u.row.max);
1222  if(u.col.elem) spx_free(u.col.elem);
1223  if(u.col.idx) spx_free(u.col.idx);
1224  if(u.col.start) spx_free(u.col.start);
1225  if(u.col.len) spx_free(u.col.len);
1226  if(u.col.max) spx_free(u.col.max);
1227  if(l.val) spx_free(l.val);
1228  if(l.idx) spx_free(l.idx);
1229  if(l.start) spx_free(l.start);
1230  if(l.row) spx_free(l.row);
1231 
1232  if(diag) spx_free(diag);
1233 
1234  if (u.col.val) spx_free(u.col.val);
1235 
1236  if (l.rval) spx_free(l.rval);
1237  if(l.ridx) spx_free(l.ridx);
1238  if(l.rbeg) spx_free(l.rbeg);
1239  if(l.rorig) spx_free(l.rorig);
1240  if(l.rperm) spx_free(l.rperm);
1241 }
1242 
1244 {
1245  freeAll();
1246 
1247  solveTime->~Timer();
1248  factorTime->~Timer();
1251 }
1252 
1254 {
1255  assert(th < REAL(1.0));
1256 
1257  if (LT(th, REAL(0.1)))
1258  th *= REAL(10.0);
1259  else if (LT(th, REAL(0.9)))
1260  th = (th + REAL(1.0)) / REAL(2.0);
1261  else if (LT(th, REAL(0.999)))
1262  th = REAL(0.99999);
1263 
1264  assert(th < REAL(1.0));
1265 
1266  return th;
1267 }
1268 
1270 {
1271  assert(dm >= 0);
1272  assert(matrix != 0);
1273 
1274  Real lastStability = stability();
1275 
1276  initDR(u.row.list);
1277  initDR(u.col.list);
1278 
1279  usetup = false;
1280  l.updateType = uptype;
1281  l.firstUpdate = 0;
1282  l.firstUnused = 0;
1283 
1284  if (dm != thedim)
1285  {
1286  clear();
1287 
1288  thedim = dm;
1289  vec.reDim(thedim);
1290  ssvec.reDim(thedim);
1291  eta.reDim(thedim);
1292  forest.reDim(thedim);
1293  work = vec.get_ptr();
1294 
1300 
1302  spx_realloc(u.row.len, thedim + 1);
1303  spx_realloc(u.row.max, thedim + 1);
1304  spx_realloc(u.row.start, thedim + 1);
1305 
1307  spx_realloc(u.col.len, thedim + 1);
1308  spx_realloc(u.col.max, thedim + 1);
1309  spx_realloc(u.col.start, thedim + 1);
1310 
1312 
1315  }
1316  // the last factorization was reasonably stable, so we decrease the Markowitz threshold (stored in lastThreshold) in
1317  // order to favour sparsity
1318  else if (lastStability > 2.0 * minStability)
1319  {
1320  // we reset lastThreshold to its previous value in the sequence minThreshold, betterThreshold(minThreshold),
1321  // betterThreshold(betterThreshold(minThreshold)), ...
1322  Real last = minThreshold;
1323  Real better = betterThreshold(last);
1324  while (better < lastThreshold)
1325  {
1326  last = better;
1327  better = betterThreshold(last);
1328  }
1329  lastThreshold = last;
1330 
1331  // we reset the minimum stability (which might have been decreased below) to ensure that the increased sparsity
1332  // does not hurt the stability
1333  minStability = 2 * MINSTABILITY;
1334  }
1335 
1336  u.row.list.idx = thedim;
1337  u.row.start[thedim] = 0;
1338  u.row.max[thedim] = 0;
1339  u.row.len[thedim] = 0;
1340 
1341  u.col.list.idx = thedim;
1342  u.col.start[thedim] = 0;
1343  u.col.max[thedim] = 0;
1344  u.col.len[thedim] = 0;
1345 
1346  for (;;)
1347  {
1348  ///@todo if the factorization fails with stat = SINGULAR, distinuish between proven singularity (e.g., because of
1349  ///an empty column) and singularity due to numerics, that could be avoided by changing minStability and
1350  ///lastThreshold; in the first case, we want to abort, otherwise change the numerics
1351  stat = OK;
1352  factor(matrix, lastThreshold, epsilon);
1353 
1354  // finish if the factorization is stable
1355  if (stability() >= minStability)
1356  break;
1357 
1358  // otherwise, we increase the Markowitz threshold
1359  Real x = lastThreshold;
1361 
1362  // until it doesn't change anymore at its maximum value
1363  if (EQ(x, lastThreshold))
1364  break;
1365 
1366  // we relax the stability requirement
1367  minStability /= 2.0;
1368 
1369  MSG_INFO3( (*spxout), (*spxout) << "ISLUFA01 refactorizing with increased Markowitz threshold: "
1370  << lastThreshold << std::endl; )
1371  }
1372  MSG_DEBUG( std::cout << "DSLUFA02 threshold = " << lastThreshold
1373  << "\tstability = " << stability()
1374  << "\tminStability = " << minStability << std::endl; )
1375  MSG_DEBUG(
1376  int i;
1377  FILE* fl = fopen("dump.lp", "w");
1378  std::cout << "DSLUFA03 Basis:\n";
1379  int j = 0;
1380  for (i = 0; i < dim(); ++i)
1381  j += matrix[i]->size();
1382  for (i = 0; i < dim(); ++i)
1383  {
1384  for (j = 0; j < matrix[i]->size(); ++j)
1385  fprintf(fl, "%8d %8d %16g\n",
1386  i + 1, matrix[i]->index(j) + 1, matrix[i]->value(j));
1387  }
1388  fclose(fl);
1389  std::cout << "DSLUFA04 LU-Factors:" << std::endl;
1390  dump();
1391 
1392  std::cout << "DSLUFA05 threshold = " << lastThreshold
1393  << "\tstability = " << stability() << std::endl;
1394  )
1395 
1396  assert(isConsistent());
1397  return Status(stat);
1398 }
1399 
1400 
1402 {
1403 #ifdef ENABLE_CONSISTENCY_CHECKS
1404  return CLUFactor::isConsistent();
1405 #else
1406  return true;
1407 #endif
1408 }
1409 
1410 void SLUFactor::dump() const
1411 {
1412  CLUFactor::dump();
1413 }
1414 } // namespace soplex
Rational spxAbs(const Rational &r)
Absolute.
Definition: rational.cpp:3909
int * len
used nonzeros per row vectors
Definition: clufactor.h:128
int updateType
type of updates to be used.
Definition: clufactor.h:167
int getSolveCount() const
number of solves performed
Definition: slufactor.h:263
DVector vec
Temporary vector.
Definition: slufactor.h:63
void updateNoClear(int p_col, const Real *p_work, const int *p_idx, int num)
Definition: clufactor.cpp:1320
Dring list
Double linked ringlist of vector indices in the order they appear in the column file.
Definition: clufactor.h:137
void solve2right4update(SSVector &x, Vector &y, const SVector &b, SSVector &d)
Solves and .
Definition: slufactor.cpp:107
Timer::TYPE timerType
Definition: slufactor.h:90
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:249
int * max
maximum available nonzeros per row: start[i] + max[i] == start[elem[i].next->idx] len[i] <= max[i]...
Definition: clufactor.h:129
SPxOut * spxout
message handler
Definition: slinsolver.h:214
std::string statistics() const
Definition: slufactor.cpp:634
#define REAL(x)
Definition: spxdefines.h:221
int vSolveRight4update(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *forest, int *forestNum, int *forestIdx)
Definition: clufactor.cpp:5599
Status load(const SVector *vec[], int dim)
Definition: slufactor.cpp:1269
Memory allocation routines.
void vSolveRight4update3sparse(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int &rn, Real eps2, Real *vec2, int *idx2, Real *rhs2, int *ridx2, int &rn2, Real eps3, Real *vec3, int *idx3, Real *rhs3, int *ridx3, int &rn3, Real *forest, int *forestNum, int *forestIdx)
sparse version of above method
Definition: clufactor.cpp:6018
SSVectorBase< R > & assign(const SVectorBase< S > &rhs)
Assigns only the elements of rhs.
Definition: basevectors.h:882
UpdateType uptype
the current UpdateType.
Definition: slufactor.h:73
SSVector ssvec
Temporary semi-sparse vector.
Definition: slufactor.h:64
int size() const
Number of used indices.
Definition: svectorbase.h:152
struct soplex::CLUFactor::U::Col col
void solveLeft(Vector &x, const Vector &b)
sparse version of solving one system of equations with transposed basis matrix
Definition: slufactor.cpp:364
Real epsilon
|x| < epsililon is considered to be 0.
Definition: slufactor.h:87
int * start
starting positions in val and idx
Definition: clufactor.h:147
Real * rval
values of rows of L
Definition: clufactor.h:173
Exception classes for SoPlex.
Real minStability
minimum stability to achieve by setting threshold.
Definition: slufactor.h:85
Real getFactorTime() const
time spent in factorizations
Definition: slufactor.h:238
Real maxabs
maximum abs number in L and U
Definition: clufactor.h:189
bool LT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a < b + eps
Definition: spxdefines.h:392
virtual ~Timer()
Definition: timer.h:124
int vSolveRight4update3(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *vec2, Real eps2, Real *rhs2, int *ridx2, int rn2, Real *vec3, Real eps3, Real *rhs3, int *ridx3, int rn3, Real *forest, int *forestNum, int *forestIdx)
Definition: clufactor.cpp:5868
void unSetup()
Makes SSVectorBase not setup.
Definition: ssvectorbase.h:126
U u
U matrix.
Definition: clufactor.h:200
Implementation of Sparse Linear Solver.
virtual ~SLUFactor()
destructor.
Definition: slufactor.cpp:1243
void solveRight4update(SSVector &x, const SVector &b)
Solves .
Definition: slufactor.cpp:67
void vSolveLeft3sparse(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int &rn, Real *vec2, int *idx2, Real *rhs2, int *ridx2, int &rn2, Real *vec3, int *idx3, Real *rhs3, int *ridx3, int &rn3)
sparse version of solving 3 systems of equations
Definition: clufactor.cpp:6287
Real lastThreshold
pivoting threshold of last factorization
Definition: slufactor.h:76
int size
size of array idx
Definition: clufactor.h:141
int getFactorCount() const
number of factorizations performed
Definition: slufactor.h:248
R & value(int n)
Reference to value of n &#39;th nonzero.
Definition: svectorbase.h:252
int * rorig
original row permutation
Definition: clufactor.h:176
void update(int p_col, Real *p_work, const int *p_idx, int num)
Definition: clufactor.cpp:1276
L l
L matrix.
Definition: clufactor.h:198
Dring * elem
Array of ring elements.
Definition: clufactor.h:122
void solveLeft(Real *vec, Real *rhs)
Definition: clufactor.cpp:4248
Real initMaxabs
maximum abs number in initail Matrix
Definition: clufactor.h:188
Timer * solveTime
Time spent in solves.
Definition: slufactor.h:89
int vSolveLeft2(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *vec2, Real *rhs2, int *ridx2, int rn2)
Definition: clufactor.cpp:6195
Real * diag
Array of pivot elements.
Definition: clufactor.h:199
Sparse Linear Solver virtual base class.Class SLinSolver provides a class for solving sparse linear s...
Definition: slinsolver.h:43
Perm row
row permutation matrices
Definition: clufactor.h:195
void solveRight(Vector &x, const Vector &b)
Solves .
Definition: slufactor.cpp:41
int * altIndexMem()
Returns array indices.
Definition: ssvectorbase.h:311
Dring * elem
Array of ring elements.
Definition: clufactor.h:140
Perm col
column permutation matrices
Definition: clufactor.h:196
int * orig
orig[p] original index from p
Definition: clufactor.h:109
Real minThreshold
minimum threshold to use.
Definition: slufactor.h:83
Real lMemMult
factor of minimum Memory * number of nonzeros
Definition: clufactor.h:193
Wrapper for different output streams and verbosity levels.
void changeEta(int idx, SSVector &eta)
Definition: slufactor.cpp:645
Exception class for out of memory exceptions.This class is derived from the SoPlex exception base cla...
Definition: exceptions.h:70
virtual void start()=0
start timer, resume accounting user, system and real time.
Real * work
Working array: must always be left as 0!
Definition: clufactor.h:202
void forestUpdate(int col, Real *work, int num, int *nonz)
Performs the Forrest-Tomlin update of the LU factorization.
Definition: clufactor.cpp:710
virtual Real stop()=0
stop timer, return accounted user time.
void spx_alloc(T &p, int n=1)
Allocate memory.
Definition: spxalloc.h:48
R * altValues()
Returns array values.
Definition: ssvectorbase.h:318
Status status() const
Definition: slufactor.h:171
R * get_ptr()
Conversion to C-style pointer.
Definition: vectorbase.h:444
int * len
used nonzeros per column vector
Definition: clufactor.h:148
SLUFactor()
default constructor.
Definition: slufactor.cpp:1022
double Real
Definition: spxdefines.h:218
int solveCount
Number of solves.
Definition: slufactor.h:92
const R * values() const
Returns array values.
Definition: ssvectorbase.h:299
#define MSG_DEBUG(x)
Definition: spxdefines.h:132
bool isConsistent() const
consistency check.
Definition: slufactor.cpp:1401
int size
size of arrays val and idx
Definition: clufactor.h:159
SLinSolver::Status stat
Status indicator.
Definition: clufactor.h:184
int used
used entries of arrays idx and val
Definition: clufactor.h:124
void solveLright(Real *vec)
Definition: clufactor.cpp:3319
int startSize
size of array start
Definition: clufactor.h:162
int factorCount
Number of factorizations.
Definition: clufactor.h:205
Real * val
hold nonzero values: this is only initialized in the end of the factorization with DEFAULT updates...
Definition: clufactor.h:144
void clear()
Clears vector.
Definition: ssvectorbase.h:600
int firstUnused
number of first unused L vector
Definition: clufactor.h:164
Real conditionEstimate(int type=0) const
return condition number estimate based on the diagonal of U
Definition: slufactor.cpp:590
SLUFactor & operator=(const SLUFactor &old)
assignment operator.
Definition: slufactor.cpp:993
static Timer * createTimer(Timer::TYPE ttype)
create timers and allocate memory for them
Definition: timerfactory.h:43
void vSolveRight4update2sparse(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int &rn, Real eps2, Real *vec2, int *idx2, Real *rhs2, int *ridx2, int &rn2, Real *forest, int *forestNum, int *forestIdx)
sparse version of above method
Definition: clufactor.cpp:5788
int thedim
dimension of factorized matrix
Definition: clufactor.h:186
const int * indexMem() const
Returns array indices.
Definition: ssvectorbase.h:293
struct soplex::CLUFactor::U::Row row
#define MSG_INFO3(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO3.
Definition: spxdefines.h:122
int * start
starting positions in val and idx
Definition: clufactor.h:127
bool usetup
TRUE iff update vector has been setup.
Definition: slufactor.h:72
SSVector eta
Definition: slufactor.h:74
void reDim(int newdim)
Resets dimension to newdim.
Definition: ssvectorbase.h:566
Debugging, floating point type and parameter definitions.
void setSize(int n)
Sets number of nonzeros (thereby unSetup SSVectorBase).
Definition: ssvectorbase.h:581
int size
size of arrays val and idx
Definition: clufactor.h:123
Real stability() const
Definition: slufactor.cpp:578
void dump() const
Definition: clufactor.cpp:2829
bool EQ(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| <= eps
Definition: spxdefines.h:380
R * get_ptr()
Only used in slufactor.cpp.
Definition: ssvectorbase.h:99
void spx_realloc(T &p, int n)
Change amount of allocated memory.
Definition: spxalloc.h:79
int * idx
indices of L vectors
Definition: clufactor.h:161
void factor(const SVector **vec, Real threshold, Real eps)
epsilon for zero detection
Definition: clufactor.cpp:2772
int * perm
perm[i] permuted index from i
Definition: clufactor.h:110
bool isConsistent() const
Definition: clufactor.cpp:2951
Implementation of Sparse Linear Solver.This class implements a SLinSolver interface by using the spar...
Definition: slufactor.h:41
void setup_and_assign(SSVectorBase< S > &rhs)
Sets up rhs vector, and assigns it.
Definition: ssvectorbase.h:718
int size() const
Returns the number of nonzeros.
Definition: ssvectorbase.h:199
Everything should be within this namespace.
void assign(const SLUFactor &old)
used to implement the assignment operator
Definition: slufactor.cpp:796
int vSolveLeft(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn)
Definition: clufactor.cpp:6167
R getEpsilon() const
Returns the non-zero epsilon used.
Definition: ssvectorbase.h:104
void solve3right4update(SSVector &x, Vector &y, Vector &z, const SVector &b, SSVector &d, SSVector &e)
Solves , and .
Definition: slufactor.cpp:224
int firstUpdate
number of first update L vector
Definition: clufactor.h:163
int vSolveLeft3(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *vec2, Real *rhs2, int *ridx2, int rn2, Real *vec3, Real *rhs3, int *ridx3, int rn3)
Definition: clufactor.cpp:6251
Real rowMemMult
factor of minimum Memory * number of nonzeros
Definition: clufactor.h:191
Dring list
Double linked ringlist of vector indices in the order they appear in the row file.
Definition: clufactor.h:119
int vSolveRight4update2(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn, Real *vec2, Real eps2, Real *rhs2, int *ridx2, int rn2, Real *forest, int *forestNum, int *forestIdx)
Definition: clufactor.cpp:5667
Timer * factorTime
Time spent in factorizations.
Definition: clufactor.h:204
void clear()
Set vector to 0.
Definition: vectorbase.h:260
void forceSetup()
Forces setup status.
Definition: ssvectorbase.h:162
int * idx
hold row indices of nonzeros
Definition: clufactor.h:143
int * ridx
indices of rows of L
Definition: clufactor.h:174
#define initDR(ring)
Definition: cring.h:23
Real colMemMult
factor of minimum Memory * number of nonzeros
Definition: clufactor.h:192
#define MAXUPDATES
maximum nr. of factorization updates allowed before refactorization.
Definition: slufactor.h:33
int * max
maximum available nonzeros per colunn: start[i] + max[i] == start[elem[i].next->idx] len[i] <= max[i]...
Definition: clufactor.h:149
Real getSolveTime() const
time spent in solves
Definition: slufactor.h:253
#define MINSTABILITY
Definition: slufactor.cpp:39
int * row
column indices of L vectors
Definition: clufactor.h:166
void dump() const
prints the LU factorization to stdout.
Definition: slufactor.cpp:1410
void vSolveLeft2sparse(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int &rn, Real *vec2, int *idx2, Real *rhs2, int *ridx2, int &rn2)
sparse version of solving 2 systems of equations
Definition: clufactor.cpp:6224
int * rbeg
start of rows in rval and ridx
Definition: clufactor.h:175
void solveRight(Real *vec, Real *rhs)
Definition: clufactor.cpp:3581
int nzCnt
number of nonzeros in U
Definition: clufactor.h:187
Real * val
hold nonzero values
Definition: clufactor.h:125
int * rperm
original row permutation
Definition: clufactor.h:177
int * start
starting positions in val and idx
Definition: clufactor.h:165
VectorBase< R > & assign(const SVectorBase< S > &vec)
Assign values of vec.
Definition: basevectors.h:80
int * idx
hold column indices of nonzeros
Definition: clufactor.h:126
int used
used entries of array idx
Definition: clufactor.h:142
Status
status flags of the SLinSolver class.
Definition: slinsolver.h:51
static Real epsilonFactorization()
Definition: spxdefines.cpp:55
No matrix has yet been loaded.
Definition: slinsolver.h:62
Status change(int idx, const SVector &subst, const SSVector *eta=0)
Definition: slufactor.cpp:654
int dim() const
Definition: slufactor.h:156
SSVector forest
? Update vector set up by solveRight4update() and solve2right4update()
Definition: slufactor.h:75
Wrapper for the system time query methods.
Definition: timer.h:76
Real * val
values of L vectors
Definition: clufactor.h:160
void spx_free(T &p)
Release memory.
Definition: spxalloc.h:109
static Real betterThreshold(Real th)
Definition: slufactor.cpp:1253
SLinSolver::Status Status
for convenience
Definition: slufactor.h:55
virtual TYPE type()=0
return type of timer