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;
48 
49  solveCount++;
50  solveTime->stop();
51 }
52 
53 void SLUFactor::solveRight(SSVector& x, const SVector& b) //const
54 {
55 
56  solveTime->start();
57 
58  vec.assign(b);
59  x.clear();
61 
62  solveCount++;
63  solveTime->stop();
64 }
65 
67 {
68 
69  solveTime->start();
70 
71  int m;
72  int n;
73  int f;
74 
75  x.clear();
76  ssvec = b;
77  n = ssvec.size();
78  if (l.updateType == ETA)
79  {
81  ssvec.altValues(), ssvec.altIndexMem(), n, 0, 0, 0);
82  x.setSize(m);
83  //x.forceSetup();
84  x.unSetup();
86  }
87  else
88  {
89  forest.clear();
93  forest.setSize(f);
95  x.setSize(m);
96  x.forceSetup();
97  }
98  usetup = true;
99  ssvec.setSize(0);
100  ssvec.forceSetup();
101 
102  solveCount++;
103  solveTime->stop();
104 }
105 
107  SSVector& x,
108  Vector& y,
109  const SVector& b,
110  SSVector& rhs)
111 {
112 
113  solveTime->start();
114 
115  int m;
116  int n;
117  int f;
118  int* sidx = ssvec.altIndexMem();
119  ssvec.setSize(0);
120  ssvec.forceSetup();
121  int rsize = rhs.size();
122  int* ridx = rhs.altIndexMem();
123 
124  x.clear();
125  y.clear();
126  usetup = true;
127  ssvec = b;
128 
129  if (l.updateType == ETA)
130  {
131  n = ssvec.size();
133  ssvec.get_ptr(), sidx, n, y.get_ptr(),
134  rhs.getEpsilon(), rhs.altValues(), ridx, rsize, 0, 0, 0);
135  x.setSize(m);
136  // x.forceSetup();
137  x.unSetup();
139  }
140  else
141  {
142  forest.clear();
143  n = ssvec.size();
145  ssvec.get_ptr(), sidx, n, y.get_ptr(),
146  rhs.getEpsilon(), rhs.altValues(), ridx, rsize,
148  x.setSize(m);
149  x.forceSetup();
150  forest.setSize(f);
151  forest.forceSetup();
152  }
153  rhs.forceSetup();
154  ssvec.setSize(0);
155  ssvec.forceSetup();
156 
157  solveCount += 2;
158  solveTime->stop();
159 }
160 
162  SSVector& x,
163  SSVector& y,
164  const SVector& b,
165  SSVector& rhs)
166 {
167 
168  solveTime->start();
169 
170  int n;
171  int f;
172  int* sidx = ssvec.altIndexMem();
173  ssvec.setSize(0);
174  ssvec.forceSetup();
175  int rsize = rhs.size();
176  int* ridx = rhs.altIndexMem();
177 
178  x.clear();
179  y.clear();
180  usetup = true;
181  ssvec = b;
182 
183  if (l.updateType == ETA)
184  {
185  n = ssvec.size();
187  ssvec.get_ptr(), sidx, n,
188  y.getEpsilon(), y.altValues(), y.altIndexMem(),
189  rhs.altValues(), ridx, rsize,
190  0, 0, 0);
191  x.setSize(n);
192  // x.forceSetup();
193  x.unSetup();
194  y.setSize(rsize);
195  y.unSetup();
197  }
198  else
199  {
200  forest.clear();
201  n = ssvec.size();
203  ssvec.get_ptr(), sidx, n,
204  y.getEpsilon(), y.altValues(), y.altIndexMem(),
205  rhs.altValues(), ridx, rsize,
207  x.setSize(n);
208  x.forceSetup();
209  y.setSize(rsize);
210  y.forceSetup();
211  forest.setSize(f);
212  forest.forceSetup();
213  }
214  rhs.forceSetup();
215  ssvec.setSize(0);
216  ssvec.forceSetup();
217 
218  solveCount += 2;
219  solveTime->stop();
220 }
221 
222 
224  SSVector& x,
225  Vector& y,
226  Vector& y2,
227  const SVector& b,
228  SSVector& rhs,
229  SSVector& rhs2)
230 {
231 
232  solveTime->start();
233 
234  int m;
235  int n;
236  int f;
237  int* sidx = ssvec.altIndexMem();
238  ssvec.setSize(0);
239  ssvec.forceSetup();
240  int rsize = rhs.size();
241  int* ridx = rhs.altIndexMem();
242  int rsize2 = rhs2.size();
243  int* ridx2 = rhs2.altIndexMem();
244 
245  x.clear();
246  y.clear();
247  y2.clear();
248  usetup = true;
249  ssvec = b;
250 
251  if (l.updateType == ETA)
252  {
253  n = ssvec.size();
255  x.altValues(), x.altIndexMem(), ssvec.get_ptr(), sidx, n,
256  y.get_ptr(), rhs.getEpsilon(), rhs.altValues(), ridx, rsize,
257  y2.get_ptr(), rhs2.getEpsilon(),rhs2.altValues(), ridx2, rsize2,
258  0, 0, 0);
259  x.setSize(m);
260  // x.forceSetup();
261  x.unSetup();
263  }
264  else
265  {
266  forest.clear();
267  n = ssvec.size();
269  x.altValues(), x.altIndexMem(), ssvec.get_ptr(), sidx, n,
270  y.get_ptr(), rhs.getEpsilon(), rhs.altValues(), ridx, rsize,
271  y2.get_ptr(), rhs2.getEpsilon(),rhs2.altValues(), ridx2, rsize2,
273  x.setSize(m);
274  x.forceSetup();
275  forest.setSize(f);
276  forest.forceSetup();
277  }
278  rhs.forceSetup();
279  rhs2.forceSetup();
280  ssvec.setSize(0);
281  ssvec.forceSetup();
282 
283  solveCount += 3;
284  solveTime->stop();
285 }
286 
288  SSVector& x,
289  SSVector& y,
290  SSVector& y2,
291  const SVector& b,
292  SSVector& rhs,
293  SSVector& rhs2)
294 {
295  solveTime->start();
296 
297  int n;
298  int f;
299  int* sidx = ssvec.altIndexMem();
300  ssvec.setSize(0);
301  ssvec.forceSetup();
302  int rsize = rhs.size();
303  int* ridx = rhs.altIndexMem();
304  int rsize2 = rhs2.size();
305  int* ridx2 = rhs2.altIndexMem();
306 
307  x.clear();
308  y.clear();
309  y2.clear();
310  usetup = true;
311  ssvec = b;
312 
313  if (l.updateType == ETA)
314  {
315  n = ssvec.size();
317  ssvec.get_ptr(), sidx, n,
318  y.getEpsilon(), y.altValues(), y.altIndexMem(),
319  rhs.altValues(), ridx, rsize,
320  y2.getEpsilon(), y2.altValues(), y2.altIndexMem(),
321  rhs2.altValues(), ridx2, rsize2,
322  0, 0, 0);
323  x.setSize(n);
324  // x.forceSetup();
325  x.unSetup();
326  y.setSize(rsize);
327  y.unSetup();
328  y2.setSize(rsize2);
329  y2.unSetup();
331  }
332  else
333  {
334  forest.clear();
335  n = ssvec.size();
337  ssvec.get_ptr(), sidx, n,
338  y.getEpsilon(), y.altValues(), y.altIndexMem(),
339  rhs.altValues(), ridx, rsize,
340  y2.getEpsilon(), y2.altValues(), y2.altIndexMem(),
341  rhs2.altValues(), ridx2, rsize2,
343  x.setSize(n);
344  x.forceSetup();
345  y.setSize(rsize);
346  y.forceSetup();
347  y2.setSize(rsize2);
348  y2.forceSetup();
349 
350  forest.setSize(f);
351  forest.forceSetup();
352  }
353  rhs.forceSetup();
354  rhs2.forceSetup();
355  ssvec.setSize(0);
356  ssvec.forceSetup();
357 
358  solveCount += 3;
359  solveTime->stop();
360 }
361 
362 
363 void SLUFactor::solveLeft(Vector& x, const Vector& b) //const
364 {
365 
366  solveTime->start();
367 
368  vec = b;
369  ///@todo Why is x.clear() here used and not with solveRight() ?
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  : CLUFactor()
1024  , vec (1)
1025  , ssvec (1)
1026  , usetup (false)
1027  , uptype (FOREST_TOMLIN)
1028  , eta (1)
1029  , forest (1)
1030  , minThreshold (0.01)
1031  , timerType(Timer::USER_TIME)
1032 {
1033  row.perm = 0;
1034  row.orig = 0;
1035  col.perm = 0;
1036  col.orig = 0;
1037  diag = 0;
1038  u.row.elem = 0;
1039  u.row.val = 0;
1040  u.row.idx = 0;
1041  u.row.start = 0;
1042  u.row.len = 0;
1043  u.row.max = 0;
1044  u.col.elem = 0;
1045  u.col.idx = 0;
1046  u.col.start = 0;
1047  u.col.len = 0;
1048  u.col.max = 0;
1049  u.col.val = 0;
1050  l.val = 0;
1051  l.idx = 0;
1052  l.start = 0;
1053  l.row = 0;
1054  l.rval = 0;
1055  l.ridx = 0;
1056  l.rbeg = 0;
1057  l.rorig = 0;
1058  l.rperm = 0;
1059 
1060  nzCnt = 0;
1061  thedim = 0;
1062  try
1063  {
1070  spx_alloc(diag, thedim);
1071 
1072  work = vec.get_ptr();
1073 
1074  u.row.size = 1;
1075  u.row.used = 0;
1077  spx_alloc(u.row.val, u.row.size);
1078  spx_alloc(u.row.idx, u.row.size);
1079  spx_alloc(u.row.start, thedim + 1);
1080  spx_alloc(u.row.len, thedim + 1);
1081  spx_alloc(u.row.max, thedim + 1);
1082 
1083  u.row.list.idx = thedim;
1084  u.row.start[thedim] = 0;
1085  u.row.max [thedim] = 0;
1086  u.row.len [thedim] = 0;
1087 
1088  u.col.size = 1;
1089  u.col.used = 0;
1091  spx_alloc(u.col.idx, u.col.size);
1092  spx_alloc(u.col.start, thedim + 1);
1093  spx_alloc(u.col.len, thedim + 1);
1094  spx_alloc(u.col.max, thedim + 1);
1095  u.col.val = 0;
1096 
1097  u.col.list.idx = thedim;
1098  u.col.start[thedim] = 0;
1099  u.col.max[thedim] = 0;
1100  u.col.len[thedim] = 0;
1101 
1102  l.size = 1;
1103 
1104  spx_alloc(l.val, l.size);
1105  spx_alloc(l.idx, l.size);
1106 
1107  l.startSize = 1;
1108  l.firstUpdate = 0;
1109  l.firstUnused = 0;
1110 
1113  }
1114  catch(const SPxMemoryException& x)
1115  {
1116  freeAll();
1117  throw x;
1118  }
1119 
1120  l.rval = 0;
1121  l.ridx = 0;
1122  l.rbeg = 0;
1123  l.rorig = 0;
1124  l.rperm = 0;
1125 
1126  SLUFactor::clear(); // clear() is virtual
1127 
1128  factorCount = 0;
1129  solveCount = 0;
1130 
1131  assert(row.perm != 0);
1132  assert(row.orig != 0);
1133  assert(col.perm != 0);
1134  assert(col.orig != 0);
1135  assert(diag != 0);
1136 
1137  assert(u.row.elem != 0);
1138  assert(u.row.val != 0);
1139  assert(u.row.idx != 0);
1140  assert(u.row.start != 0);
1141  assert(u.row.len != 0);
1142  assert(u.row.max != 0);
1143 
1144  assert(u.col.elem != 0);
1145  assert(u.col.idx != 0);
1146  assert(u.col.start != 0);
1147  assert(u.col.len != 0);
1148  assert(u.col.max != 0);
1149 
1150  assert(l.val != 0);
1151  assert(l.idx != 0);
1152  assert(l.start != 0);
1153  assert(l.row != 0);
1154 
1155  assert(SLUFactor::isConsistent());
1156 }
1157 
1159  : SLinSolver( old )
1160  , CLUFactor()
1161  , vec(1) // we don't need to copy it, because they are temporary vectors
1162  , ssvec(1) // we don't need to copy it, because they are temporary vectors
1163  , usetup(old.usetup)
1164  , eta (old.eta)
1165  , forest(old.forest)
1166  , timerType(old.timerType)
1167 {
1168  row.perm = 0;
1169  row.orig = 0;
1170  col.perm = 0;
1171  col.orig = 0;
1172  diag = 0;
1173  u.row.elem = 0;
1174  u.row.val = 0;
1175  u.row.idx = 0;
1176  u.row.start = 0;
1177  u.row.len = 0;
1178  u.row.max = 0;
1179  u.col.elem = 0;
1180  u.col.idx = 0;
1181  u.col.start = 0;
1182  u.col.len = 0;
1183  u.col.max = 0;
1184  u.col.val = 0;
1185  l.val = 0;
1186  l.idx = 0;
1187  l.start = 0;
1188  l.row = 0;
1189  l.rval = 0;
1190  l.ridx = 0;
1191  l.rbeg = 0;
1192  l.rorig = 0;
1193  l.rperm = 0;
1194 
1195  solveCount = 0;
1198 
1199  try
1200  {
1201  assign(old);
1202  }
1203  catch(const SPxMemoryException& x)
1204  {
1205  freeAll();
1206  throw x;
1207  }
1208  assert(SLUFactor::isConsistent());
1209 }
1210 
1212 {
1213 
1214  if(row.perm) spx_free(row.perm);
1215  if(row.orig) spx_free(row.orig);
1216  if(col.perm) spx_free(col.perm);
1217  if(col.orig) spx_free(col.orig);
1218  if(u.row.elem) spx_free(u.row.elem);
1219  if(u.row.val) spx_free(u.row.val);
1220  if(u.row.idx) spx_free(u.row.idx);
1221  if(u.row.start) spx_free(u.row.start);
1222  if(u.row.len) spx_free(u.row.len);
1223  if(u.row.max) spx_free(u.row.max);
1224  if(u.col.elem) spx_free(u.col.elem);
1225  if(u.col.idx) spx_free(u.col.idx);
1226  if(u.col.start) spx_free(u.col.start);
1227  if(u.col.len) spx_free(u.col.len);
1228  if(u.col.max) spx_free(u.col.max);
1229  if(l.val) spx_free(l.val);
1230  if(l.idx) spx_free(l.idx);
1231  if(l.start) spx_free(l.start);
1232  if(l.row) spx_free(l.row);
1233 
1234  if(diag) spx_free(diag);
1235 
1236  if (u.col.val) spx_free(u.col.val);
1237 
1238  if (l.rval) spx_free(l.rval);
1239  if(l.ridx) spx_free(l.ridx);
1240  if(l.rbeg) spx_free(l.rbeg);
1241  if(l.rorig) spx_free(l.rorig);
1242  if(l.rperm) spx_free(l.rperm);
1243 }
1244 
1246 {
1247  freeAll();
1248 
1249  solveTime->~Timer();
1250  factorTime->~Timer();
1253 }
1254 
1256 {
1257  assert(th < REAL(1.0));
1258 
1259  if (LT(th, REAL(0.1)))
1260  th *= REAL(10.0);
1261  else if (LT(th, REAL(0.9)))
1262  th = (th + REAL(1.0)) / REAL(2.0);
1263  else if (LT(th, REAL(0.999)))
1264  th = REAL(0.99999);
1265 
1266  assert(th < REAL(1.0));
1267 
1268  return th;
1269 }
1270 
1272 {
1273  assert(dm >= 0);
1274  assert(matrix != 0);
1275 
1276  Real lastStability = stability();
1277 
1278  initDR(u.row.list);
1279  initDR(u.col.list);
1280 
1281  usetup = false;
1282  l.updateType = uptype;
1283  l.firstUpdate = 0;
1284  l.firstUnused = 0;
1285 
1286  if (dm != thedim)
1287  {
1288  clear();
1289 
1290  thedim = dm;
1291  vec.reDim(thedim);
1292  ssvec.reDim(thedim);
1293  eta.reDim(thedim);
1294  forest.reDim(thedim);
1295  work = vec.get_ptr();
1296 
1302 
1304  spx_realloc(u.row.len, thedim + 1);
1305  spx_realloc(u.row.max, thedim + 1);
1306  spx_realloc(u.row.start, thedim + 1);
1307 
1309  spx_realloc(u.col.len, thedim + 1);
1310  spx_realloc(u.col.max, thedim + 1);
1311  spx_realloc(u.col.start, thedim + 1);
1312 
1314 
1317  }
1318  // the last factorization was reasonably stable, so we decrease the Markowitz threshold (stored in lastThreshold) in
1319  // order to favour sparsity
1320  else if (lastStability > 2.0 * minStability)
1321  {
1322  // we reset lastThreshold to its previous value in the sequence minThreshold, betterThreshold(minThreshold),
1323  // betterThreshold(betterThreshold(minThreshold)), ...
1324  Real last = minThreshold;
1325  Real better = betterThreshold(last);
1326  while (better < lastThreshold)
1327  {
1328  last = better;
1329  better = betterThreshold(last);
1330  }
1331  lastThreshold = last;
1332 
1333  // we reset the minimum stability (which might have been decreased below) to ensure that the increased sparsity
1334  // does not hurt the stability
1335  minStability = 2 * MINSTABILITY;
1336  }
1337 
1338  u.row.list.idx = thedim;
1339  u.row.start[thedim] = 0;
1340  u.row.max[thedim] = 0;
1341  u.row.len[thedim] = 0;
1342 
1343  u.col.list.idx = thedim;
1344  u.col.start[thedim] = 0;
1345  u.col.max[thedim] = 0;
1346  u.col.len[thedim] = 0;
1347 
1348  for (;;)
1349  {
1350  ///@todo if the factorization fails with stat = SINGULAR, distinuish between proven singularity (e.g., because of
1351  ///an empty column) and singularity due to numerics, that could be avoided by changing minStability and
1352  ///lastThreshold; in the first case, we want to abort, otherwise change the numerics
1353  stat = OK;
1354  factor(matrix, lastThreshold, epsilon);
1355 
1356  // finish if the factorization is stable
1357  if (stability() >= minStability)
1358  break;
1359 
1360  // otherwise, we increase the Markowitz threshold
1361  Real x = lastThreshold;
1363 
1364  // until it doesn't change anymore at its maximum value
1365  if (EQ(x, lastThreshold))
1366  break;
1367 
1368  // we relax the stability requirement
1369  minStability /= 2.0;
1370 
1371  MSG_INFO3( (*spxout), (*spxout) << "ISLUFA01 refactorizing with increased Markowitz threshold: "
1372  << lastThreshold << std::endl; )
1373  }
1374  MSG_DEBUG( std::cout << "DSLUFA02 threshold = " << lastThreshold
1375  << "\tstability = " << stability()
1376  << "\tminStability = " << minStability << std::endl; )
1377  MSG_DEBUG(
1378  int i;
1379  FILE* fl = fopen("dump.lp", "w");
1380  std::cout << "DSLUFA03 Basis:\n";
1381  int j = 0;
1382  for (i = 0; i < dim(); ++i)
1383  j += matrix[i]->size();
1384  for (i = 0; i < dim(); ++i)
1385  {
1386  for (j = 0; j < matrix[i]->size(); ++j)
1387  fprintf(fl, "%8d %8d %16g\n",
1388  i + 1, matrix[i]->index(j) + 1, matrix[i]->value(j));
1389  }
1390  fclose(fl);
1391  std::cout << "DSLUFA04 LU-Factors:" << std::endl;
1392  dump();
1393 
1394  std::cout << "DSLUFA05 threshold = " << lastThreshold
1395  << "\tstability = " << stability() << std::endl;
1396  )
1397 
1398  assert(isConsistent());
1399  return Status(stat);
1400 }
1401 
1402 
1404 {
1405 #ifdef ENABLE_CONSISTENCY_CHECKS
1406  return CLUFactor::isConsistent();
1407 #else
1408  return true;
1409 #endif
1410 }
1411 
1412 void SLUFactor::dump() const
1413 {
1414  CLUFactor::dump();
1415 }
1416 } // 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:253
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:106
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:212
std::string statistics() const
Definition: slufactor.cpp:634
#define REAL(x)
Definition: spxdefines.h:218
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:1271
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:363
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:228
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:387
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:1245
void solveRight4update(SSVector &x, const SVector &b)
Solves .
Definition: slufactor.cpp:66
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:238
R & value(int n)
Reference to value of n &#39;th nonzero.
Definition: svectorbase.h:254
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:215
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:129
bool isConsistent() const
consistency check.
Definition: slufactor.cpp:1403
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:599
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:119
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:565
Debugging, floating point type and parameter definitions.
void setSize(int n)
Sets number of nonzeros (thereby unSetup SSVectorBase).
Definition: ssvectorbase.h:580
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:375
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
Implementation of sparse LU factorization.This class implements a sparse LU factorization with either...
Definition: clufactor.h:37
void setup_and_assign(SSVectorBase< S > &rhs)
Sets up rhs vector, and assigns it.
Definition: ssvectorbase.h:717
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:223
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:243
#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:1412
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:1255
SLinSolver::Status Status
for convenience
Definition: slufactor.h:55
virtual TYPE type()=0
return type of timer