1 | // Copyright (C) 2003, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | |
---|
4 | |
---|
5 | |
---|
6 | |
---|
7 | #include "CoinPragma.hpp" |
---|
8 | |
---|
9 | #include <cmath> |
---|
10 | #include <cstring> |
---|
11 | |
---|
12 | #include "CoinHelperFunctions.hpp" |
---|
13 | #include "ClpSimplex.hpp" |
---|
14 | #include "ClpInterior.hpp" |
---|
15 | #include <cfloat> |
---|
16 | // Get C stuff but with extern C |
---|
17 | #define CLP_EXTERN_C |
---|
18 | #include "Coin_C_defines.h" |
---|
19 | |
---|
20 | /// To allow call backs |
---|
21 | class CMessageHandler : public CoinMessageHandler { |
---|
22 | |
---|
23 | public: |
---|
24 | /**@name Overrides */ |
---|
25 | //@{ |
---|
26 | virtual int print(); |
---|
27 | //@} |
---|
28 | /**@name set and get */ |
---|
29 | //@{ |
---|
30 | /// Model |
---|
31 | const Clp_Simplex * model() const; |
---|
32 | void setModel(Clp_Simplex * model); |
---|
33 | /// Call back |
---|
34 | void setCallBack(clp_callback callback); |
---|
35 | //@} |
---|
36 | |
---|
37 | /**@name Constructors, destructor */ |
---|
38 | //@{ |
---|
39 | /** Default constructor. */ |
---|
40 | CMessageHandler(); |
---|
41 | /// Constructor with pointer to model |
---|
42 | CMessageHandler(Clp_Simplex * model, |
---|
43 | FILE * userPointer=NULL); |
---|
44 | /** Destructor */ |
---|
45 | virtual ~CMessageHandler(); |
---|
46 | //@} |
---|
47 | |
---|
48 | /**@name Copy method */ |
---|
49 | //@{ |
---|
50 | /** The copy constructor. */ |
---|
51 | CMessageHandler(const CMessageHandler&); |
---|
52 | /** The copy constructor from an CoinSimplexMessageHandler. */ |
---|
53 | CMessageHandler(const CoinMessageHandler&); |
---|
54 | |
---|
55 | CMessageHandler& operator=(const CMessageHandler&); |
---|
56 | /// Clone |
---|
57 | virtual CoinMessageHandler * clone() const ; |
---|
58 | //@} |
---|
59 | |
---|
60 | |
---|
61 | protected: |
---|
62 | /**@name Data members |
---|
63 | The data members are protected to allow access for derived classes. */ |
---|
64 | //@{ |
---|
65 | /// Pointer back to model |
---|
66 | Clp_Simplex * model_; |
---|
67 | /// call back |
---|
68 | clp_callback callback_; |
---|
69 | //@} |
---|
70 | }; |
---|
71 | |
---|
72 | |
---|
73 | //------------------------------------------------------------------- |
---|
74 | // Default Constructor |
---|
75 | //------------------------------------------------------------------- |
---|
76 | CMessageHandler::CMessageHandler () |
---|
77 | : CoinMessageHandler(), |
---|
78 | model_(NULL), |
---|
79 | callback_(NULL) |
---|
80 | { |
---|
81 | } |
---|
82 | |
---|
83 | //------------------------------------------------------------------- |
---|
84 | // Copy constructor |
---|
85 | //------------------------------------------------------------------- |
---|
86 | CMessageHandler::CMessageHandler (const CMessageHandler & rhs) |
---|
87 | : CoinMessageHandler(rhs), |
---|
88 | model_(rhs.model_), |
---|
89 | callback_(rhs.callback_) |
---|
90 | { |
---|
91 | } |
---|
92 | |
---|
93 | CMessageHandler::CMessageHandler (const CoinMessageHandler & rhs) |
---|
94 | : CoinMessageHandler(), |
---|
95 | model_(NULL), |
---|
96 | callback_(NULL) |
---|
97 | { |
---|
98 | } |
---|
99 | |
---|
100 | // Constructor with pointer to model |
---|
101 | CMessageHandler::CMessageHandler(Clp_Simplex * model, |
---|
102 | FILE * userPointer) |
---|
103 | : CoinMessageHandler(), |
---|
104 | model_(model), |
---|
105 | callback_(NULL) |
---|
106 | { |
---|
107 | } |
---|
108 | |
---|
109 | //------------------------------------------------------------------- |
---|
110 | // Destructor |
---|
111 | //------------------------------------------------------------------- |
---|
112 | CMessageHandler::~CMessageHandler () |
---|
113 | { |
---|
114 | } |
---|
115 | |
---|
116 | //---------------------------------------------------------------- |
---|
117 | // Assignment operator |
---|
118 | //------------------------------------------------------------------- |
---|
119 | CMessageHandler & |
---|
120 | CMessageHandler::operator=(const CMessageHandler& rhs) |
---|
121 | { |
---|
122 | if (this != &rhs) { |
---|
123 | CoinMessageHandler::operator=(rhs); |
---|
124 | model_ = rhs.model_; |
---|
125 | callback_ = rhs.callback_; |
---|
126 | } |
---|
127 | return *this; |
---|
128 | } |
---|
129 | //------------------------------------------------------------------- |
---|
130 | // Clone |
---|
131 | //------------------------------------------------------------------- |
---|
132 | CoinMessageHandler * CMessageHandler::clone() const |
---|
133 | { |
---|
134 | return new CMessageHandler(*this); |
---|
135 | } |
---|
136 | |
---|
137 | int |
---|
138 | CMessageHandler::print() |
---|
139 | { |
---|
140 | if (callback_) { |
---|
141 | int messageNumber = currentMessage().externalNumber(); |
---|
142 | if (currentSource()!="Clp") |
---|
143 | messageNumber += 1000000; |
---|
144 | int i; |
---|
145 | int nDouble=numberDoubleFields(); |
---|
146 | assert (nDouble<=10); |
---|
147 | double vDouble[10]; |
---|
148 | for (i=0;i<nDouble;i++) |
---|
149 | vDouble[i]=doubleValue(i); |
---|
150 | int nInt=numberIntFields(); |
---|
151 | assert (nInt<=10); |
---|
152 | int vInt[10]; |
---|
153 | for (i=0;i<nInt;i++) |
---|
154 | vInt[i]=intValue(i); |
---|
155 | int nString=numberStringFields(); |
---|
156 | assert (nString<=10); |
---|
157 | char * vString[10]; |
---|
158 | for (i=0;i<nString;i++) { |
---|
159 | std::string value = stringValue(i); |
---|
160 | vString[i]=CoinStrdup(value.c_str()); |
---|
161 | } |
---|
162 | callback_(model_,messageNumber, |
---|
163 | nDouble,vDouble, |
---|
164 | nInt,vInt, |
---|
165 | nString,vString); |
---|
166 | for (i=0;i<nString;i++) |
---|
167 | free(vString[i]); |
---|
168 | |
---|
169 | } |
---|
170 | return CoinMessageHandler::print(); |
---|
171 | } |
---|
172 | const Clp_Simplex * |
---|
173 | CMessageHandler::model() const |
---|
174 | { |
---|
175 | return model_; |
---|
176 | } |
---|
177 | void |
---|
178 | CMessageHandler::setModel(Clp_Simplex * model) |
---|
179 | { |
---|
180 | model_ = model; |
---|
181 | } |
---|
182 | // Call back |
---|
183 | void |
---|
184 | CMessageHandler::setCallBack(clp_callback callback) |
---|
185 | { |
---|
186 | callback_ = callback; |
---|
187 | } |
---|
188 | |
---|
189 | #include "Clp_C_Interface.h" |
---|
190 | #include <string> |
---|
191 | #include <stdio.h> |
---|
192 | #include <iostream> |
---|
193 | |
---|
194 | #if defined(__MWERKS__) |
---|
195 | #pragma export on |
---|
196 | #endif |
---|
197 | /* Default constructor */ |
---|
198 | COINLIBAPI Clp_Simplex * COINLINKAGE |
---|
199 | Clp_newModel() |
---|
200 | { |
---|
201 | Clp_Simplex * model = new Clp_Simplex; |
---|
202 | model->model_ = new ClpSimplex(); |
---|
203 | model->handler_=NULL; |
---|
204 | return model; |
---|
205 | } |
---|
206 | /* Destructor */ |
---|
207 | COINLIBAPI void COINLINKAGE |
---|
208 | Clp_deleteModel(Clp_Simplex * model) |
---|
209 | { |
---|
210 | delete model->model_; |
---|
211 | delete model->handler_; |
---|
212 | delete model; |
---|
213 | } |
---|
214 | |
---|
215 | /* Loads a problem (the constraints on the |
---|
216 | rows are given by lower and upper bounds). If a pointer is NULL then the |
---|
217 | following values are the default: |
---|
218 | <ul> |
---|
219 | <li> <code>colub</code>: all columns have upper bound infinity |
---|
220 | <li> <code>collb</code>: all columns have lower bound 0 |
---|
221 | <li> <code>rowub</code>: all rows have upper bound infinity |
---|
222 | <li> <code>rowlb</code>: all rows have lower bound -infinity |
---|
223 | <li> <code>obj</code>: all variables have 0 objective coefficient |
---|
224 | </ul> |
---|
225 | */ |
---|
226 | /* Just like the other loadProblem() method except that the matrix is |
---|
227 | given in a standard column major ordered format (without gaps). */ |
---|
228 | COINLIBAPI void COINLINKAGE |
---|
229 | Clp_loadProblem (Clp_Simplex * model, const int numcols, const int numrows, |
---|
230 | const CoinBigIndex * start, const int* index, |
---|
231 | const double* value, |
---|
232 | const double* collb, const double* colub, |
---|
233 | const double* obj, |
---|
234 | const double* rowlb, const double* rowub) |
---|
235 | { |
---|
236 | const char prefix[] = "Clp_c_Interface::Clp_loadProblem(): "; |
---|
237 | const int verbose = 0; |
---|
238 | if (verbose > 1) { |
---|
239 | printf("%s numcols = %i, numrows = %i\n", |
---|
240 | prefix, numcols, numrows); |
---|
241 | printf("%s model = %p, start = %p, index = %p, value = %p\n", |
---|
242 | prefix, reinterpret_cast<const void *>(model), reinterpret_cast<const void *>(start), reinterpret_cast<const void *>(index), reinterpret_cast<const void *>(value)); |
---|
243 | printf("%s collb = %p, colub = %p, obj = %p, rowlb = %p, rowub = %p\n", |
---|
244 | prefix, reinterpret_cast<const void *>(collb), reinterpret_cast<const void *>(colub), reinterpret_cast<const void *>(obj), reinterpret_cast<const void *>(rowlb), reinterpret_cast<const void *>(rowub)); |
---|
245 | } |
---|
246 | model->model_->loadProblem(numcols,numrows,start,index,value, |
---|
247 | collb,colub,obj,rowlb,rowub); |
---|
248 | } |
---|
249 | /* read quadratic part of the objective (the matrix part) */ |
---|
250 | COINLIBAPI void COINLINKAGE |
---|
251 | Clp_loadQuadraticObjective(Clp_Simplex * model, |
---|
252 | const int numberColumns, |
---|
253 | const CoinBigIndex * start, |
---|
254 | const int * column, |
---|
255 | const double * element) |
---|
256 | { |
---|
257 | |
---|
258 | model->model_->loadQuadraticObjective(numberColumns, |
---|
259 | start, column, element); |
---|
260 | |
---|
261 | } |
---|
262 | /* Read an mps file from the given filename */ |
---|
263 | COINLIBAPI int COINLINKAGE |
---|
264 | Clp_readMps(Clp_Simplex * model,const char *filename, |
---|
265 | int keepNames, |
---|
266 | int ignoreErrors) |
---|
267 | { |
---|
268 | return model->model_->readMps(filename,keepNames!=0,ignoreErrors!=0); |
---|
269 | } |
---|
270 | /* Copy in integer informations */ |
---|
271 | COINLIBAPI void COINLINKAGE |
---|
272 | Clp_copyInIntegerInformation(Clp_Simplex * model,const char * information) |
---|
273 | { |
---|
274 | model->model_->copyInIntegerInformation(information); |
---|
275 | } |
---|
276 | /* Drop integer informations */ |
---|
277 | COINLIBAPI void COINLINKAGE |
---|
278 | Clp_deleteIntegerInformation(Clp_Simplex * model) |
---|
279 | { |
---|
280 | model->model_->deleteIntegerInformation(); |
---|
281 | } |
---|
282 | /* Resizes rim part of model */ |
---|
283 | COINLIBAPI void COINLINKAGE |
---|
284 | Clp_resize (Clp_Simplex * model, int newNumberRows, int newNumberColumns) |
---|
285 | { |
---|
286 | model->model_->resize(newNumberRows,newNumberColumns); |
---|
287 | } |
---|
288 | /* Deletes rows */ |
---|
289 | COINLIBAPI void COINLINKAGE |
---|
290 | Clp_deleteRows(Clp_Simplex * model, int number, const int * which) |
---|
291 | { |
---|
292 | model->model_->deleteRows(number,which); |
---|
293 | } |
---|
294 | /* Add rows */ |
---|
295 | COINLIBAPI void COINLINKAGE |
---|
296 | Clp_addRows(Clp_Simplex * model, int number, const double * rowLower, |
---|
297 | const double * rowUpper, |
---|
298 | const int * rowStarts, const int * columns, |
---|
299 | const double * elements) |
---|
300 | { |
---|
301 | model->model_->addRows(number,rowLower,rowUpper,rowStarts,columns,elements); |
---|
302 | } |
---|
303 | |
---|
304 | /* Deletes columns */ |
---|
305 | COINLIBAPI void COINLINKAGE |
---|
306 | Clp_deleteColumns(Clp_Simplex * model, int number, const int * which) |
---|
307 | { |
---|
308 | model->model_->deleteColumns(number,which); |
---|
309 | } |
---|
310 | /* Add columns */ |
---|
311 | COINLIBAPI void COINLINKAGE |
---|
312 | Clp_addColumns(Clp_Simplex * model, int number, const double * columnLower, |
---|
313 | const double * columnUpper, |
---|
314 | const double * objective, |
---|
315 | const int * columnStarts, const int * rows, |
---|
316 | const double * elements) |
---|
317 | { |
---|
318 | model->model_->addColumns(number,columnLower,columnUpper,objective, |
---|
319 | columnStarts,rows,elements); |
---|
320 | } |
---|
321 | /* Change row lower bounds */ |
---|
322 | COINLIBAPI void COINLINKAGE |
---|
323 | Clp_chgRowLower(Clp_Simplex * model, const double * rowLower) |
---|
324 | { |
---|
325 | model->model_->chgRowLower(rowLower); |
---|
326 | } |
---|
327 | /* Change row upper bounds */ |
---|
328 | COINLIBAPI void COINLINKAGE |
---|
329 | Clp_chgRowUpper(Clp_Simplex * model, const double * rowUpper) |
---|
330 | { |
---|
331 | model->model_->chgRowUpper(rowUpper); |
---|
332 | } |
---|
333 | /* Change column lower bounds */ |
---|
334 | COINLIBAPI void COINLINKAGE |
---|
335 | Clp_chgColumnLower(Clp_Simplex * model, const double * columnLower) |
---|
336 | { |
---|
337 | model->model_->chgColumnLower(columnLower); |
---|
338 | } |
---|
339 | /* Change column upper bounds */ |
---|
340 | COINLIBAPI void COINLINKAGE |
---|
341 | Clp_chgColumnUpper(Clp_Simplex * model, const double * columnUpper) |
---|
342 | { |
---|
343 | model->model_->chgColumnUpper(columnUpper); |
---|
344 | } |
---|
345 | /* Change objective coefficients */ |
---|
346 | COINLIBAPI void COINLINKAGE |
---|
347 | Clp_chgObjCoefficients(Clp_Simplex * model, const double * objIn) |
---|
348 | { |
---|
349 | model->model_->chgObjCoefficients(objIn); |
---|
350 | } |
---|
351 | /* Drops names - makes lengthnames 0 and names empty */ |
---|
352 | COINLIBAPI void COINLINKAGE |
---|
353 | Clp_dropNames(Clp_Simplex * model) |
---|
354 | { |
---|
355 | model->model_->dropNames(); |
---|
356 | } |
---|
357 | /* Copies in names */ |
---|
358 | COINLIBAPI void COINLINKAGE |
---|
359 | Clp_copyNames(Clp_Simplex * model, const char * const * rowNamesIn, |
---|
360 | const char * const * columnNamesIn) |
---|
361 | { |
---|
362 | int iRow; |
---|
363 | std::vector<std::string> rowNames; |
---|
364 | int numberRows = model->model_->numberRows(); |
---|
365 | rowNames.reserve(numberRows); |
---|
366 | for (iRow=0;iRow<numberRows;iRow++) { |
---|
367 | rowNames.push_back(rowNamesIn[iRow]); |
---|
368 | } |
---|
369 | |
---|
370 | int iColumn; |
---|
371 | std::vector<std::string> columnNames; |
---|
372 | int numberColumns = model->model_->numberColumns(); |
---|
373 | columnNames.reserve(numberColumns); |
---|
374 | for (iColumn=0;iColumn<numberColumns;iColumn++) { |
---|
375 | columnNames.push_back(columnNamesIn[iColumn]); |
---|
376 | } |
---|
377 | model->model_->copyNames(rowNames,columnNames); |
---|
378 | } |
---|
379 | |
---|
380 | /* Number of rows */ |
---|
381 | COINLIBAPI int COINLINKAGE |
---|
382 | Clp_numberRows(Clp_Simplex * model) |
---|
383 | { |
---|
384 | return model->model_->numberRows(); |
---|
385 | } |
---|
386 | /* Number of columns */ |
---|
387 | COINLIBAPI int COINLINKAGE |
---|
388 | Clp_numberColumns(Clp_Simplex * model) |
---|
389 | { |
---|
390 | return model->model_->numberColumns(); |
---|
391 | } |
---|
392 | /* Primal tolerance to use */ |
---|
393 | COINLIBAPI double COINLINKAGE |
---|
394 | Clp_primalTolerance(Clp_Simplex * model) |
---|
395 | { |
---|
396 | return model->model_->primalTolerance(); |
---|
397 | } |
---|
398 | COINLIBAPI void COINLINKAGE |
---|
399 | Clp_setPrimalTolerance(Clp_Simplex * model, double value) |
---|
400 | { |
---|
401 | model->model_->setPrimalTolerance(value); |
---|
402 | } |
---|
403 | /* Dual tolerance to use */ |
---|
404 | COINLIBAPI double COINLINKAGE |
---|
405 | Clp_dualTolerance(Clp_Simplex * model) |
---|
406 | { |
---|
407 | return model->model_->dualTolerance(); |
---|
408 | } |
---|
409 | COINLIBAPI void COINLINKAGE |
---|
410 | Clp_setDualTolerance(Clp_Simplex * model, double value) |
---|
411 | { |
---|
412 | model->model_->setDualTolerance(value); |
---|
413 | } |
---|
414 | /* Dual objective limit */ |
---|
415 | COINLIBAPI double COINLINKAGE |
---|
416 | Clp_dualObjectiveLimit(Clp_Simplex * model) |
---|
417 | { |
---|
418 | return model->model_->dualObjectiveLimit(); |
---|
419 | } |
---|
420 | COINLIBAPI void COINLINKAGE |
---|
421 | Clp_setDualObjectiveLimit(Clp_Simplex * model, double value) |
---|
422 | { |
---|
423 | model->model_->setDualObjectiveLimit(value); |
---|
424 | } |
---|
425 | /* Objective offset */ |
---|
426 | COINLIBAPI double COINLINKAGE |
---|
427 | Clp_objectiveOffset(Clp_Simplex * model) |
---|
428 | { |
---|
429 | return model->model_->objectiveOffset(); |
---|
430 | } |
---|
431 | COINLIBAPI void COINLINKAGE |
---|
432 | Clp_setObjectiveOffset(Clp_Simplex * model, double value) |
---|
433 | { |
---|
434 | model->model_->setObjectiveOffset(value); |
---|
435 | } |
---|
436 | /* Fills in array with problem name */ |
---|
437 | COINLIBAPI void COINLINKAGE |
---|
438 | Clp_problemName(Clp_Simplex * model, int maxNumberCharacters, char * array) |
---|
439 | { |
---|
440 | std::string name = model->model_->problemName(); |
---|
441 | maxNumberCharacters = CoinMin(maxNumberCharacters,(int)strlen(name.c_str())); |
---|
442 | strncpy(array,name.c_str(),maxNumberCharacters-1); |
---|
443 | array[maxNumberCharacters-1]='\0'; |
---|
444 | } |
---|
445 | /* Sets problem name. Must have \0 at end. */ |
---|
446 | COINLIBAPI int COINLINKAGE |
---|
447 | Clp_setProblemName(Clp_Simplex * model, int maxNumberCharacters, char * array) |
---|
448 | { |
---|
449 | return model->model_->setStrParam(ClpProbName, array); |
---|
450 | } |
---|
451 | /* Number of iterations */ |
---|
452 | COINLIBAPI int COINLINKAGE |
---|
453 | Clp_numberIterations(Clp_Simplex * model) |
---|
454 | { |
---|
455 | return model->model_->numberIterations(); |
---|
456 | } |
---|
457 | COINLIBAPI void COINLINKAGE |
---|
458 | Clp_setNumberIterations(Clp_Simplex * model, int numberIterations) |
---|
459 | { |
---|
460 | model->model_->setNumberIterations(numberIterations); |
---|
461 | } |
---|
462 | /* Maximum number of iterations */ |
---|
463 | COINLIBAPI int maximumIterations(Clp_Simplex * model) |
---|
464 | { |
---|
465 | return model->model_->maximumIterations(); |
---|
466 | } |
---|
467 | COINLIBAPI void COINLINKAGE |
---|
468 | Clp_setMaximumIterations(Clp_Simplex * model, int value) |
---|
469 | { |
---|
470 | model->model_->setMaximumIterations(value); |
---|
471 | } |
---|
472 | /* Maximum time in seconds (from when set called) */ |
---|
473 | COINLIBAPI double COINLINKAGE |
---|
474 | Clp_maximumSeconds(Clp_Simplex * model) |
---|
475 | { |
---|
476 | return model->model_->maximumSeconds(); |
---|
477 | } |
---|
478 | COINLIBAPI void COINLINKAGE |
---|
479 | Clp_setMaximumSeconds(Clp_Simplex * model, double value) |
---|
480 | { |
---|
481 | model->model_->setMaximumSeconds(value); |
---|
482 | } |
---|
483 | /* Returns true if hit maximum iteratio`ns (or time) */ |
---|
484 | COINLIBAPI int COINLINKAGE |
---|
485 | Clp_hitMaximumIterations(Clp_Simplex * model) |
---|
486 | { |
---|
487 | return model->model_->hitMaximumIterations() ? 1 : 0; |
---|
488 | } |
---|
489 | /* Status of problem: |
---|
490 | 0 - optimal |
---|
491 | 1 - primal infeasible |
---|
492 | 2 - dual infeasible |
---|
493 | 3 - stopped on iterations etc |
---|
494 | 4 - stopped due to errors |
---|
495 | */ |
---|
496 | COINLIBAPI int COINLINKAGE |
---|
497 | Clp_status(Clp_Simplex * model) |
---|
498 | { |
---|
499 | return model->model_->status(); |
---|
500 | } |
---|
501 | /* Set problem status */ |
---|
502 | COINLIBAPI void COINLINKAGE |
---|
503 | Clp_setProblemStatus(Clp_Simplex * model, int problemStatus) |
---|
504 | { |
---|
505 | model->model_->setProblemStatus(problemStatus); |
---|
506 | } |
---|
507 | /* Secondary status of problem - may get extended |
---|
508 | 0 - none |
---|
509 | 1 - primal infeasible because dual limit reached |
---|
510 | 2 - scaled problem optimal - unscaled has primal infeasibilities |
---|
511 | 3 - scaled problem optimal - unscaled has dual infeasibilities |
---|
512 | 4 - scaled problem optimal - unscaled has both dual and primal infeasibilities |
---|
513 | */ |
---|
514 | COINLIBAPI int COINLINKAGE |
---|
515 | Clp_secondaryStatus(Clp_Simplex * model) |
---|
516 | { |
---|
517 | return model->model_->secondaryStatus(); |
---|
518 | } |
---|
519 | COINLIBAPI void COINLINKAGE |
---|
520 | Clp_setSecondaryStatus(Clp_Simplex * model, int status) |
---|
521 | { |
---|
522 | model->model_->setSecondaryStatus(status); |
---|
523 | } |
---|
524 | /* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */ |
---|
525 | COINLIBAPI double COINLINKAGE |
---|
526 | Clp_optimizationDirection(Clp_Simplex * model) |
---|
527 | { |
---|
528 | return model->model_->optimizationDirection(); |
---|
529 | } |
---|
530 | COINLIBAPI void COINLINKAGE |
---|
531 | Clp_setOptimizationDirection(Clp_Simplex * model, double value) |
---|
532 | { |
---|
533 | model->model_->setOptimizationDirection(value); |
---|
534 | } |
---|
535 | /* Primal row solution */ |
---|
536 | COINLIBAPI double * COINLINKAGE |
---|
537 | Clp_primalRowSolution(Clp_Simplex * model) |
---|
538 | { |
---|
539 | return model->model_->primalRowSolution(); |
---|
540 | } |
---|
541 | /* Primal column solution */ |
---|
542 | COINLIBAPI double * COINLINKAGE |
---|
543 | Clp_primalColumnSolution(Clp_Simplex * model) |
---|
544 | { |
---|
545 | return model->model_->primalColumnSolution(); |
---|
546 | } |
---|
547 | /* Dual row solution */ |
---|
548 | COINLIBAPI double * COINLINKAGE |
---|
549 | Clp_dualRowSolution(Clp_Simplex * model) |
---|
550 | { |
---|
551 | return model->model_->dualRowSolution(); |
---|
552 | } |
---|
553 | /* Reduced costs */ |
---|
554 | COINLIBAPI double * COINLINKAGE |
---|
555 | Clp_dualColumnSolution(Clp_Simplex * model) |
---|
556 | { |
---|
557 | return model->model_->dualColumnSolution(); |
---|
558 | } |
---|
559 | /* Row lower */ |
---|
560 | COINLIBAPI double* COINLINKAGE |
---|
561 | Clp_rowLower(Clp_Simplex * model) |
---|
562 | { |
---|
563 | return model->model_->rowLower(); |
---|
564 | } |
---|
565 | /* Row upper */ |
---|
566 | COINLIBAPI double* COINLINKAGE |
---|
567 | Clp_rowUpper(Clp_Simplex * model) |
---|
568 | { |
---|
569 | return model->model_->rowUpper(); |
---|
570 | } |
---|
571 | /* Objective */ |
---|
572 | COINLIBAPI double * COINLINKAGE |
---|
573 | Clp_objective(Clp_Simplex * model) |
---|
574 | { |
---|
575 | return model->model_->objective(); |
---|
576 | } |
---|
577 | /* Column Lower */ |
---|
578 | COINLIBAPI double * COINLINKAGE |
---|
579 | Clp_columnLower(Clp_Simplex * model) |
---|
580 | { |
---|
581 | return model->model_->columnLower(); |
---|
582 | } |
---|
583 | /* Column Upper */ |
---|
584 | COINLIBAPI double * COINLINKAGE |
---|
585 | Clp_columnUpper(Clp_Simplex * model) |
---|
586 | { |
---|
587 | return model->model_->columnUpper(); |
---|
588 | } |
---|
589 | /* Number of elements in matrix */ |
---|
590 | COINLIBAPI int COINLINKAGE |
---|
591 | Clp_getNumElements(Clp_Simplex * model) |
---|
592 | { |
---|
593 | return model->model_->getNumElements(); |
---|
594 | } |
---|
595 | // Column starts in matrix |
---|
596 | COINLIBAPI const CoinBigIndex * COINLINKAGE Clp_getVectorStarts(Clp_Simplex * model) |
---|
597 | { |
---|
598 | CoinPackedMatrix * matrix; |
---|
599 | matrix = model->model_->matrix(); |
---|
600 | return (matrix == NULL) ? NULL : matrix->getVectorStarts(); |
---|
601 | } |
---|
602 | |
---|
603 | // Row indices in matrix |
---|
604 | COINLIBAPI const int * COINLINKAGE Clp_getIndices(Clp_Simplex * model) |
---|
605 | { |
---|
606 | CoinPackedMatrix * matrix = model->model_->matrix(); |
---|
607 | return (matrix == NULL) ? NULL : matrix->getIndices(); |
---|
608 | } |
---|
609 | |
---|
610 | // Column vector lengths in matrix |
---|
611 | COINLIBAPI const int * COINLINKAGE Clp_getVectorLengths(Clp_Simplex * model) |
---|
612 | { |
---|
613 | CoinPackedMatrix * matrix = model->model_->matrix(); |
---|
614 | return (matrix == NULL) ? NULL : matrix->getVectorLengths(); |
---|
615 | } |
---|
616 | |
---|
617 | // Element values in matrix |
---|
618 | COINLIBAPI const double * COINLINKAGE Clp_getElements(Clp_Simplex * model) |
---|
619 | { |
---|
620 | CoinPackedMatrix * matrix = model->model_->matrix(); |
---|
621 | return (matrix == NULL) ? NULL : matrix->getElements(); |
---|
622 | } |
---|
623 | /* Objective value */ |
---|
624 | COINLIBAPI double COINLINKAGE |
---|
625 | Clp_objectiveValue(Clp_Simplex * model) |
---|
626 | { |
---|
627 | return model->model_->objectiveValue(); |
---|
628 | } |
---|
629 | /* Integer information */ |
---|
630 | COINLIBAPI char * COINLINKAGE |
---|
631 | Clp_integerInformation(Clp_Simplex * model) |
---|
632 | { |
---|
633 | return model->model_->integerInformation(); |
---|
634 | } |
---|
635 | /* Infeasibility/unbounded ray (NULL returned if none/wrong) |
---|
636 | Up to user to use delete [] on these arrays. */ |
---|
637 | COINLIBAPI double * COINLINKAGE |
---|
638 | Clp_infeasibilityRay(Clp_Simplex * model) |
---|
639 | { |
---|
640 | return model->model_->infeasibilityRay(); |
---|
641 | } |
---|
642 | COINLIBAPI double * COINLINKAGE |
---|
643 | Clp_unboundedRay(Clp_Simplex * model) |
---|
644 | { |
---|
645 | return model->model_->unboundedRay(); |
---|
646 | } |
---|
647 | /* See if status array exists (partly for OsiClp) */ |
---|
648 | COINLIBAPI int COINLINKAGE |
---|
649 | Clp_statusExists(Clp_Simplex * model) |
---|
650 | { |
---|
651 | return model->model_->statusExists() ? 1 : 0; |
---|
652 | } |
---|
653 | /* Return address of status array (char[numberRows+numberColumns]) */ |
---|
654 | COINLIBAPI unsigned char * COINLINKAGE |
---|
655 | Clp_statusArray(Clp_Simplex * model) |
---|
656 | { |
---|
657 | return model->model_->statusArray(); |
---|
658 | } |
---|
659 | /* Copy in status vector */ |
---|
660 | COINLIBAPI void COINLINKAGE |
---|
661 | Clp_copyinStatus(Clp_Simplex * model, const unsigned char * statusArray) |
---|
662 | { |
---|
663 | model->model_->copyinStatus(statusArray); |
---|
664 | } |
---|
665 | |
---|
666 | /* User pointer for whatever reason */ |
---|
667 | COINLIBAPI void COINLINKAGE |
---|
668 | Clp_setUserPointer (Clp_Simplex * model, void * pointer) |
---|
669 | { |
---|
670 | model->model_->setUserPointer(pointer); |
---|
671 | } |
---|
672 | COINLIBAPI void * COINLINKAGE |
---|
673 | Clp_getUserPointer (Clp_Simplex * model) |
---|
674 | { |
---|
675 | return model->model_->getUserPointer(); |
---|
676 | } |
---|
677 | /* Pass in Callback function */ |
---|
678 | COINLIBAPI void COINLINKAGE |
---|
679 | Clp_registerCallBack(Clp_Simplex * model, |
---|
680 | clp_callback userCallBack) |
---|
681 | { |
---|
682 | // Will be copy of users one |
---|
683 | delete model->handler_; |
---|
684 | model->handler_ = new CMessageHandler(*(model->model_->messageHandler())); |
---|
685 | model->handler_->setCallBack(userCallBack); |
---|
686 | model->handler_->setModel(model); |
---|
687 | model->model_->passInMessageHandler(model->handler_); |
---|
688 | } |
---|
689 | /* Unset Callback function */ |
---|
690 | COINLIBAPI void COINLINKAGE |
---|
691 | Clp_clearCallBack(Clp_Simplex * model) |
---|
692 | { |
---|
693 | delete model->handler_; |
---|
694 | model->handler_=NULL; |
---|
695 | } |
---|
696 | /* Amount of print out: |
---|
697 | 0 - none |
---|
698 | 1 - just final |
---|
699 | 2 - just factorizations |
---|
700 | 3 - as 2 plus a bit more |
---|
701 | 4 - verbose |
---|
702 | above that 8,16,32 etc just for selective debug |
---|
703 | */ |
---|
704 | COINLIBAPI void COINLINKAGE |
---|
705 | Clp_setLogLevel(Clp_Simplex * model, int value) |
---|
706 | { |
---|
707 | model->model_->setLogLevel(value); |
---|
708 | } |
---|
709 | COINLIBAPI int COINLINKAGE |
---|
710 | Clp_logLevel(Clp_Simplex * model) |
---|
711 | { |
---|
712 | return model->model_->logLevel(); |
---|
713 | } |
---|
714 | /* length of names (0 means no names0 */ |
---|
715 | COINLIBAPI int COINLINKAGE |
---|
716 | Clp_lengthNames(Clp_Simplex * model) |
---|
717 | { |
---|
718 | return model->model_->lengthNames(); |
---|
719 | } |
---|
720 | /* Fill in array (at least lengthNames+1 long) with a row name */ |
---|
721 | COINLIBAPI void COINLINKAGE |
---|
722 | Clp_rowName(Clp_Simplex * model, int iRow, char * name) |
---|
723 | { |
---|
724 | std::string rowName=model->model_->rowName(iRow); |
---|
725 | strcpy(name,rowName.c_str()); |
---|
726 | } |
---|
727 | /* Fill in array (at least lengthNames+1 long) with a column name */ |
---|
728 | COINLIBAPI void COINLINKAGE |
---|
729 | Clp_columnName(Clp_Simplex * model, int iColumn, char * name) |
---|
730 | { |
---|
731 | std::string columnName= model->model_->columnName(iColumn); |
---|
732 | strcpy(name,columnName.c_str()); |
---|
733 | } |
---|
734 | |
---|
735 | /* General solve algorithm which can do presolve. |
---|
736 | See ClpSolve.hpp for options |
---|
737 | */ |
---|
738 | COINLIBAPI int COINLINKAGE |
---|
739 | Clp_initialSolve(Clp_Simplex * model) |
---|
740 | { |
---|
741 | return model->model_->initialSolve(); |
---|
742 | } |
---|
743 | /* Barrier initial solve */ |
---|
744 | COINLIBAPI int COINLINKAGE |
---|
745 | Clp_initialBarrierSolve(Clp_Simplex * model0) |
---|
746 | { |
---|
747 | ClpSimplex *model = model0->model_; |
---|
748 | |
---|
749 | return model->initialBarrierSolve(); |
---|
750 | |
---|
751 | } |
---|
752 | /* Barrier initial solve */ |
---|
753 | COINLIBAPI int COINLINKAGE |
---|
754 | Clp_initialBarrierNoCrossSolve(Clp_Simplex * model0) |
---|
755 | { |
---|
756 | ClpSimplex *model = model0->model_; |
---|
757 | |
---|
758 | return model->initialBarrierNoCrossSolve(); |
---|
759 | |
---|
760 | } |
---|
761 | /* Dual initial solve */ |
---|
762 | COINLIBAPI int COINLINKAGE |
---|
763 | Clp_initialDualSolve(Clp_Simplex * model) |
---|
764 | { |
---|
765 | return model->model_->initialDualSolve(); |
---|
766 | } |
---|
767 | /* Primal initial solve */ |
---|
768 | COINLIBAPI int COINLINKAGE |
---|
769 | Clp_initialPrimalSolve(Clp_Simplex * model) |
---|
770 | { |
---|
771 | return model->model_->initialPrimalSolve(); |
---|
772 | } |
---|
773 | /* Dual algorithm - see ClpSimplexDual.hpp for method */ |
---|
774 | COINLIBAPI int COINLINKAGE |
---|
775 | Clp_dual(Clp_Simplex * model, int ifValuesPass) |
---|
776 | { |
---|
777 | return model->model_->dual(ifValuesPass); |
---|
778 | } |
---|
779 | /* Primal algorithm - see ClpSimplexPrimal.hpp for method */ |
---|
780 | COINLIBAPI int COINLINKAGE |
---|
781 | Clp_primal(Clp_Simplex * model, int ifValuesPass) |
---|
782 | { |
---|
783 | return model->model_->primal(ifValuesPass); |
---|
784 | } |
---|
785 | /* Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */ |
---|
786 | COINLIBAPI void COINLINKAGE |
---|
787 | Clp_scaling(Clp_Simplex * model, int mode) |
---|
788 | { |
---|
789 | model->model_->scaling(mode); |
---|
790 | } |
---|
791 | /* Gets scalingFlag */ |
---|
792 | COINLIBAPI int COINLINKAGE |
---|
793 | Clp_scalingFlag(Clp_Simplex * model) |
---|
794 | { |
---|
795 | return model->model_->scalingFlag(); |
---|
796 | } |
---|
797 | /* Crash - at present just aimed at dual, returns |
---|
798 | -2 if dual preferred and crash basis created |
---|
799 | -1 if dual preferred and all slack basis preferred |
---|
800 | 0 if basis going in was not all slack |
---|
801 | 1 if primal preferred and all slack basis preferred |
---|
802 | 2 if primal preferred and crash basis created. |
---|
803 | |
---|
804 | if gap between bounds <="gap" variables can be flipped |
---|
805 | |
---|
806 | If "pivot" is |
---|
807 | 0 No pivoting (so will just be choice of algorithm) |
---|
808 | 1 Simple pivoting e.g. gub |
---|
809 | 2 Mini iterations |
---|
810 | */ |
---|
811 | COINLIBAPI int COINLINKAGE |
---|
812 | Clp_crash(Clp_Simplex * model, double gap,int pivot) |
---|
813 | { |
---|
814 | return model->model_->crash(gap,pivot); |
---|
815 | } |
---|
816 | /* If problem is primal feasible */ |
---|
817 | COINLIBAPI int COINLINKAGE |
---|
818 | Clp_primalFeasible(Clp_Simplex * model) |
---|
819 | { |
---|
820 | return model->model_->primalFeasible() ? 1 : 0; |
---|
821 | } |
---|
822 | /* If problem is dual feasible */ |
---|
823 | COINLIBAPI int COINLINKAGE |
---|
824 | Clp_dualFeasible(Clp_Simplex * model) |
---|
825 | { |
---|
826 | return model->model_->dualFeasible() ? 1 : 0; |
---|
827 | } |
---|
828 | /* Dual bound */ |
---|
829 | COINLIBAPI double COINLINKAGE |
---|
830 | Clp_dualBound(Clp_Simplex * model) |
---|
831 | { |
---|
832 | return model->model_->dualBound(); |
---|
833 | } |
---|
834 | COINLIBAPI void COINLINKAGE |
---|
835 | Clp_setDualBound(Clp_Simplex * model, double value) |
---|
836 | { |
---|
837 | model->model_->setDualBound(value); |
---|
838 | } |
---|
839 | /* Infeasibility cost */ |
---|
840 | COINLIBAPI double COINLINKAGE |
---|
841 | Clp_infeasibilityCost(Clp_Simplex * model) |
---|
842 | { |
---|
843 | return model->model_->infeasibilityCost(); |
---|
844 | } |
---|
845 | COINLIBAPI void COINLINKAGE |
---|
846 | Clp_setInfeasibilityCost(Clp_Simplex * model, double value) |
---|
847 | { |
---|
848 | model->model_->setInfeasibilityCost(value); |
---|
849 | } |
---|
850 | /* Perturbation: |
---|
851 | 50 - switch on perturbation |
---|
852 | 100 - auto perturb if takes too long (1.0e-6 largest nonzero) |
---|
853 | 101 - we are perturbed |
---|
854 | 102 - don't try perturbing again |
---|
855 | default is 100 |
---|
856 | others are for playing |
---|
857 | */ |
---|
858 | COINLIBAPI int COINLINKAGE |
---|
859 | Clp_perturbation(Clp_Simplex * model) |
---|
860 | { |
---|
861 | return model->model_->perturbation(); |
---|
862 | } |
---|
863 | COINLIBAPI void COINLINKAGE |
---|
864 | Clp_setPerturbation(Clp_Simplex * model, int value) |
---|
865 | { |
---|
866 | model->model_->setPerturbation(value); |
---|
867 | } |
---|
868 | /* Current (or last) algorithm */ |
---|
869 | COINLIBAPI int COINLINKAGE |
---|
870 | Clp_algorithm(Clp_Simplex * model) |
---|
871 | { |
---|
872 | return model->model_->algorithm(); |
---|
873 | } |
---|
874 | /* Set algorithm */ |
---|
875 | COINLIBAPI void COINLINKAGE |
---|
876 | Clp_setAlgorithm(Clp_Simplex * model, int value) |
---|
877 | { |
---|
878 | model->model_->setAlgorithm(value); |
---|
879 | } |
---|
880 | /* Sum of dual infeasibilities */ |
---|
881 | COINLIBAPI double COINLINKAGE |
---|
882 | Clp_sumDualInfeasibilities(Clp_Simplex * model) |
---|
883 | { |
---|
884 | return model->model_->sumDualInfeasibilities(); |
---|
885 | } |
---|
886 | /* Number of dual infeasibilities */ |
---|
887 | COINLIBAPI int COINLINKAGE |
---|
888 | Clp_numberDualInfeasibilities(Clp_Simplex * model) |
---|
889 | { |
---|
890 | return model->model_->numberDualInfeasibilities(); |
---|
891 | } |
---|
892 | /* Sum of primal infeasibilities */ |
---|
893 | COINLIBAPI double COINLINKAGE |
---|
894 | Clp_sumPrimalInfeasibilities(Clp_Simplex * model) |
---|
895 | { |
---|
896 | return model->model_->sumPrimalInfeasibilities(); |
---|
897 | } |
---|
898 | /* Number of primal infeasibilities */ |
---|
899 | COINLIBAPI int COINLINKAGE |
---|
900 | Clp_numberPrimalInfeasibilities(Clp_Simplex * model) |
---|
901 | { |
---|
902 | return model->model_->numberPrimalInfeasibilities(); |
---|
903 | } |
---|
904 | /* Save model to file, returns 0 if success. This is designed for |
---|
905 | use outside algorithms so does not save iterating arrays etc. |
---|
906 | It does not save any messaging information. |
---|
907 | Does not save scaling values. |
---|
908 | It does not know about all types of virtual functions. |
---|
909 | */ |
---|
910 | COINLIBAPI int COINLINKAGE |
---|
911 | Clp_saveModel(Clp_Simplex * model, const char * fileName) |
---|
912 | { |
---|
913 | return model->model_->saveModel(fileName); |
---|
914 | } |
---|
915 | /* Restore model from file, returns 0 if success, |
---|
916 | deletes current model */ |
---|
917 | COINLIBAPI int COINLINKAGE |
---|
918 | Clp_restoreModel(Clp_Simplex * model, const char * fileName) |
---|
919 | { |
---|
920 | return model->model_->restoreModel(fileName); |
---|
921 | } |
---|
922 | |
---|
923 | /* Just check solution (for external use) - sets sum of |
---|
924 | infeasibilities etc */ |
---|
925 | COINLIBAPI void COINLINKAGE |
---|
926 | Clp_checkSolution(Clp_Simplex * model) |
---|
927 | { |
---|
928 | model->model_->checkSolution(); |
---|
929 | } |
---|
930 | /* Number of rows */ |
---|
931 | COINLIBAPI int COINLINKAGE |
---|
932 | Clp_getNumRows(Clp_Simplex * model) |
---|
933 | { |
---|
934 | return model->model_->getNumRows(); |
---|
935 | } |
---|
936 | /* Number of columns */ |
---|
937 | COINLIBAPI int COINLINKAGE |
---|
938 | Clp_getNumCols(Clp_Simplex * model) |
---|
939 | { |
---|
940 | return model->model_->getNumCols(); |
---|
941 | } |
---|
942 | /* Number of iterations */ |
---|
943 | COINLIBAPI int COINLINKAGE |
---|
944 | Clp_getIterationCount(Clp_Simplex * model) |
---|
945 | { |
---|
946 | return model->model_->getIterationCount(); |
---|
947 | } |
---|
948 | /* Are there a numerical difficulties? */ |
---|
949 | COINLIBAPI int COINLINKAGE |
---|
950 | Clp_isAbandoned(Clp_Simplex * model) |
---|
951 | { |
---|
952 | return model->model_->isAbandoned() ? 1 : 0; |
---|
953 | } |
---|
954 | /* Is optimality proven? */ |
---|
955 | COINLIBAPI int COINLINKAGE |
---|
956 | Clp_isProvenOptimal(Clp_Simplex * model) |
---|
957 | { |
---|
958 | return model->model_->isProvenOptimal() ? 1 : 0; |
---|
959 | } |
---|
960 | /* Is primal infeasiblity proven? */ |
---|
961 | COINLIBAPI int COINLINKAGE |
---|
962 | Clp_isProvenPrimalInfeasible(Clp_Simplex * model) |
---|
963 | { |
---|
964 | return model->model_->isProvenPrimalInfeasible() ? 1 : 0; |
---|
965 | } |
---|
966 | /* Is dual infeasiblity proven? */ |
---|
967 | COINLIBAPI int COINLINKAGE |
---|
968 | Clp_isProvenDualInfeasible(Clp_Simplex * model) |
---|
969 | { |
---|
970 | return model->model_->isProvenDualInfeasible() ? 1 : 0; |
---|
971 | } |
---|
972 | /* Is the given primal objective limit reached? */ |
---|
973 | COINLIBAPI int COINLINKAGE |
---|
974 | Clp_isPrimalObjectiveLimitReached(Clp_Simplex * model) |
---|
975 | { |
---|
976 | return model->model_->isPrimalObjectiveLimitReached() ? 1 : 0; |
---|
977 | } |
---|
978 | /* Is the given dual objective limit reached? */ |
---|
979 | COINLIBAPI int COINLINKAGE |
---|
980 | Clp_isDualObjectiveLimitReached(Clp_Simplex * model) |
---|
981 | { |
---|
982 | return model->model_->isDualObjectiveLimitReached() ? 1 : 0; |
---|
983 | } |
---|
984 | /* Iteration limit reached? */ |
---|
985 | COINLIBAPI int COINLINKAGE |
---|
986 | Clp_isIterationLimitReached(Clp_Simplex * model) |
---|
987 | { |
---|
988 | return model->model_->isIterationLimitReached() ? 1 : 0; |
---|
989 | } |
---|
990 | /* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */ |
---|
991 | COINLIBAPI double COINLINKAGE |
---|
992 | Clp_getObjSense(Clp_Simplex * model) |
---|
993 | { |
---|
994 | return model->model_->getObjSense(); |
---|
995 | } |
---|
996 | /* Primal row solution */ |
---|
997 | COINLIBAPI const double * COINLINKAGE |
---|
998 | Clp_getRowActivity(Clp_Simplex * model) |
---|
999 | { |
---|
1000 | return model->model_->getRowActivity(); |
---|
1001 | } |
---|
1002 | /* Primal column solution */ |
---|
1003 | COINLIBAPI const double * COINLINKAGE |
---|
1004 | Clp_getColSolution(Clp_Simplex * model) |
---|
1005 | { |
---|
1006 | return model->model_->getColSolution(); |
---|
1007 | } |
---|
1008 | COINLIBAPI void COINLINKAGE |
---|
1009 | Clp_setColSolution(Clp_Simplex * model, const double * input) |
---|
1010 | { |
---|
1011 | model->model_->setColSolution(input); |
---|
1012 | } |
---|
1013 | /* Dual row solution */ |
---|
1014 | COINLIBAPI const double * COINLINKAGE |
---|
1015 | Clp_getRowPrice(Clp_Simplex * model) |
---|
1016 | { |
---|
1017 | return model->model_->getRowPrice(); |
---|
1018 | } |
---|
1019 | /* Reduced costs */ |
---|
1020 | COINLIBAPI const double * COINLINKAGE |
---|
1021 | Clp_getReducedCost(Clp_Simplex * model) |
---|
1022 | { |
---|
1023 | return model->model_->getReducedCost(); |
---|
1024 | } |
---|
1025 | /* Row lower */ |
---|
1026 | COINLIBAPI const double* COINLINKAGE |
---|
1027 | Clp_getRowLower(Clp_Simplex * model) |
---|
1028 | { |
---|
1029 | return model->model_->getRowLower(); |
---|
1030 | } |
---|
1031 | /* Row upper */ |
---|
1032 | COINLIBAPI const double* COINLINKAGE |
---|
1033 | Clp_getRowUpper(Clp_Simplex * model) |
---|
1034 | { |
---|
1035 | return model->model_->getRowUpper(); |
---|
1036 | } |
---|
1037 | /* Objective */ |
---|
1038 | COINLIBAPI const double * COINLINKAGE |
---|
1039 | Clp_getObjCoefficients(Clp_Simplex * model) |
---|
1040 | { |
---|
1041 | return model->model_->getObjCoefficients(); |
---|
1042 | } |
---|
1043 | /* Column Lower */ |
---|
1044 | COINLIBAPI const double * COINLINKAGE |
---|
1045 | Clp_getColLower(Clp_Simplex * model) |
---|
1046 | { |
---|
1047 | return model->model_->getColLower(); |
---|
1048 | } |
---|
1049 | /* Column Upper */ |
---|
1050 | COINLIBAPI const double * COINLINKAGE |
---|
1051 | Clp_getColUpper(Clp_Simplex * model) |
---|
1052 | { |
---|
1053 | return model->model_->getColUpper(); |
---|
1054 | } |
---|
1055 | /* Objective value */ |
---|
1056 | COINLIBAPI double COINLINKAGE |
---|
1057 | Clp_getObjValue(Clp_Simplex * model) |
---|
1058 | { |
---|
1059 | return model->model_->getObjValue(); |
---|
1060 | } |
---|
1061 | /* Get variable basis info */ |
---|
1062 | COINLIBAPI int COINLINKAGE |
---|
1063 | Clp_getColumnStatus(Clp_Simplex * model,int sequence) |
---|
1064 | { |
---|
1065 | return (int) model->model_->getColumnStatus(sequence); |
---|
1066 | } |
---|
1067 | /* Get row basis info */ |
---|
1068 | COINLIBAPI int COINLINKAGE |
---|
1069 | Clp_getRowStatus(Clp_Simplex * model,int sequence) |
---|
1070 | { |
---|
1071 | return (int) model->model_->getRowStatus(sequence); |
---|
1072 | } |
---|
1073 | /* Set variable basis info */ |
---|
1074 | COINLIBAPI void COINLINKAGE |
---|
1075 | Clp_setColumnStatus(Clp_Simplex * model,int sequence, int value) |
---|
1076 | { |
---|
1077 | if (value>=0&&value<=5) { |
---|
1078 | model->model_->setColumnStatus(sequence,(ClpSimplex::Status) value ); |
---|
1079 | if (value==3||value==5) |
---|
1080 | model->model_->primalColumnSolution()[sequence]= |
---|
1081 | model->model_->columnLower()[sequence]; |
---|
1082 | else if (value==2) |
---|
1083 | model->model_->primalColumnSolution()[sequence]= |
---|
1084 | model->model_->columnUpper()[sequence]; |
---|
1085 | } |
---|
1086 | } |
---|
1087 | /* Set row basis info */ |
---|
1088 | COINLIBAPI void COINLINKAGE |
---|
1089 | Clp_setRowStatus(Clp_Simplex * model,int sequence, int value) |
---|
1090 | { |
---|
1091 | if (value>=0&&value<=5) { |
---|
1092 | model->model_->setRowStatus(sequence,(ClpSimplex::Status) value ); |
---|
1093 | if (value==3||value==5) |
---|
1094 | model->model_->primalRowSolution()[sequence]= |
---|
1095 | model->model_->rowLower()[sequence]; |
---|
1096 | else if (value==2) |
---|
1097 | model->model_->primalRowSolution()[sequence]= |
---|
1098 | model->model_->rowUpper()[sequence]; |
---|
1099 | } |
---|
1100 | } |
---|
1101 | /* Small element value - elements less than this set to zero, |
---|
1102 | default is 1.0e-20 */ |
---|
1103 | COINLIBAPI double COINLINKAGE |
---|
1104 | Clp_getSmallElementValue(Clp_Simplex * model) |
---|
1105 | { |
---|
1106 | return model->model_->getSmallElementValue(); |
---|
1107 | } |
---|
1108 | COINLIBAPI void COINLINKAGE |
---|
1109 | Clp_setSmallElementValue(Clp_Simplex * model,double value) |
---|
1110 | { |
---|
1111 | model->model_->setSmallElementValue(value); |
---|
1112 | } |
---|
1113 | /* Print model */ |
---|
1114 | COINLIBAPI void COINLINKAGE |
---|
1115 | Clp_printModel(Clp_Simplex * model, const char * prefix) |
---|
1116 | { |
---|
1117 | ClpSimplex *clp_simplex = model->model_; |
---|
1118 | int numrows = clp_simplex->numberRows(); |
---|
1119 | int numcols = clp_simplex->numberColumns(); |
---|
1120 | int numelem = clp_simplex->getNumElements(); |
---|
1121 | const CoinBigIndex *start = clp_simplex->matrix()->getVectorStarts(); |
---|
1122 | const int *index = clp_simplex->matrix()->getIndices(); |
---|
1123 | const double *value = clp_simplex->matrix()->getElements(); |
---|
1124 | const double *collb = model->model_->columnLower(); |
---|
1125 | const double *colub = model->model_->columnUpper(); |
---|
1126 | const double *obj = model->model_->objective(); |
---|
1127 | const double *rowlb = model->model_->rowLower(); |
---|
1128 | const double *rowub = model->model_->rowUpper(); |
---|
1129 | printf("%s numcols = %i, numrows = %i, numelem = %i\n", |
---|
1130 | prefix, numcols, numrows, numelem); |
---|
1131 | printf("%s model = %p, start = %p, index = %p, value = %p\n", |
---|
1132 | prefix, reinterpret_cast<const void *>(model), reinterpret_cast<const void *>(start), reinterpret_cast<const void *>(index), reinterpret_cast<const void *>(value)); |
---|
1133 | clp_simplex->matrix()->dumpMatrix(NULL); |
---|
1134 | { |
---|
1135 | int i; |
---|
1136 | for (i=0; i<=numcols; i++) |
---|
1137 | printf("%s start[%i] = %i\n", prefix, i, start[i]); |
---|
1138 | for (i=0; i< numelem; i++) |
---|
1139 | printf("%s index[%i] = %i, value[%i] = %g\n", |
---|
1140 | prefix, i, index[i], i, value[i]); |
---|
1141 | } |
---|
1142 | |
---|
1143 | printf("%s collb = %p, colub = %p, obj = %p, rowlb = %p, rowub = %p\n", |
---|
1144 | prefix, reinterpret_cast<const void *>(collb), reinterpret_cast<const void *>(colub), reinterpret_cast<const void *>(obj), reinterpret_cast<const void *>(rowlb), reinterpret_cast<const void *>(rowub)); |
---|
1145 | printf("%s optimization direction = %g\n",prefix, Clp_optimizationDirection(model)); |
---|
1146 | printf(" (1 - minimize, -1 - maximize, 0 - ignore)\n"); |
---|
1147 | { |
---|
1148 | int i; |
---|
1149 | for (i=0; i<numcols; i++) |
---|
1150 | printf("%s collb[%i] = %g, colub[%i] = %g, obj[%i] = %g\n", |
---|
1151 | prefix, i, collb[i], i, colub[i], i, obj[i]); |
---|
1152 | for (i=0; i< numrows; i++) |
---|
1153 | printf("%s rowlb[%i] = %g, rowub[%i] = %g\n", |
---|
1154 | prefix, i, rowlb[i], i, rowub[i]); |
---|
1155 | } |
---|
1156 | } |
---|
1157 | #if defined(__MWERKS__) |
---|
1158 | #pragma export off |
---|
1159 | #endif |
---|
1160 | |
---|