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-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@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 "soplex/spxdefines.h"
27 #include "soplex/slufactor.h"
28 #include "soplex/cring.h"
29 #include "soplex/spxalloc.h"
30 #include "soplex/spxout.h"
31 #include "soplex/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 
80  if(l.updateType == ETA)
81  {
83  ssvec.altValues(), ssvec.altIndexMem(), n, 0, 0, 0);
84  x.setSize(m);
85  //x.forceSetup();
86  x.unSetup();
88  }
89  else
90  {
91  forest.clear();
95  forest.setSize(f);
97  x.setSize(m);
98  x.forceSetup();
99  }
100 
101  usetup = true;
102  ssvec.setSize(0);
103  ssvec.forceSetup();
104 
105  solveCount++;
106  solveTime->stop();
107 }
108 
110  SSVector& x,
111  Vector& y,
112  const SVector& b,
113  SSVector& rhs)
114 {
115 
116  solveTime->start();
117 
118  int m;
119  int n;
120  int f;
121  int* sidx = ssvec.altIndexMem();
122  ssvec.setSize(0);
123  ssvec.forceSetup();
124  int rsize = rhs.size();
125  int* ridx = rhs.altIndexMem();
126 
127  x.clear();
128  y.clear();
129  usetup = true;
130  ssvec = b;
131 
132  if(l.updateType == ETA)
133  {
134  n = ssvec.size();
136  ssvec.get_ptr(), sidx, n, y.get_ptr(),
137  rhs.getEpsilon(), rhs.altValues(), ridx, rsize, 0, 0, 0);
138  x.setSize(m);
139  // x.forceSetup();
140  x.unSetup();
142  }
143  else
144  {
145  forest.clear();
146  n = ssvec.size();
148  ssvec.get_ptr(), sidx, n, y.get_ptr(),
149  rhs.getEpsilon(), rhs.altValues(), ridx, rsize,
151  x.setSize(m);
152  x.forceSetup();
153  forest.setSize(f);
154  forest.forceSetup();
155  }
156 
157  rhs.forceSetup();
158  ssvec.setSize(0);
159  ssvec.forceSetup();
160 
161  solveCount += 2;
162  solveTime->stop();
163 }
164 
166  SSVector& x,
167  SSVector& y,
168  const SVector& b,
169  SSVector& rhs)
170 {
171 
172  solveTime->start();
173 
174  int n;
175  int f;
176  int* sidx = ssvec.altIndexMem();
177  ssvec.setSize(0);
178  ssvec.forceSetup();
179  int rsize = rhs.size();
180  int* ridx = rhs.altIndexMem();
181 
182  x.clear();
183  y.clear();
184  usetup = true;
185  ssvec = b;
186 
187  if(l.updateType == ETA)
188  {
189  n = ssvec.size();
191  ssvec.get_ptr(), sidx, n,
192  y.getEpsilon(), y.altValues(), y.altIndexMem(),
193  rhs.altValues(), ridx, rsize,
194  0, 0, 0);
195  x.setSize(n);
196  // x.forceSetup();
197  x.unSetup();
198  y.setSize(rsize);
199  y.unSetup();
201  }
202  else
203  {
204  forest.clear();
205  n = ssvec.size();
207  ssvec.get_ptr(), sidx, n,
208  y.getEpsilon(), y.altValues(), y.altIndexMem(),
209  rhs.altValues(), ridx, rsize,
211  x.setSize(n);
212  x.forceSetup();
213  y.setSize(rsize);
214  y.forceSetup();
215  forest.setSize(f);
216  forest.forceSetup();
217  }
218 
219  rhs.forceSetup();
220  ssvec.setSize(0);
221  ssvec.forceSetup();
222 
223  solveCount += 2;
224  solveTime->stop();
225 }
226 
227 
229  SSVector& x,
230  Vector& y,
231  Vector& y2,
232  const SVector& b,
233  SSVector& rhs,
234  SSVector& rhs2)
235 {
236 
237  solveTime->start();
238 
239  int m;
240  int n;
241  int f;
242  int* sidx = ssvec.altIndexMem();
243  ssvec.setSize(0);
244  ssvec.forceSetup();
245  int rsize = rhs.size();
246  int* ridx = rhs.altIndexMem();
247  int rsize2 = rhs2.size();
248  int* ridx2 = rhs2.altIndexMem();
249 
250  x.clear();
251  y.clear();
252  y2.clear();
253  usetup = true;
254  ssvec = b;
255 
256  if(l.updateType == ETA)
257  {
258  n = ssvec.size();
260  x.altValues(), x.altIndexMem(), ssvec.get_ptr(), sidx, n,
261  y.get_ptr(), rhs.getEpsilon(), rhs.altValues(), ridx, rsize,
262  y2.get_ptr(), rhs2.getEpsilon(), rhs2.altValues(), ridx2, rsize2,
263  0, 0, 0);
264  x.setSize(m);
265  // x.forceSetup();
266  x.unSetup();
268  }
269  else
270  {
271  forest.clear();
272  n = ssvec.size();
274  x.altValues(), x.altIndexMem(), ssvec.get_ptr(), sidx, n,
275  y.get_ptr(), rhs.getEpsilon(), rhs.altValues(), ridx, rsize,
276  y2.get_ptr(), rhs2.getEpsilon(), rhs2.altValues(), ridx2, rsize2,
278  x.setSize(m);
279  x.forceSetup();
280  forest.setSize(f);
281  forest.forceSetup();
282  }
283 
284  rhs.forceSetup();
285  rhs2.forceSetup();
286  ssvec.setSize(0);
287  ssvec.forceSetup();
288 
289  solveCount += 3;
290  solveTime->stop();
291 }
292 
294  SSVector& x,
295  SSVector& y,
296  SSVector& y2,
297  const SVector& b,
298  SSVector& rhs,
299  SSVector& rhs2)
300 {
301  solveTime->start();
302 
303  int n;
304  int f;
305  int* sidx = ssvec.altIndexMem();
306  ssvec.setSize(0);
307  ssvec.forceSetup();
308  int rsize = rhs.size();
309  int* ridx = rhs.altIndexMem();
310  int rsize2 = rhs2.size();
311  int* ridx2 = rhs2.altIndexMem();
312 
313  x.clear();
314  y.clear();
315  y2.clear();
316  usetup = true;
317  ssvec = b;
318 
319  if(l.updateType == ETA)
320  {
321  n = ssvec.size();
323  ssvec.get_ptr(), sidx, n,
324  y.getEpsilon(), y.altValues(), y.altIndexMem(),
325  rhs.altValues(), ridx, rsize,
326  y2.getEpsilon(), y2.altValues(), y2.altIndexMem(),
327  rhs2.altValues(), ridx2, rsize2,
328  0, 0, 0);
329  x.setSize(n);
330  // x.forceSetup();
331  x.unSetup();
332  y.setSize(rsize);
333  y.unSetup();
334  y2.setSize(rsize2);
335  y2.unSetup();
337  }
338  else
339  {
340  forest.clear();
341  n = ssvec.size();
343  ssvec.get_ptr(), sidx, n,
344  y.getEpsilon(), y.altValues(), y.altIndexMem(),
345  rhs.altValues(), ridx, rsize,
346  y2.getEpsilon(), y2.altValues(), y2.altIndexMem(),
347  rhs2.altValues(), ridx2, rsize2,
349  x.setSize(n);
350  x.forceSetup();
351  y.setSize(rsize);
352  y.forceSetup();
353  y2.setSize(rsize2);
354  y2.forceSetup();
355 
356  forest.setSize(f);
357  forest.forceSetup();
358  }
359 
360  rhs.forceSetup();
361  rhs2.forceSetup();
362  ssvec.setSize(0);
363  ssvec.forceSetup();
364 
365  solveCount += 3;
366  solveTime->stop();
367 }
368 
369 
370 void SLUFactor::solveLeft(Vector& x, const Vector& b) //const
371 {
372 
373  solveTime->start();
374 
375  vec = b;
376  x.clear();
378 
379  solveCount++;
380  solveTime->stop();
381 }
382 
383 void SLUFactor::solveLeft(SSVector& x, const SVector& b) //const
384 {
385 
386  solveTime->start();
387 
388  // copy to SSVec is done to avoid having to deal with the Nonzero datatype
389  // TODO change SVec to standard sparse format
390  ssvec.assign(b);
391 
392  x.clear();
393  int sz = ssvec.size(); // see .altValues()
394  int n = vSolveLeft(x.getEpsilon(), x.altValues(), x.altIndexMem(),
395  ssvec.altValues(), ssvec.altIndexMem(), sz);
396 
397  if(n > 0)
398  {
399  x.setSize(n);
400  x.forceSetup();
401  }
402  else
403  x.unSetup();
404 
405  ssvec.setSize(0);
406  ssvec.forceSetup();
407 
408  solveCount++;
409  solveTime->stop();
410 }
411 
413  SSVector& x,
414  Vector& y,
415  const SVector& rhs1,
416  SSVector& rhs2) //const
417 {
418 
419  solveTime->start();
420 
421  int n;
422  Real* svec = ssvec.altValues();
423  int* sidx = ssvec.altIndexMem();
424  int rn = rhs2.size();
425  int* ridx = rhs2.altIndexMem();
426 
427  x.clear();
428  y.clear();
429  ssvec.assign(rhs1);
430  n = ssvec.size(); // see altValues();
431  n = vSolveLeft2(x.getEpsilon(), x.altValues(), x.altIndexMem(), svec, sidx, n,
432  y.get_ptr(), rhs2.altValues(), ridx, rn);
433 
434  // this will unsetup x
435  x.setSize(n);
436 
437  if(n > 0)
438  x.forceSetup();
439 
440  ssvec.setSize(0);
441  ssvec.forceSetup();
442 
443  solveCount += 2;
444  solveTime->stop();
445 }
446 
448  SSVector& x,
449  SSVector& y,
450  const SVector& rhs1,
451  SSVector& rhs2) //const
452 {
453 
454  solveTime->start();
455 
456  int n1, n2;
457  Real* svec = ssvec.altValues();
458  int* sidx = ssvec.altIndexMem();
459 
460  x.clear();
461  y.clear();
462  ssvec.assign(rhs1);
463  n1 = ssvec.size(); // see altValues();
464  n2 = rhs2.size();
465 
466  if(n2 < 10)
467  {
469  x.altValues(), x.altIndexMem(),
470  svec, sidx, n1,
471  y.altValues(), y.altIndexMem(),
472  rhs2.altValues(), rhs2.altIndexMem(), n2);
473  y.setSize(n2);
474 
475  if(n2 > 0)
476  y.forceSetup();
477  }
478  else
479  {
480  n1 = vSolveLeft2(x.getEpsilon(), x.altValues(), x.altIndexMem(), svec, sidx, n1,
481  y.altValues(), rhs2.altValues(), rhs2.altIndexMem(), n2);
482  // y.setup();
483  }
484 
485  x.setSize(n1);
486 
487  if(n1 > 0)
488  x.forceSetup();
489 
490  // if (n2 > 0)
491  // y.forceSetup();
492 
493  ssvec.setSize(0);
494  ssvec.forceSetup();
495 
496  solveCount += 2;
497  solveTime->stop();
498 }
499 
500 
502  SSVector& x,
503  Vector& y,
504  Vector& z,
505  const SVector& rhs1,
506  SSVector& rhs2,
507  SSVector& rhs3)
508 {
509 
510  solveTime->start();
511 
512  int n, n2, n3;
513  Real* svec = ssvec.altValues();
514  int* sidx = ssvec.altIndexMem();
515 
516  x.clear();
517  y.clear();
518  z.clear();
519  ssvec.assign(rhs1);
520  n = ssvec.size(); // see altValues();
521  n2 = rhs2.size();
522  n3 = rhs3.size();
523 
524  n = vSolveLeft3(x.getEpsilon(), x.altValues(), x.altIndexMem(), svec, sidx, n,
525  y.get_ptr(), rhs2.altValues(), rhs2.altIndexMem(), n2,
526  z.get_ptr(), rhs3.altValues(), rhs3.altIndexMem(), n3);
527 
528  x.setSize(n);
529 
530  if(n > 0)
531  x.forceSetup();
532 
533  ssvec.setSize(0);
534  ssvec.forceSetup();
535 
536  solveCount += 3;
537  solveTime->stop();
538 }
539 
541  SSVector& x,
542  SSVector& y,
543  SSVector& z,
544  const SVector& rhs1,
545  SSVector& rhs2,
546  SSVector& rhs3)
547 {
548 
549  solveTime->start();
550 
551  int n1, n2, n3;
552  Real* svec = ssvec.altValues();
553  int* sidx = ssvec.altIndexMem();
554 
555  x.clear();
556  y.clear();
557  z.clear();
558  ssvec.assign(rhs1);
559  n1 = ssvec.size(); // see altValues();
560  n2 = rhs2.size();
561  n3 = rhs3.size();
563  x.altValues(), x.altIndexMem(),
564  svec, sidx, n1,
565  y.altValues(), y.altIndexMem(),
566  rhs2.altValues(), rhs2.altIndexMem(), n2,
567  z.altValues(), z.altIndexMem(),
568  rhs3.altValues(), rhs3.altIndexMem(), n3);
569  x.setSize(n1);
570  y.setSize(n2);
571  z.setSize(n3);
572 
573  if(n1 > 0)
574  x.forceSetup();
575 
576  if(n2 > 0)
577  y.forceSetup();
578 
579  if(n3 > 0)
580  z.forceSetup();
581 
582  ssvec.setSize(0);
583  ssvec.forceSetup();
584 
585  solveCount += 3;
586  solveTime->stop();
587 }
588 
589 
591 {
592  if(status() != OK)
593  return 0;
594 
595  if(maxabs < initMaxabs)
596  return 1;
597 
598  assert(maxabs != 0.0);
599  return initMaxabs / maxabs;
600 }
601 
603 {
604  Real result = 0.0;
605 
606  // catch corner case of empty matrix
607  if(dim() == 0)
608  return 1.0;
609 
610  switch(type)
611  {
612  // compute estimate by ratio of max/min of elements on the diagonal
613  case 0:
614  {
615  Real mindiag = spxAbs(diag[0]);
616  Real maxdiag = spxAbs(diag[0]);
617 
618  for(int i = 1; i < dim(); ++i)
619  {
620  Real absdiag = spxAbs(diag[i]);
621 
622  if(absdiag < mindiag)
623  mindiag = absdiag;
624 
625  if(absdiag > maxdiag)
626  maxdiag = absdiag;
627  }
628 
629  result = maxdiag / mindiag;
630  break;
631  }
632 
633  // compute estimate by summing up the elements on the diagonal
634  case 1:
635  result = diag[0];
636 
637  for(int i = 1; i < dim(); ++i)
638  result += spxAbs(diag[i]);
639 
640  break;
641 
642  // compute estimate by multiplying the elements on the diagonal
643  case 2:
644  result = diag[0];
645 
646  for(int i = 1; i < dim(); ++i)
647  result *= spxAbs(diag[i]);
648 
649  break;
650  }
651 
652  return result;
653 }
654 
655 std::string SLUFactor::statistics() const
656 {
657  std::stringstream s;
658  s << "Factorizations : " << std::setw(10) << getFactorCount() << std::endl
659  << " Time spent : " << std::setw(10) << std::fixed << std::setprecision(
660  2) << getFactorTime() << std::endl
661  << "Solves : " << std::setw(10) << getSolveCount() << std::endl
662  << " Time spent : " << std::setw(10) << getSolveTime() << std::endl;
663 
664  return s.str();
665 }
666 
667 void SLUFactor::changeEta(int idx, SSVector& et)
668 {
669 
670  int es = et.size(); // see altValues()
671  update(idx, et.altValues(), et.altIndexMem(), es);
672  et.setSize(0);
673  et.forceSetup();
674 }
675 
677  int idx,
678  const SVector& subst,
679  const SSVector* e)
680 {
681 
682  // BH 2005-08-23: The boolean usetup indicates that an "update vector"
683  // has been set up. I suppose that SSVector forest is this
684  // update vector, which is set up by solveRight4update() and
685  // solve2right4update() in order to optimize the basis update.
686 
687  if(usetup)
688  {
689  if(l.updateType == FOREST_TOMLIN) // FOREST_TOMLIN updates
690  {
691  // BH 2005-08-19: The size of a SSVector is the size of the
692  // index set, i.e. the number of nonzeros which is only
693  // defined if the SSVector is set up. Since
694  // SSVector::altValues() calls unSetup() the size needs to be
695  // stored before the following call.
696  int fsize = forest.size(); // see altValues()
697  forestUpdate(idx, forest.altValues(), fsize, forest.altIndexMem());
698  forest.setSize(0);
699  forest.forceSetup();
700  }
701  else
702  {
703  assert(l.updateType == ETA);
704  changeEta(idx, eta);
705  }
706  }
707  else if(e != 0) // ETA updates
708  {
709  l.updateType = ETA;
710  updateNoClear(idx, e->values(), e->indexMem(), e->size());
711  l.updateType = uptype;
712  }
713  else if(l.updateType == FOREST_TOMLIN) // FOREST_TOMLIN updates
714  {
715  assert(0); // probably this part is never called.
716  // forestUpdate() with the last parameter set to NULL should fail.
717  forest = subst;
719  forestUpdate(idx, forest.altValues(), 0, 0);
720  forest.setSize(0);
721  forest.forceSetup();
722  }
723  else // ETA updates
724  {
725  assert(l.updateType == ETA);
726  vec = subst;
727  eta.clear();
729  changeEta(idx, eta);
730  }
731 
732  usetup = false;
733 
734  MSG_DEBUG(std::cout << "DSLUFA01\tupdated\t\tstability = " << stability()
735  << std::endl;)
736 
737  return status();
738 }
739 
741 {
742 
743  rowMemMult = 5; /* factor of minimum Memory * #of nonzeros */
744  colMemMult = 5; /* factor of minimum Memory * #of nonzeros */
745  lMemMult = 1; /* factor of minimum Memory * #of nonzeros */
746 
747  l.firstUpdate = 0;
748  l.firstUnused = 0;
749  thedim = 0;
750 
752  usetup = false;
753  maxabs = 1;
754  initMaxabs = 1;
757  stat = UNLOADED;
758 
759  vec.clear();
760  eta.clear();
761  ssvec.clear();
762  forest.clear();
763 
764  u.row.size = 100;
765  u.col.size = 100;
766  l.size = 100;
767  l.startSize = 100;
768 
769  if(l.rval)
770  spx_free(l.rval);
771 
772  if(l.ridx)
773  spx_free(l.ridx);
774 
775  if(l.rbeg)
776  spx_free(l.rbeg);
777 
778  if(l.rorig)
779  spx_free(l.rorig);
780 
781  if(l.rperm)
782  spx_free(l.rperm);
783 
784  if(u.row.val)
785  spx_free(u.row.val);
786 
787  if(u.row.idx)
788  spx_free(u.row.idx);
789 
790  if(u.col.idx)
791  spx_free(u.col.idx);
792 
793  if(l.val)
794  spx_free(l.val);
795 
796  if(l.idx)
797  spx_free(l.idx);
798 
799  if(l.start)
800  spx_free(l.start);
801 
802  if(l.row)
803  spx_free(l.row);
804 
805  // G clear() is used in constructor of SLUFactor so we have to
806  // G clean up if anything goes wrong here
807  try
808  {
809  spx_alloc(u.row.val, u.row.size);
810  spx_alloc(u.row.idx, u.row.size);
811  spx_alloc(u.col.idx, u.col.size);
812 
813  spx_alloc(l.val, l.size);
814  spx_alloc(l.idx, l.size);
817  }
818  catch(const SPxMemoryException& x)
819  {
820  freeAll();
821  throw x;
822  }
823 }
824 
825 /** assignment used to implement operator=() and copy constructor.
826  * If this is initialised, freeAll() has to be called before.
827  * Class objects from SLUFactor are not copied here.
828  */
829 void SLUFactor::assign(const SLUFactor& old)
830 {
831  spxout = old.spxout;
832 
835 
836  // slufactor
837  uptype = old.uptype;
840  epsilon = old.epsilon;
842 
843  // clufactor
844  stat = old.stat;
845  thedim = old.thedim;
846  nzCnt = old.nzCnt;
847  initMaxabs = old.initMaxabs;
848  maxabs = old.maxabs;
849  rowMemMult = old.rowMemMult;
850  colMemMult = old.colMemMult;
851  lMemMult = old.lMemMult;
852 
858 
859  memcpy(row.perm, old.row.perm, (unsigned int)thedim * sizeof(*row.perm));
860  memcpy(row.orig, old.row.orig, (unsigned int)thedim * sizeof(*row.orig));
861  memcpy(col.perm, old.col.perm, (unsigned int)thedim * sizeof(*col.perm));
862  memcpy(col.orig, old.col.orig, (unsigned int)thedim * sizeof(*col.orig));
863  memcpy(diag, old.diag, (unsigned int)thedim * sizeof(*diag));
864 
865  work = vec.get_ptr();
866 
867  /* setup U
868  */
869  u.row.size = old.u.row.size;
870  u.row.used = old.u.row.used;
871 
873  spx_alloc(u.row.val, u.row.size);
874  spx_alloc(u.row.idx, u.row.size);
875  spx_alloc(u.row.start, thedim + 1);
876  spx_alloc(u.row.len, thedim + 1);
877  spx_alloc(u.row.max, thedim + 1);
878 
879  memcpy(u.row.elem, old.u.row.elem, (unsigned int)thedim * sizeof(*u.row.elem));
880  memcpy(u.row.val, old.u.row.val, (unsigned int)u.row.size * sizeof(*u.row.val));
881  memcpy(u.row.idx, old.u.row.idx, (unsigned int)u.row.size * sizeof(*u.row.idx));
882  memcpy(u.row.start, old.u.row.start, (unsigned int)(thedim + 1) * sizeof(*u.row.start));
883  memcpy(u.row.len, old.u.row.len, (unsigned int)(thedim + 1) * sizeof(*u.row.len));
884  memcpy(u.row.max, old.u.row.max, (unsigned int)(thedim + 1) * sizeof(*u.row.max));
885 
886  // need to make row list ok ?
887  if(thedim > 0 && stat == OK)
888  {
889  u.row.list.idx = old.u.row.list.idx; // .idx neu
890 
891  const Dring* oring = &old.u.row.list;
892  Dring* ring = &u.row.list;
893 
894  while(oring->next != &old.u.row.list)
895  {
896  ring->next = &u.row.elem[oring->next->idx];
897  ring->next->prev = ring;
898  oring = oring->next;
899  ring = ring->next;
900  }
901 
902  ring->next = &u.row.list;
903  ring->next->prev = ring;
904  }
905 
906  u.col.size = old.u.col.size;
907  u.col.used = old.u.col.used;
908 
910  spx_alloc(u.col.idx, u.col.size);
911  spx_alloc(u.col.start, thedim + 1);
912  spx_alloc(u.col.len, thedim + 1);
913  spx_alloc(u.col.max, thedim + 1);
914 
915  if(old.u.col.val != 0)
916  {
917  spx_alloc(u.col.val, u.col.size);
918  memcpy(u.col.val, old.u.col.val, (unsigned int)u.col.size * sizeof(*u.col.val));
919  }
920  else
921  u.col.val = 0;
922 
923  memcpy(u.col.elem, old.u.col.elem, (unsigned int)thedim * sizeof(*u.col.elem));
924  memcpy(u.col.idx, old.u.col.idx, (unsigned int)u.col.size * sizeof(*u.col.idx));
925  memcpy(u.col.start, old.u.col.start, (unsigned int)(thedim + 1) * sizeof(*u.col.start));
926  memcpy(u.col.len, old.u.col.len, (unsigned int)(thedim + 1) * sizeof(*u.col.len));
927  memcpy(u.col.max, old.u.col.max, (unsigned int)(thedim + 1) * sizeof(*u.col.max));
928 
929  // need to make col list ok
930  if(thedim > 0 && stat == OK)
931  {
932  u.col.list.idx = old.u.col.list.idx; // .idx neu
933 
934  const Dring* oring = &old.u.col.list;
935  Dring* ring = &u.col.list;
936 
937  while(oring->next != &old.u.col.list)
938  {
939  ring->next = &u.col.elem[oring->next->idx];
940  ring->next->prev = ring;
941  oring = oring->next;
942  ring = ring->next;
943  }
944 
945  ring->next = &u.col.list;
946  ring->next->prev = ring;
947  }
948 
949  /* Setup L
950  */
951  l.size = old.l.size;
952  l.startSize = old.l.startSize;
953  l.firstUpdate = old.l.firstUpdate;
954  l.firstUnused = old.l.firstUnused;
955  l.updateType = old.l.updateType;
956 
957  spx_alloc(l.val, l.size);
958  spx_alloc(l.idx, l.size);
961 
962  memcpy(l.val, old.l.val, (unsigned int)l.size * sizeof(*l.val));
963  memcpy(l.idx, old.l.idx, (unsigned int)l.size * sizeof(*l.idx));
964  memcpy(l.start, old.l.start, (unsigned int)l.startSize * sizeof(*l.start));
965  memcpy(l.row, old.l.row, (unsigned int)l.startSize * sizeof(*l.row));
966 
967  if(old.l.rval != 0)
968  {
969  assert(old.l.ridx != 0);
970  assert(old.l.rbeg != 0);
971  assert(old.l.rorig != 0);
972  assert(old.l.rperm != 0);
973 
974  int memsize = l.start[l.firstUpdate];
975 
976  spx_alloc(l.rval, memsize);
977  spx_alloc(l.ridx, memsize);
978  spx_alloc(l.rbeg, thedim + 1);
981 
982  memcpy(l.rval, old.l.rval, (unsigned int)memsize * sizeof(*l.rval));
983  memcpy(l.ridx, old.l.ridx, (unsigned int)memsize * sizeof(*l.ridx));
984  memcpy(l.rbeg, old.l.rbeg, (unsigned int)(thedim + 1) * sizeof(*l.rbeg));
985  memcpy(l.rorig, old.l.rorig, (unsigned int)thedim * sizeof(*l.rorig));
986  memcpy(l.rperm, old.l.rperm, (unsigned int)thedim * sizeof(*l.rperm));
987  }
988  else
989  {
990  assert(old.l.ridx == 0);
991  assert(old.l.rbeg == 0);
992  assert(old.l.rorig == 0);
993  assert(old.l.rperm == 0);
994 
995  l.rval = 0;
996  l.ridx = 0;
997  l.rbeg = 0;
998  l.rorig = 0;
999  l.rperm = 0;
1000  }
1001 
1002  assert(row.perm != 0);
1003  assert(row.orig != 0);
1004  assert(col.perm != 0);
1005  assert(col.orig != 0);
1006  assert(diag != 0);
1007 
1008  assert(u.row.elem != 0);
1009  assert(u.row.val != 0);
1010  assert(u.row.idx != 0);
1011  assert(u.row.start != 0);
1012  assert(u.row.len != 0);
1013  assert(u.row.max != 0);
1014 
1015  assert(u.col.elem != 0);
1016  assert(u.col.idx != 0);
1017  assert(u.col.start != 0);
1018  assert(u.col.len != 0);
1019  assert(u.col.max != 0);
1020 
1021  assert(l.val != 0);
1022  assert(l.idx != 0);
1023  assert(l.start != 0);
1024  assert(l.row != 0);
1025 
1026 }
1027 
1029 {
1030 
1031  if(this != &old)
1032  {
1033  // we don't need to copy them, because they are temporary vectors
1034  vec.clear();
1035  ssvec.clear();
1036 
1037  eta = old.eta;
1038  forest = old.forest;
1039 
1040  timerType = old.timerType;
1041 
1042  freeAll();
1043 
1044  try
1045  {
1046  assign(old);
1047  }
1048  catch(const SPxMemoryException& x)
1049  {
1050  freeAll();
1051  throw x;
1052  }
1053 
1054  assert(isConsistent());
1055  }
1056 
1057  return *this;
1058 }
1059 
1061  : vec(1)
1062  , ssvec(1)
1063  , usetup(false)
1065  , eta(1)
1066  , forest(1)
1067  , minThreshold(0.01)
1068  , timerType(Timer::USER_TIME)
1069 {
1070  row.perm = 0;
1071  row.orig = 0;
1072  col.perm = 0;
1073  col.orig = 0;
1074  diag = 0;
1075  u.row.elem = 0;
1076  u.row.val = 0;
1077  u.row.idx = 0;
1078  u.row.start = 0;
1079  u.row.len = 0;
1080  u.row.max = 0;
1081  u.col.elem = 0;
1082  u.col.idx = 0;
1083  u.col.start = 0;
1084  u.col.len = 0;
1085  u.col.max = 0;
1086  u.col.val = 0;
1087  l.val = 0;
1088  l.idx = 0;
1089  l.start = 0;
1090  l.row = 0;
1091  l.rval = 0;
1092  l.ridx = 0;
1093  l.rbeg = 0;
1094  l.rorig = 0;
1095  l.rperm = 0;
1096 
1097  nzCnt = 0;
1098  thedim = 0;
1099 
1100  try
1101  {
1108  spx_alloc(diag, thedim);
1109 
1110  work = vec.get_ptr();
1111 
1112  u.row.size = 1;
1113  u.row.used = 0;
1115  spx_alloc(u.row.val, u.row.size);
1116  spx_alloc(u.row.idx, u.row.size);
1117  spx_alloc(u.row.start, thedim + 1);
1118  spx_alloc(u.row.len, thedim + 1);
1119  spx_alloc(u.row.max, thedim + 1);
1120 
1121  u.row.list.idx = thedim;
1122  u.row.start[thedim] = 0;
1123  u.row.max [thedim] = 0;
1124  u.row.len [thedim] = 0;
1125 
1126  u.col.size = 1;
1127  u.col.used = 0;
1129  spx_alloc(u.col.idx, u.col.size);
1130  spx_alloc(u.col.start, thedim + 1);
1131  spx_alloc(u.col.len, thedim + 1);
1132  spx_alloc(u.col.max, thedim + 1);
1133  u.col.val = 0;
1134 
1135  u.col.list.idx = thedim;
1136  u.col.start[thedim] = 0;
1137  u.col.max[thedim] = 0;
1138  u.col.len[thedim] = 0;
1139 
1140  l.size = 1;
1141 
1142  spx_alloc(l.val, l.size);
1143  spx_alloc(l.idx, l.size);
1144 
1145  l.startSize = 1;
1146  l.firstUpdate = 0;
1147  l.firstUnused = 0;
1148 
1151  }
1152  catch(const SPxMemoryException& x)
1153  {
1154  freeAll();
1155  throw x;
1156  }
1157 
1158  l.rval = 0;
1159  l.ridx = 0;
1160  l.rbeg = 0;
1161  l.rorig = 0;
1162  l.rperm = 0;
1163 
1164  SLUFactor::clear(); // clear() is virtual
1165 
1166  factorCount = 0;
1167  solveCount = 0;
1168 
1169  assert(row.perm != 0);
1170  assert(row.orig != 0);
1171  assert(col.perm != 0);
1172  assert(col.orig != 0);
1173  assert(diag != 0);
1174 
1175  assert(u.row.elem != 0);
1176  assert(u.row.val != 0);
1177  assert(u.row.idx != 0);
1178  assert(u.row.start != 0);
1179  assert(u.row.len != 0);
1180  assert(u.row.max != 0);
1181 
1182  assert(u.col.elem != 0);
1183  assert(u.col.idx != 0);
1184  assert(u.col.start != 0);
1185  assert(u.col.len != 0);
1186  assert(u.col.max != 0);
1187 
1188  assert(l.val != 0);
1189  assert(l.idx != 0);
1190  assert(l.start != 0);
1191  assert(l.row != 0);
1192 
1193  assert(SLUFactor::isConsistent());
1194 }
1195 
1197  : SLinSolver(old)
1198  , vec(1) // we don't need to copy it, because they are temporary vectors
1199  , ssvec(1) // we don't need to copy it, because they are temporary vectors
1200  , usetup(old.usetup)
1201  , eta(old.eta)
1202  , forest(old.forest)
1203  , timerType(old.timerType)
1204 {
1205  row.perm = 0;
1206  row.orig = 0;
1207  col.perm = 0;
1208  col.orig = 0;
1209  diag = 0;
1210  u.row.elem = 0;
1211  u.row.val = 0;
1212  u.row.idx = 0;
1213  u.row.start = 0;
1214  u.row.len = 0;
1215  u.row.max = 0;
1216  u.col.elem = 0;
1217  u.col.idx = 0;
1218  u.col.start = 0;
1219  u.col.len = 0;
1220  u.col.max = 0;
1221  u.col.val = 0;
1222  l.val = 0;
1223  l.idx = 0;
1224  l.start = 0;
1225  l.row = 0;
1226  l.rval = 0;
1227  l.ridx = 0;
1228  l.rbeg = 0;
1229  l.rorig = 0;
1230  l.rperm = 0;
1231 
1232  solveCount = 0;
1235 
1236  try
1237  {
1238  assign(old);
1239  }
1240  catch(const SPxMemoryException& x)
1241  {
1242  freeAll();
1243  throw x;
1244  }
1245 
1246  assert(SLUFactor::isConsistent());
1247 }
1248 
1250 {
1251 
1252  if(row.perm)
1253  spx_free(row.perm);
1254 
1255  if(row.orig)
1256  spx_free(row.orig);
1257 
1258  if(col.perm)
1259  spx_free(col.perm);
1260 
1261  if(col.orig)
1262  spx_free(col.orig);
1263 
1264  if(u.row.elem)
1265  spx_free(u.row.elem);
1266 
1267  if(u.row.val)
1268  spx_free(u.row.val);
1269 
1270  if(u.row.idx)
1271  spx_free(u.row.idx);
1272 
1273  if(u.row.start)
1274  spx_free(u.row.start);
1275 
1276  if(u.row.len)
1277  spx_free(u.row.len);
1278 
1279  if(u.row.max)
1280  spx_free(u.row.max);
1281 
1282  if(u.col.elem)
1283  spx_free(u.col.elem);
1284 
1285  if(u.col.idx)
1286  spx_free(u.col.idx);
1287 
1288  if(u.col.start)
1289  spx_free(u.col.start);
1290 
1291  if(u.col.len)
1292  spx_free(u.col.len);
1293 
1294  if(u.col.max)
1295  spx_free(u.col.max);
1296 
1297  if(l.val)
1298  spx_free(l.val);
1299 
1300  if(l.idx)
1301  spx_free(l.idx);
1302 
1303  if(l.start)
1304  spx_free(l.start);
1305 
1306  if(l.row)
1307  spx_free(l.row);
1308 
1309  if(diag)
1310  spx_free(diag);
1311 
1312  if(u.col.val)
1313  spx_free(u.col.val);
1314 
1315  if(l.rval)
1316  spx_free(l.rval);
1317 
1318  if(l.ridx)
1319  spx_free(l.ridx);
1320 
1321  if(l.rbeg)
1322  spx_free(l.rbeg);
1323 
1324  if(l.rorig)
1325  spx_free(l.rorig);
1326 
1327  if(l.rperm)
1328  spx_free(l.rperm);
1329 }
1330 
1332 {
1333  freeAll();
1334 
1335  solveTime->~Timer();
1336  factorTime->~Timer();
1339 }
1340 
1342 {
1343  assert(th < REAL(1.0));
1344 
1345  if(LT(th, REAL(0.1)))
1346  th *= REAL(10.0);
1347  else if(LT(th, REAL(0.9)))
1348  th = (th + REAL(1.0)) / REAL(2.0);
1349  else if(LT(th, REAL(0.999)))
1350  th = REAL(0.99999);
1351 
1352  assert(th < REAL(1.0));
1353 
1354  return th;
1355 }
1356 
1358 {
1359  assert(dm >= 0);
1360  assert(matrix != 0);
1361 
1362  Real lastStability = stability();
1363 
1364  initDR(u.row.list);
1365  initDR(u.col.list);
1366 
1367  usetup = false;
1368  l.updateType = uptype;
1369  l.firstUpdate = 0;
1370  l.firstUnused = 0;
1371 
1372  if(dm != thedim)
1373  {
1374  clear();
1375 
1376  thedim = dm;
1377  vec.reDim(thedim);
1378  ssvec.reDim(thedim);
1379  eta.reDim(thedim);
1380  forest.reDim(thedim);
1381  work = vec.get_ptr();
1382 
1388 
1390  spx_realloc(u.row.len, thedim + 1);
1391  spx_realloc(u.row.max, thedim + 1);
1392  spx_realloc(u.row.start, thedim + 1);
1393 
1395  spx_realloc(u.col.len, thedim + 1);
1396  spx_realloc(u.col.max, thedim + 1);
1397  spx_realloc(u.col.start, thedim + 1);
1398 
1400 
1403  }
1404  // the last factorization was reasonably stable, so we decrease the Markowitz threshold (stored in lastThreshold) in
1405  // order to favour sparsity
1406  else if(lastStability > 2.0 * minStability)
1407  {
1408  // we reset lastThreshold to its previous value in the sequence minThreshold, betterThreshold(minThreshold),
1409  // betterThreshold(betterThreshold(minThreshold)), ...
1410  Real last = minThreshold;
1411  Real better = betterThreshold(last);
1412 
1413  while(better < lastThreshold)
1414  {
1415  last = better;
1416  better = betterThreshold(last);
1417  }
1418 
1419  lastThreshold = last;
1420 
1421  // we reset the minimum stability (which might have been decreased below) to ensure that the increased sparsity
1422  // does not hurt the stability
1423  minStability = 2 * MINSTABILITY;
1424  }
1425 
1426  u.row.list.idx = thedim;
1427  u.row.start[thedim] = 0;
1428  u.row.max[thedim] = 0;
1429  u.row.len[thedim] = 0;
1430 
1431  u.col.list.idx = thedim;
1432  u.col.start[thedim] = 0;
1433  u.col.max[thedim] = 0;
1434  u.col.len[thedim] = 0;
1435 
1436  for(;;)
1437  {
1438  ///@todo if the factorization fails with stat = SINGULAR, distinuish between proven singularity (e.g., because of
1439  ///an empty column) and singularity due to numerics, that could be avoided by changing minStability and
1440  ///lastThreshold; in the first case, we want to abort, otherwise change the numerics
1441  stat = OK;
1442  factor(matrix, lastThreshold, epsilon);
1443 
1444  // finish if the factorization is stable
1445  if(stability() >= minStability)
1446  break;
1447 
1448  // otherwise, we increase the Markowitz threshold
1449  Real x = lastThreshold;
1451 
1452  // until it doesn't change anymore at its maximum value
1453  if(EQ(x, lastThreshold))
1454  break;
1455 
1456  // we relax the stability requirement
1457  minStability /= 2.0;
1458 
1459  MSG_INFO3((*spxout), (*spxout) << "ISLUFA01 refactorizing with increased Markowitz threshold: "
1460  << lastThreshold << std::endl;)
1461  }
1462 
1463  MSG_DEBUG(std::cout << "DSLUFA02 threshold = " << lastThreshold
1464  << "\tstability = " << stability()
1465  << "\tminStability = " << minStability << std::endl;)
1466  MSG_DEBUG(
1467  int i;
1468  FILE* fl = fopen("dump.lp", "w");
1469  std::cout << "DSLUFA03 Basis:\n";
1470  int j = 0;
1471 
1472  for(i = 0; i < dim(); ++i)
1473  j += matrix[i]->size();
1474  for(i = 0; i < dim(); ++i)
1475  {
1476  for(j = 0; j < matrix[i]->size(); ++j)
1477  fprintf(fl, "%8d %8d %16g\n",
1478  i + 1, matrix[i]->index(j) + 1, matrix[i]->value(j));
1479  }
1480  fclose(fl);
1481  std::cout << "DSLUFA04 LU-Factors:" << std::endl;
1482  dump();
1483 
1484  std::cout << "DSLUFA05 threshold = " << lastThreshold
1485  << "\tstability = " << stability() << std::endl;
1486  )
1487 
1488  assert(isConsistent());
1489  return Status(stat);
1490 }
1491 
1492 
1494 {
1495 #ifdef ENABLE_CONSISTENCY_CHECKS
1496  return CLUFactor::isConsistent();
1497 #else
1498  return true;
1499 #endif
1500 }
1501 
1502 void SLUFactor::dump() const
1503 {
1504  CLUFactor::dump();
1505 }
1506 } // namespace soplex
Rational spxAbs(const Rational &r)
Absolute.
Definition: rational.cpp:4102
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:264
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:1321
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:109
Timer::TYPE timerType
Definition: slufactor.h:91
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:253
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:655
#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:5510
Status load(const SVector *vec[], int dim)
Definition: slufactor.cpp:1357
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:5926
SSVectorBase< R > & assign(const SVectorBase< S > &rhs)
Assigns only the elements of rhs.
Definition: basevectors.h:857
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:153
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:370
Real epsilon
|x| < epsililon is considered to be 0.
Definition: slufactor.h:88
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:86
Real getFactorTime() const
time spent in factorizations
Definition: slufactor.h:239
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:388
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:5778
void unSetup()
Makes SSVectorBase not setup.
Definition: ssvectorbase.h:127
U u
U matrix.
Definition: clufactor.h:200
Implementation of Sparse Linear Solver.
virtual ~SLUFactor()
destructor.
Definition: slufactor.cpp:1331
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:6194
Real lastThreshold
pivoting threshold of last factorization
Definition: slufactor.h:77
int size
size of array idx
Definition: clufactor.h:141
int getFactorCount() const
number of factorizations performed
Definition: slufactor.h:249
R & value(int n)
Reference to value of n &#39;th nonzero.
Definition: svectorbase.h:253
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:1277
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:4143
Real initMaxabs
maximum abs number in initail Matrix
Definition: clufactor.h:188
Timer * solveTime
Time spent in solves.
Definition: slufactor.h:90
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:6102
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:312
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:84
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:667
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:712
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:319
Status status() const
Definition: slufactor.h:172
R * get_ptr()
Conversion to C-style pointer.
Definition: vectorbase.h:446
int * len
used nonzeros per column vector
Definition: clufactor.h:148
SLUFactor()
default constructor.
Definition: slufactor.cpp:1060
double Real
Definition: spxdefines.h:218
int solveCount
Number of solves.
Definition: slufactor.h:93
const R * values() const
Returns array values.
Definition: ssvectorbase.h:300
#define MSG_DEBUG(x)
Definition: spxdefines.h:132
bool isConsistent() const
consistency check.
Definition: slufactor.cpp:1493
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:3288
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:603
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:602
SLUFactor & operator=(const SLUFactor &old)
assignment operator.
Definition: slufactor.cpp:1028
static Timer * createTimer(Timer::TYPE ttype)
create timers and allocate memory for them
Definition: timerfactory.h:44
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:5698
int thedim
dimension of factorized matrix
Definition: clufactor.h:186
const int * indexMem() const
Returns array indices.
Definition: ssvectorbase.h:294
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:569
Debugging, floating point type and parameter definitions.
void setSize(int n)
Sets number of nonzeros (thereby unSetup SSVectorBase).
Definition: ssvectorbase.h:584
int size
size of arrays val and idx
Definition: clufactor.h:123
Real stability() const
Definition: slufactor.cpp:590
void dump() const
Definition: clufactor.cpp:2824
bool EQ(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| <= eps
Definition: spxdefines.h:376
R * get_ptr()
Only used in slufactor.cpp.
Definition: ssvectorbase.h:100
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:2767
int * perm
perm[i] permuted index from i
Definition: clufactor.h:110
bool isConsistent() const
Definition: clufactor.cpp:2946
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:722
int size() const
Returns the number of nonzeros.
Definition: ssvectorbase.h:200
Everything should be within this namespace.
void assign(const SLUFactor &old)
used to implement the assignment operator
Definition: slufactor.cpp:829
int vSolveLeft(Real eps, Real *vec, int *idx, Real *rhs, int *ridx, int rn)
Definition: clufactor.cpp:6074
R getEpsilon() const
Returns the non-zero epsilon used.
Definition: ssvectorbase.h:105
void solve3right4update(SSVector &x, Vector &y, Vector &z, const SVector &b, SSVector &d, SSVector &e)
Solves , and .
Definition: slufactor.cpp:228
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:6158
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:5578
Timer * factorTime
Time spent in factorizations.
Definition: clufactor.h:204
void clear()
Set vector to 0.
Definition: vectorbase.h:262
void forceSetup()
Forces setup status.
Definition: ssvectorbase.h:163
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:254
#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:1502
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:6131
int * rbeg
start of rows in rval and ridx
Definition: clufactor.h:175
void solveRight(Real *vec, Real *rhs)
Definition: clufactor.cpp:3548
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:676
int dim() const
Definition: slufactor.h:157
SSVector forest
? Update vector set up by solveRight4update() and solve2right4update()
Definition: slufactor.h:76
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:110
static Real betterThreshold(Real th)
Definition: slufactor.cpp:1341
SLinSolver::Status Status
for convenience
Definition: slufactor.h:55
virtual TYPE type()=0
return type of timer