1    	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2    	/*                                                                           */
3    	/*                  This file is part of the class library                   */
4    	/*       SoPlex --- the Sequential object-oriented simPlex.                  */
5    	/*                                                                           */
6    	/*    Copyright (C) 1996-2022 Konrad-Zuse-Zentrum                            */
7    	/*                            fuer Informationstechnik Berlin                */
8    	/*                                                                           */
9    	/*  SoPlex is distributed under the terms of the ZIB Academic Licence.       */
10   	/*                                                                           */
11   	/*  You should have received a copy of the ZIB Academic License              */
12   	/*  along with SoPlex; see the file COPYING. If not email to soplex@zib.de.  */
13   	/*                                                                           */
14   	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15   	
16   	#include <assert.h>
17   	#include <iostream>
18   	
19   	#include "soplex/spxdefines.h"
(1) Event include_recursion: #include file "/sapmnt/home1/d029903/my_work/SCIPSoPlex_coverity/scipoptsuite-8.0.1/soplex/src/soplex/spxparmultpr.h" includes itself: spxparmultpr.h -> spxparmultpr.hpp -> spxparmultpr.h
(2) Event caretline: ^
20   	#include "soplex/spxparmultpr.h"
21   	
22   	namespace soplex
23   	{
24   	
25   	template <class R>
26   	void SPxParMultPR<R>::setType(typename SPxSolverBase<R>::Type tp)
27   	{
28   	   if(tp == SPxSolverBase<R>::ENTER)
29   	   {
30   	      used = 0;
31   	      this->thesolver->setPricing(SPxSolverBase<R>::PARTIAL);
32   	   }
33   	   else
34   	   {
35   	      this->thesolver->setPricing(SPxSolverBase<R>::FULL);
36   	   }
37   	
38   	   this->thesolver->weights.reDim(0);
39   	   this->thesolver->coWeights.reDim(0);
40   	   this->thesolver->weightsAreSetup = false;
41   	
42   	   last = 0;
43   	   min = partialSize / 2;
44   	}
45   	
46   	template <class R>
47   	void SPxParMultPR<R>::load(SPxSolverBase<R>* p_solver)
48   	{
49   	   this->thesolver = p_solver;
50   	   multiParts = (this->thesolver->dim() + this->thesolver->coDim()) / partialSize + 1;
51   	   pricSet.reSize(10 * partialSize);
52   	}
53   	
54   	template <class R>
55   	SPxId SPxParMultPR<R>::selectEnter()
56   	{
57   	   SPxId id;
58   	   R x;
59   	   int i;
60   	   int best = -1;
61   	   //    const SPxBasisBase<R>::Desc& ds   = this->thesolver->basis().desc();
62   	
63   	   assert(this->thesolver != 0);
64   	   int lastlast = -1;
65   	
66   	   if(this->thesolver->pricing() == SPxSolverBase<R>::PARTIAL)
67   	   {
68   	      R val;
69   	      R eps = -this->theeps;
70   	      lastlast = last;
71   	
72   	      for(i = used - 1; i >= 0; --i)
73   	      {
74   	         int n = this->thesolver->number(pricSet[i].id);
75   	
76   	         if(this->thesolver->isId(pricSet[i].id))
77   	         {
78   	            this->thesolver->computePvec(n);
79   	            pricSet[i].test = val = this->thesolver->computeTest(n);
80   	         }
81   	         else
82   	            pricSet[i].test = val = this->thesolver->coTest()[n];
83   	
84   	         if(val >= eps)
85   	            pricSet[i] = pricSet[--used];
86   	      }
87   	
88   	      while(pricSet.size() - used < partialSize)
89   	      {
90   	         best = 0;
91   	
92   	         for(i = 1; i < used; ++i)
93   	         {
94   	            if(pricSet[i].test > pricSet[best].test)
95   	               best = i;
96   	         }
97   	
98   	         pricSet[best] = pricSet[--used];
99   	      }
100  	
101  	      do
102  	      {
103  	         last = (last + 1) % multiParts;
104  	
105  	         for(i = this->thesolver->coDim() - last - 1;
106  	               i >= 0; i -= multiParts)
107  	         {
108  	            this->thesolver->computePvec(i);
109  	            x = this->thesolver->computeTest(i);
110  	
111  	            if(x < eps)
112  	            {
113  	               pricSet[used].id = this->thesolver->id(i);
114  	               pricSet[used].test = x;
115  	               used++;
116  	            }
117  	         }
118  	
119  	         for(i = this->thesolver->dim() - last - 1;
120  	               i >= 0; i -= multiParts)
121  	         {
122  	            x = this->thesolver->coTest()[i];
123  	
124  	            if(x < eps)
125  	            {
126  	               pricSet[used].id = this->thesolver->coId(i);
127  	               pricSet[used].test = x;
128  	               used++;
129  	            }
130  	         }
131  	
132  	         assert(used < pricSet.size());
133  	      }
134  	      while(used < min && last != lastlast);
135  	
136  	      if(used > 0)
137  	      {
138  	         min = (used + 1);
139  	
140  	         if(min < 1)
141  	            min = 1;
142  	
143  	         if(min > partialSize)
144  	            min = partialSize;
145  	
146  	         best = 0;
147  	
148  	         for(i = 1; i < used; ++i)
149  	         {
150  	            if(pricSet[i].test < pricSet[best].test)
151  	               best = i;
152  	         }
153  	
154  	         id = pricSet[best].id;
155  	      }
156  	
157  	      return id;
158  	   }
159  	
160  	   else
161  	   {
162  	      assert(this->thesolver->pricing() == SPxSolverBase<R>::FULL);
163  	      R bestx = -this->theeps;
164  	
165  	      for(i = this->thesolver->dim() - 1; i >= 0; --i)
166  	      {
167  	         x = this->thesolver->coTest()[i];
168  	
169  	         // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasisBase<R>::Desc::P_FREE
170  	         //                || ds.coStatus(i) == SPxBasisBase<R>::Desc::D_FREE));
171  	         if(x < bestx)
172  	         {
173  	            id = this->thesolver->coId(i);
174  	            bestx = this->thesolver->coTest()[i];
175  	         }
176  	      }
177  	
178  	      for(i = this->thesolver->coDim() - 1; i >= 0; --i)
179  	      {
180  	         x = this->thesolver->test()[i];
181  	
182  	         // x *= EQ_PREF * (1 + (ds.status(i) == SPxBasisBase<R>::Desc::P_FREE
183  	         //                || ds.status(i) == SPxBasisBase<R>::Desc::D_FREE));
184  	         if(x < bestx)
185  	         {
186  	            id = this->thesolver->id(i);
187  	            bestx = this->thesolver->test()[i];
188  	         }
189  	      }
190  	
191  	      return id;
192  	   }
193  	}
194  	
195  	template <class R>
196  	int SPxParMultPR<R>::selectLeave()
197  	{
198  	   int i, n;
199  	   R x;
200  	   R best = -this->theeps;
201  	   //    const R* up  = this->thesolver->ubBound();
202  	   //    const R* low = this->thesolver->lbBound();
203  	
204  	   assert(this->thesolver != 0);
205  	   n = -1;
206  	
207  	   for(i = this->thesolver->dim() - 1; i >= 0; --i)
208  	   {
209  	      x = this->thesolver->fTest()[i];
210  	
211  	      // x *= EQ_PREF * (1 + (up[i] == low[i]));
212  	      if(x < best)
213  	      {
214  	         n = i;
215  	         best = this->thesolver->fTest()[i];
216  	      }
217  	   }
218  	
219  	   return n;
220  	}
221  	} // namespace soplex
222