Debian Codegraph @

Osi/src/OsiMsk/OsiMskSolverInterface.hpp

raw symbols SCIP
1 // Osi interface for Mosek ver. 5.0
2 // Lower versions are not supported
3 //-----------------------------------------------------------------------------
4 // name: OSI Interface for MOSEK
5 // author: Bo Jensen
6 // email: [email protected]
7 //-----------------------------------------------------------------------------
8
9 // This code is licensed under the terms of the Eclipse Public License (EPL).
10
11 #ifndef OsiMskSolverInterface_H
12 #define OsiMskSolverInterface_H
13
14 #include "OsiSolverInterface.hpp"
15
16 typedef void* MSKtask_t;
17 typedef void* MSKenv_t;
18
19 /* MOSEK Solver Interface
20 Instantiation of OsiMskSolverInterface for MOSEK
21 */
22
23 class OsiMskSolverInterface :
24 virtual public OsiSolverInterface {
25 friend void OsiMskSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
26 public:
27
28 //---------------------------------------------------------------------------
29 /**@name Solve methods */
30 //@{
31 /// Solve initial LP relaxation
32 virtual void initialSolve();
33
34 /// Resolve an LP relaxation after problem modification
35 virtual void resolve();
36
37 /// Invoke solver's built-in enumeration algorithm
38 virtual void branchAndBound();
39 //@}
40
41 //---------------------------------------------------------------------------
42 /**@name Parameter set/get methods
43
44 The set methods return true if the parameter was set to the given value,
45 false otherwise. There can be various reasons for failure: the given
46 parameter is not applicable for the solver (e.g., refactorization
47 frequency for the volume algorithm), the parameter is not yet implemented
48 for the solver or simply the value of the parameter is out of the range
49 the solver accepts. If a parameter setting call returns false check the
50 details of your solver.
51
52 The get methods return true if the given parameter is applicable for the
53 solver and is implemented. In this case the value of the parameter is
54 returned in the second argument. Otherwise they return false.
55 */
56 //@{
57 // Set an integer parameter
58 bool setIntParam(OsiIntParam key, int value);
59 // Set an double parameter
60 bool setDblParam(OsiDblParam key, double value);
61 // Set a string parameter
62 bool setStrParam(OsiStrParam key, const std::string & value);
63 // Get an integer parameter
64 bool getIntParam(OsiIntParam key, int& value) const;
65 // Get an double parameter
66 bool getDblParam(OsiDblParam key, double& value) const;
67 // Get a string parameter
68 bool getStrParam(OsiStrParam key, std::string& value) const;
69 //@}
70
71 //---------------------------------------------------------------------------
72 ///@name Methods returning info on how the solution process terminated
73 //@{
74 /// Are there a numerical difficulties?
75 virtual bool isAbandoned() const;
76 /// Is optimality proven?
77 virtual bool isProvenOptimal() const;
78 /// Is primal infeasiblity proven?
79 virtual bool isProvenPrimalInfeasible() const;
80 /// Is dual infeasiblity proven?
81 virtual bool isProvenDualInfeasible() const;
82 /// Is the given primal objective limit reached?
83 virtual bool isPrimalObjectiveLimitReached() const;
84 /// Is the given dual objective limit reached?
85 virtual bool isDualObjectiveLimitReached() const;
86 /// Iteration limit reached?
87 virtual bool isIterationLimitReached() const;
88 /// Has there been a license problem?
89 virtual bool isLicenseError() const;
90 /// Get rescode return of last Mosek optimizer call
91 int getRescode() const { return Mskerr; }
92 //@}
93
94 //---------------------------------------------------------------------------
95 /**@name WarmStart related methods */
96
97 /*! \brief Get an empty warm start object
98
99 This routine returns an empty CoinWarmStartBasis object. Its purpose is
100 to provide a way to give a client a warm start basis object of the
101 appropriate type, which can resized and modified as desired.
102 */
103 CoinWarmStart* getEmptyWarmStart () const;
104
105 //@{
106 /// Get warmstarting information
107 virtual CoinWarmStart* getWarmStart() const;
108 /** Set warmstarting information. Return true/false depending on whether
109 the warmstart information was accepted or not. */
110 virtual bool setWarmStart(const CoinWarmStart* warmstart);
111 //@}
112
113 //---------------------------------------------------------------------------
114 /**@name Hotstart related methods (primarily used in strong branching). <br>
115 The user can create a hotstart (a snapshot) of the optimization process
116 then reoptimize over and over again always starting from there.<br>
117 <strong>NOTE</strong>: between hotstarted optimizations only
118 bound changes are allowed. */
119 //@{
120 /// Create a hotstart point of the optimization process
121 virtual void markHotStart();
122 /// Optimize starting from the hotstart
123 virtual void solveFromHotStart();
124 /// Delete the snapshot
125 virtual void unmarkHotStart();
126 //@}
127
128 //---------------------------------------------------------------------------
129 /**@name Problem information methods
130
131 These methods call the solver's query routines to return
132 information about the problem referred to by the current object.
133 Querying a problem that has no data associated with it result in
134 zeros for the number of rows and columns, and NULL pointers from
135 the methods that return vectors.
136
137 Const pointers returned from any data-query method are valid as
138 long as the data is unchanged and the solver is not called.
139 */
140 //@{
141 /**@name Methods related to querying the input data */
142 //@{
143 /// Get number of columns
144 virtual int getNumCols() const;
145
146 /// Get number of rows
147 virtual int getNumRows() const;
148
149 /// Get number of nonzero elements
150 virtual int getNumElements() const;
151
152 /// Get pointer to array[getNumCols()] of column lower bounds
153 virtual const double * getColLower() const;
154
155 /// Get pointer to array[getNumCols()] of column upper bounds
156 virtual const double * getColUpper() const;
157
158 /** Get pointer to array[getNumRows()] of row constraint senses.
159 <ul>
160 <li>'L': <= constraint
161 <li>'E': = constraint
162 <li>'G': >= constraint
163 <li>'R': ranged constraint
164 <li>'N': free constraint
165 </ul>
166 */
167 virtual const char * getRowSense() const;
168
169 /** Get pointer to array[getNumRows()] of rows right-hand sides
170 <ul>
171 <li> if rowsense()[i] == 'L' then rhs()[i] == rowupper()[i]
172 <li> if rowsense()[i] == 'G' then rhs()[i] == rowlower()[i]
173 <li> if rowsense()[i] == 'R' then rhs()[i] == rowupper()[i]
174 <li> if rowsense()[i] == 'N' then rhs()[i] == 0.0
175 </ul>
176 */
177 virtual const double * getRightHandSide() const;
178
179 /** Get pointer to array[getNumRows()] of row ranges.
180 <ul>
181 <li> if rowsense()[i] == 'R' then
182 rowrange()[i] == rowupper()[i] - rowlower()[i]
183 <li> if rowsense()[i] != 'R' then
184 rowrange()[i] is 0.0
185 </ul>
186 */
187 virtual const double * getRowRange() const;
188
189 /// Get pointer to array[getNumRows()] of row lower bounds
190 virtual const double * getRowLower() const;
191
192 /// Get pointer to array[getNumRows()] of row upper bounds
193 virtual const double * getRowUpper() const;
194
195 /// Get pointer to array[getNumCols()] of objective function coefficients
196 virtual const double * getObjCoefficients() const;
197
198 /// Get objective function sense (1 for min (default), -1 for max)
199 virtual double getObjSense() const;
200
201 /// Return true if column is continuous
202 virtual bool isContinuous(int colNumber) const;
203
204 #if 0
205 /// Return true if column is binary
206 virtual bool isBinary(int columnNumber) const;
207
208 /** Return true if column is integer.
209 Note: This function returns true if the the column
210 is binary or a general integer.
211 */
212 virtual bool isInteger(int columnNumber) const;
213
214 /// Return true if column is general integer
215 virtual bool isIntegerNonBinary(int columnNumber) const;
216
217 /// Return true if column is binary and not fixed at either bound
218 virtual bool isFreeBinary(int columnNumber) const;
219 #endif
220
221 /// Get pointer to row-wise copy of matrix
222 virtual const CoinPackedMatrix * getMatrixByRow() const;
223
224 /// Get pointer to column-wise copy of matrix
225 virtual const CoinPackedMatrix * getMatrixByCol() const;
226
227 /// Get solver's value for infinity
228 virtual double getInfinity() const;
229 //@}
230
231 /**@name Methods related to querying the solution */
232 //@{
233 /// Get pointer to array[getNumCols()] of primal solution vector
234 virtual const double * getColSolution() const;
235
236 /// Get pointer to array[getNumRows()] of dual prices
237 virtual const double * getRowPrice() const;
238
239 /// Get a pointer to array[getNumCols()] of reduced costs
240 virtual const double * getReducedCost() const;
241
242 /** Get pointer to array[getNumRows()] of row activity levels (constraint
243 matrix times the solution vector */
244 virtual const double * getRowActivity() const;
245
246 /// Get objective function value
247 virtual double getObjValue() const;
248
249 /** Get how many iterations it took to solve the problem (whatever
250 "iteration" mean to the solver. */
251 virtual int getIterationCount() const;
252
253 /** Get as many dual rays as the solver can provide. (In case of proven
254 primal infeasibility there should be at least one.)
255
256 The first getNumRows() ray components will always be associated with
257 the row duals (as returned by getRowPrice()). If \c fullRay is true,
258 the final getNumCols() entries will correspond to the ray components
259 associated with the nonbasic variables. If the full ray is requested
260 and the method cannot provide it, it will throw an exception.
261
262 <strong>NOTE for implementers of solver interfaces:</strong> <br>
263 The double pointers in the vector should point to arrays of length
264 getNumRows() and they should be allocated via new[]. <br>
265
266 <strong>NOTE for users of solver interfaces:</strong> <br>
267 It is the user's responsibility to free the double pointers in the
268 vector using delete[].
269 */
270 virtual std::vector<double*> getDualRays(int maxNumRays,
271 bool fullRay=false) const;
272 /** Get as many primal rays as the solver can provide. (In case of proven
273 dual infeasibility there should be at least one.)
274
275 <strong>NOTE for implementers of solver interfaces:</strong> <br>
276 The double pointers in the vector should point to arrays of length
277 getNumCols() and they should be allocated via new[]. <br>
278
279 <strong>NOTE for users of solver interfaces:</strong> <br>
280 It is the user's responsibility to free the double pointers in the
281 vector using delete[].
282 */
283 virtual std::vector<double*> getPrimalRays(int maxNumRays) const;
284
285 #if 0
286 /** Get vector of indices of solution which are integer variables
287 presently at fractional values */
288 virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05)
289 const;
290 #endif
291 //@}
292 //@}
293
294 //---------------------------------------------------------------------------
295
296 /**@name Problem modifying methods */
297 //@{
298 //-------------------------------------------------------------------------
299 /**@name Changing bounds on variables and constraints */
300 //@{
301 /** Set an objective function coefficient */
302 virtual void setObjCoeff( int elementIndex, double elementValue );
303
304 /** Set a a set of objective function coefficients */
305 virtual void setObjCoeffSet(const int* indexFirst,
306 const int* indexLast,
307 const double* coeffList);
308
309 /** Set a single column lower bound<br>
310 Use -COIN_DBL_MAX for -infinity. */
311 virtual void setColLower( int elementIndex, double elementValue );
312
313 /** Set a single column upper bound<br>
314 Use COIN_DBL_MAX for infinity. */
315 virtual void setColUpper( int elementIndex, double elementValue );
316
317 /** Set a single column lower and upper bound<br>
318 The default implementation just invokes <code>setColLower()</code> and
319 <code>setColUpper()</code> */
320 virtual void setColBounds( int elementIndex,
321 double lower, double upper );
322
323 /** Set the bounds on a number of columns simultaneously<br>
324 The default implementation just invokes <code>setCollower()</code> and
325 <code>setColupper()</code> over and over again.
326 @param <code>[indexfirst,indexLast]</code> contains the indices of
327 the constraints whose </em>either</em> bound changes
328 @param boundList the new lower/upper bound pairs for the variables
329 */
330 virtual void setColSetBounds(const int* indexFirst,
331 const int* indexLast,
332 const double* boundList);
333
334 /** Set a single row lower bound<br>
335 Use -COIN_DBL_MAX for -infinity. */
336 virtual void setRowLower( int elementIndex, double elementValue );
337
338 /** Set a single row upper bound<br>
339 Use COIN_DBL_MAX for infinity. */
340 virtual void setRowUpper( int elementIndex, double elementValue );
341
342 /** Set a single row lower and upper bound<br>
343 The default implementation just invokes <code>setRowLower()</code> and
344 <code>setRowUpper()</code> */
345 virtual void setRowBounds( int elementIndex,
346 double lower, double upper );
347
348 /** Set the type of a single row<br> */
349 virtual void setRowType(int index, char sense, double rightHandSide,
350 double range);
351
352 /** Set the bounds on a number of rows simultaneously<br>
353 The default implementation just invokes <code>setRowLower()</code> and
354 <code>setRowUpper()</code> over and over again.
355 @param <code>[indexfirst,indexLast]</code> contains the indices of
356 the constraints whose </em>either</em> bound changes
357 @param boundList the new lower/upper bound pairs for the constraints
358 */
359 virtual void setRowSetBounds(const int* indexFirst,
360 const int* indexLast,
361 const double* boundList);
362
363 /** Set the type of a number of rows simultaneously<br>
364 The default implementation just invokes <code>setRowType()</code> and
365 over and over again.
366 @param <code>[indexfirst,indexLast]</code> contains the indices of
367 the constraints whose type changes
368 @param senseList the new senses
369 @param rhsList the new right hand sides
370 @param rangeList the new ranges
371 */
372 virtual void setRowSetTypes(const int* indexFirst,
373 const int* indexLast,
374 const char* senseList,
375 const double* rhsList,
376 const double* rangeList);
377 //@}
378
379 //-------------------------------------------------------------------------
380 /**@name Integrality related changing methods */
381 //@{
382 /** Set the index-th variable to be a continuous variable */
383 virtual void setContinuous(int index);
384 /** Set the index-th variable to be an integer variable */
385 virtual void setInteger(int index);
386 /** Set the variables listed in indices (which is of length len) to be
387 continuous variables */
388 virtual void setContinuous(const int* indices, int len);
389 /** Set the variables listed in indices (which is of length len) to be
390 integer variables */
391 virtual void setInteger(const int* indices, int len);
392 //@}
393
394 //-------------------------------------------------------------------------
395 /// Set objective function sense (1 for min (default), -1 for max,)
396 virtual void setObjSense(double s);
397
398 /** Set the primal solution column values
399
400 colsol[numcols()] is an array of values of the problem column
401 variables. These values are copied to memory owned by the
402 solver object or the solver. They will be returned as the
403 result of colsol() until changed by another call to
404 setColsol() or by a call to any solver routine. Whether the
405 solver makes use of the solution in any way is
406 solver-dependent.
407 */
408 virtual void setColSolution(const double * colsol);
409
410 /** Set dual solution vector
411
412 rowprice[numrows()] is an array of values of the problem row
413 dual variables. These values are copied to memory owned by the
414 solver object or the solver. They will be returned as the
415 result of rowprice() until changed by another call to
416 setRowprice() or by a call to any solver routine. Whether the
417 solver makes use of the solution in any way is
418 solver-dependent.
419 */
420 virtual void setRowPrice(const double * rowprice);
421
422 //-------------------------------------------------------------------------
423 /**@name Methods to expand a problem.<br>
424 Note that if a column is added then by default it will correspond to a
425 continuous variable. */
426 //@{
427 /** */
428 virtual void addCol(const CoinPackedVectorBase& vec,
429 const double collb, const double colub,
430 const double obj);
431 /** */
432 virtual void addCols(const int numcols,
433 const CoinPackedVectorBase * const * cols,
434 const double* collb, const double* colub,
435 const double* obj);
436 /** */
437 virtual void deleteCols(const int num, const int * colIndices);
438
439 /** */
440 virtual void addRow(const CoinPackedVectorBase& vec,
441 const double rowlb, const double rowub);
442 /** */
443 virtual void addRow(const CoinPackedVectorBase& vec,
444 const char rowsen, const double rowrhs,
445 const double rowrng);
446 /** */
447 virtual void addRows(const int numrows,
448 const CoinPackedVectorBase * const * rows,
449 const double* rowlb, const double* rowub);
450 /** */
451 virtual void addRows(const int numrows,
452 const CoinPackedVectorBase * const * rows,
453 const char* rowsen, const double* rowrhs,
454 const double* rowrng);
455 /** */
456 virtual void deleteRows(const int num, const int * rowIndices);
457
458 #if 0
459 // ??? implemented in OsiSolverInterface
460 //-----------------------------------------------------------------------
461 /** Apply a collection of cuts.<br>
462 Only cuts which have an <code>effectiveness >= effectivenessLb</code>
463 are applied.
464 <ul>
465 <li> ReturnCode.numberIneffective() -- number of cuts which were
466 not applied because they had an
467 <code>effectiveness < effectivenessLb</code>
468 <li> ReturnCode.numberInconsistent() -- number of invalid cuts
469 <li> ReturnCode.numberInconsistentWrtIntegerModel() -- number of
470 cuts that are invalid with respect to this integer model
471 <li> ReturnCode.numberInfeasible() -- number of cuts that would
472 make this integer model infeasible
473 <li> ReturnCode.numberApplied() -- number of integer cuts which
474 were applied to the integer model
475 <li> cs.size() == numberIneffective() +
476 numberInconsistent() +
477 numberInconsistentWrtIntegerModel() +
478 numberInfeasible() +
479 nubmerApplied()
480 </ul>
481 */
482 virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
483 double effectivenessLb = 0.0);
484 #endif
485 //@}
486 //@}
487
488 //---------------------------------------------------------------------------
489
490 /**@name Methods to input a problem */
491 //@{
492 /** Load in an problem by copying the arguments (the constraints on the
493 rows are given by lower and upper bounds). If a pointer is 0 then the
494 following values are the default:
495 <ul>
496 <li> <code>colub</code>: all columns have upper bound infinity
497 <li> <code>collb</code>: all columns have lower bound 0
498 <li> <code>rowub</code>: all rows have upper bound infinity
499 <li> <code>rowlb</code>: all rows have lower bound -infinity
500 <li> <code>obj</code>: all variables have 0 objective coefficient
501 </ul>
502 */
503 virtual void loadProblem(const CoinPackedMatrix& matrix,
504 const double* collb, const double* colub,
505 const double* obj,
506 const double* rowlb, const double* rowub);
507
508 /** Load in an problem by assuming ownership of the arguments (the
509 constraints on the rows are given by lower and upper bounds). For
510 default values see the previous method. <br>
511 <strong>WARNING</strong>: The arguments passed to this method will be
512 freed using the C++ <code>delete</code> and <code>delete[]</code>
513 functions.
514 */
515 virtual void assignProblem(CoinPackedMatrix*& matrix,
516 double*& collb, double*& colub, double*& obj,
517 double*& rowlb, double*& rowub);
518
519 /** Load in an problem by copying the arguments (the constraints on the
520 rows are given by sense/rhs/range triplets). If a pointer is 0 then the
521 following values are the default:
522 <ul>
523 <li> <code>colub</code>: all columns have upper bound infinity
524 <li> <code>collb</code>: all columns have lower bound 0
525 <li> <code>obj</code>: all variables have 0 objective coefficient
526 <li> <code>rowsen</code>: all rows are >=
527 <li> <code>rowrhs</code>: all right hand sides are 0
528 <li> <code>rowrng</code>: 0 for the ranged rows
529 </ul>
530 */
531 virtual void loadProblem(const CoinPackedMatrix& matrix,
532 const double* collb, const double* colub,
533 const double* obj,
534 const char* rowsen, const double* rowrhs,
535 const double* rowrng);
536
537 /** Load in an problem by assuming ownership of the arguments (the
538 constraints on the rows are given by sense/rhs/range triplets). For
539 default values see the previous method. <br>
540 <strong>WARNING</strong>: The arguments passed to this method will be
541 freed using the C++ <code>delete</code> and <code>delete[]</code>
542 functions.
543 */
544 virtual void assignProblem(CoinPackedMatrix*& matrix,
545 double*& collb, double*& colub, double*& obj,
546 char*& rowsen, double*& rowrhs,
547 double*& rowrng);
548
549 /** Just like the other loadProblem() methods except that the matrix is
550 given in a standard column major ordered format (without gaps). */
551 virtual void loadProblem(const int numcols, const int numrows,
552 const int* start, const int* index,
553 const double* value,
554 const double* collb, const double* colub,
555 const double* obj,
556 const double* rowlb, const double* rowub);
557
558 /** Just like the other loadProblem() methods except that the matrix is
559 given in a standard column major ordered format (without gaps). */
560 virtual void loadProblem(const int numcols, const int numrows,
561 const int* start, const int* index,
562 const double* value,
563 const double* collb, const double* colub,
564 const double* obj,
565 const char* rowsen, const double* rowrhs,
566 const double* rowrng);
567
568 /** Read an mps file from the given filename */
569 virtual int readMps(const char *filename,
570 const char *extension = "mps");
571
572 /** Write the problem into an mps file of the given filename.
573 If objSense is non zero then -1.0 forces the code to write a
574 maximization objective and +1.0 to write a minimization one.
575 If 0.0 then solver can do what it wants */
576 virtual void writeMps(const char *filename,
577 const char *extension = "mps",
578 double objSense=0.0) const;
579 //@}
580
581 /**@name Message handling */
582 //@{
583 /** Pass in a message handler
584 It is the client's responsibility to destroy a message handler installed
585 by this routine; it will not be destroyed when the solver interface is
586 destroyed.
587 */
588 void passInMessageHandler(CoinMessageHandler * handler);
589 //@}
590
591 //---------------------------------------------------------------------------
592
593 /**@name MOSEK specific public interfaces */
594 //@{
595 /** Get pointer to MOSEK model and free all specified cached data entries
596 (combined with logical or-operator '|' ):
597 */
598 enum keepCachedFlag
599 {
600 /// discard all cached data (default)
601 KEEPCACHED_NONE = 0,
602 /// column information: objective values, lower and upper bounds, variable types
603 KEEPCACHED_COLUMN = 1,
604 /// row information: right hand sides, ranges and senses, lower and upper bounds for row
605 KEEPCACHED_ROW = 2,
606 /// problem matrix: matrix ordered by column and by row
607 KEEPCACHED_MATRIX = 4,
608 /// LP solution: primal and dual solution, reduced costs, row activities
609 KEEPCACHED_RESULTS = 8,
610 /// only discard cached LP solution
611 KEEPCACHED_PROBLEM = KEEPCACHED_COLUMN | KEEPCACHED_ROW | KEEPCACHED_MATRIX,
612 /// keep all cached data (similar to getMutableLpPtr())
613 KEEPCACHED_ALL = KEEPCACHED_PROBLEM | KEEPCACHED_RESULTS,
614 /// free only cached column and LP solution information
615 FREECACHED_COLUMN = KEEPCACHED_PROBLEM & ~KEEPCACHED_COLUMN,
616 /// free only cached row and LP solution information
617 FREECACHED_ROW = KEEPCACHED_PROBLEM & ~KEEPCACHED_ROW,
618 /// free only cached matrix and LP solution information
619 FREECACHED_MATRIX = KEEPCACHED_PROBLEM & ~KEEPCACHED_MATRIX,
620 /// free only cached LP solution information
621 FREECACHED_RESULTS = KEEPCACHED_ALL & ~KEEPCACHED_RESULTS
622 };
623
624 MSKtask_t getLpPtr( int keepCached = KEEPCACHED_NONE );
625
626 //@{
627 /// Method to access MOSEK environment pointer
628 MSKenv_t getEnvironmentPtr();
629 //@}
630
631 /// return a vector of variable types (continous, binary, integer)
632 const char* getCtype() const;
633
634 /**@name Static instance counter methods */
635 /** MOSEK has a context which must be created prior to all other MOSEK calls.
636 This method:
637 <ul>
638 <li>Increments by 1 the number of uses of the MOSEK environment.
639 <li>Creates the MOSEK context when the number of uses is change to
640 1 from 0.
641 </ul>
642 */
643 static void incrementInstanceCounter();
644
645 /** MOSEK has a context which should be deleted after MOSEK calls.
646 This method:
647 <ul>
648 <li>Decrements by 1 the number of uses of the MOSEK environment.
649 <li>Deletes the MOSEK context when the number of uses is change to
650 0 from 1.
651 </ul>
652 */
653 static void decrementInstanceCounter();
654
655 /// Return the number of instances of instantiated objects using MOSEK services.
656 static unsigned int getNumInstances();
657 //@}
658 //@}
659
660 /**@name Constructors and destructor */
661 //@{
662 /// Default Constructor
663 /// optional argument mskenv can be used to reach in an initialized user environment
664 /// OsiMsk assumes membership of mskenv, so it will be freed when the last instanciation of OsiMsk is deleted
665 OsiMskSolverInterface(MSKenv_t mskenv = NULL);
666
667 /// Clone
668 virtual OsiSolverInterface * clone(bool copyData = true) const;
669
670 /// Copy constructor
671 OsiMskSolverInterface( const OsiMskSolverInterface& );
672
673 /// Assignment operator
674 OsiMskSolverInterface& operator=( const OsiMskSolverInterface& rhs );
675
676 /// Destructor
677 virtual ~OsiMskSolverInterface();
678 //@}
679
680 protected:
681
682 /**@name Protected methods */
683 //@{
684 /// Apply a row cut. Return true if cut was applied.
685 virtual void applyRowCut( const OsiRowCut & rc );
686
687 /** Apply a column cut (bound adjustment).
688 Return true if cut was applied.
689 */
690 virtual void applyColCut( const OsiColCut & cc );
691 //@}
692
693 private:
694 /**@name Private static class functions */
695 //@{
696 /// switches MOSEK to prob type LP
697 void switchToLP();
698
699 /// switches MOSEK to prob type MIP
700 void switchToMIP();
701
702 /// resizes coltype_ vector to be able to store at least minsize elements
703 void resizeColType( int minsize );
704
705 /// frees colsize_ vector
706 void freeColType();
707
708 bool definedSolution(int solution) const;
709
710 int solverUsed() const;
711
712 //@}
713
714 /**@name Private static class data */
715 //@{
716 /// MOSEK environment pointer
717 static MSKenv_t env_ ;
718
719 /// Number of live problem instances
720 //static unsigned int numInstances_;
721 //@}
722 static unsigned int numInstances_;
723
724 /**@name Private methods */
725 //@{
726
727 int Mskerr;
728 int MSKsolverused_;
729 double ObjOffset_;
730
731 int InitialSolver;
732
733 /// Get task Pointer for const methods
734 public: MSKtask_t getMutableLpPtr() const;
735
736 /// The real work of a copy constructor (used by copy and assignment)
737 void gutsOfCopy( const OsiMskSolverInterface & source );
738
739 /// The real work of the constructor
740 void gutsOfConstructor();
741
742 /// The real work of the destructor
743 void gutsOfDestructor();
744
745 /// free cached column rim vectors
746 void freeCachedColRim();
747
748 /// free cached row rim vectors
749 void freeCachedRowRim();
750
751 /// free cached result vectors
752 void freeCachedResults();
753
754 /// free cached matrices
755 void freeCachedMatrix();
756
757 /// free all cached data (except specified entries, see getLpPtr())
758 void freeCachedData( int keepCached = KEEPCACHED_NONE );
759
760 /// free all allocated memory
761 void freeAllMemory();
762
763 /**@name Private member data */
764 //@{
765 /// MOSEK model represented by this class instance
766 mutable MSKtask_t task_;
767
768 /// Hotstart information
769 int *hotStartCStat_;
770 int hotStartCStatSize_;
771 int *hotStartRStat_;
772 int hotStartRStatSize_;
773 int hotStartMaxIteration_;
774
775 /**@name Cached information derived from the MOSEK model */
776 //@{
777 /// Pointer to objective vector
778 mutable double *obj_;
779
780 /// Pointer to dense vector of variable lower bounds
781 mutable double *collower_;
782
783 /// Pointer to dense vector of variable lower bounds
784 mutable double *colupper_;
785
786 /// Pointer to dense vector of row sense indicators
787 mutable char *rowsense_;
788
789 /// Pointer to dense vector of row right-hand side values
790 mutable double *rhs_;
791
792 /// Pointer to dense vector of slack upper bounds for range constraints (undefined for non-range rows)
793 mutable double *rowrange_;
794
795 /// Pointer to dense vector of row lower bounds
796 mutable double *rowlower_;
797
798 /// Pointer to dense vector of row upper bounds
799 mutable double *rowupper_;
800
801 /// Pointer to primal solution vector
802 mutable double *colsol_;
803
804 /// Pointer to dual solution vector
805 mutable double *rowsol_;
806
807 /// Pointer to reduced cost vector
808 mutable double *redcost_;
809
810 /// Pointer to row activity (slack) vector
811 mutable double *rowact_;
812
813 /// Pointer to row-wise copy of problem matrix coefficients.
814 mutable CoinPackedMatrix *matrixByRow_;
815
816 /// Pointer to row-wise copy of problem matrix coefficients.
817 mutable CoinPackedMatrix *matrixByCol_;
818 //@}
819
820 /**@name Additional information needed for storing MIP problems */
821 //@{
822 /// Pointer to dense vector of variable types (continous, binary, integer)
823 char *coltype_;
824
825 /// Size of allocated memory for coltype_
826 int coltypesize_;
827
828 /// Stores whether MOSEK' prob type is currently set to MIP
829 mutable bool probtypemip_;
830
831 //@}
832 };
833
834 //#############################################################################
835 /** A function that tests the methods in the OsiMskSolverInterface class */
836 void OsiMskSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
837
838 #endif