Skip to content

Commit 535a72b

Browse files
committed
Useful constructor added.
1 parent 1ee1445 commit 535a72b

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

src/OsiMosekSolverInterface.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,31 @@ OsiMosekSolverInterface::OsiMosekSolverInterface(const OsiMosekSolverInterface &
6565
checkMSKerror(res, "MSK_putintparam", "OsiMosekSolverInterface");
6666
}
6767

68+
// copy constructor
69+
OsiMosekSolverInterface::OsiMosekSolverInterface(const OsiConicSolverInterface * other):
70+
OsiSolverInterface(*other){
71+
MSKrescodee res;
72+
MSKtask_t task = getLpPtr();
73+
// set number of threads to 1
74+
res = MSK_putintparam(task, MSK_IPAR_NUM_THREADS, 1);
75+
checkMSKerror(res, "MSK_putintparam", "OsiMosekSolverInterface");
76+
// ignore integrality constraints
77+
res = MSK_putintparam(task, MSK_IPAR_MIO_MODE, MSK_MIO_MODE_IGNORED);
78+
checkMSKerror(res, "MSK_putintparam", "OsiMosekSolverInterface");
79+
// set optimizer to conic
80+
res = MSK_putintparam (task, MSK_IPAR_OPTIMIZER, MSK_OPTIMIZER_CONIC);
81+
checkMSKerror(res, "MSK_putintparam", "OsiMosekSolverInterface");
82+
// add conic constraints
83+
for (int i=0; i<other->getNumCones(); ++i) {
84+
OsiLorentzConeType type;
85+
int size;
86+
int * members = 0;
87+
other->getConicConstraint(i, type, size, members);
88+
addConicConstraint(type, size, members);
89+
delete[] members;
90+
}
91+
}
92+
6893
// copy assignment operator
6994
OsiMosekSolverInterface & OsiMosekSolverInterface::operator=(const OsiMosekSolverInterface & rhs) {
7095
// copy rhs to this

src/OsiMosekSolverInterface.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,34 @@
66
#include <CoinPackedMatrix.hpp>
77

88
class OsiMosekSolverInterface: virtual public OsiConicSolverInterface,
9-
virtual public OsiMskSolverInterface {
9+
virtual public OsiMskSolverInterface {
1010
OsiLorentzConeType getLorentzConeType(int i) const;
1111
public:
1212
// default constructor
1313
OsiMosekSolverInterface();
1414
// copy constructor
1515
OsiMosekSolverInterface(const OsiMosekSolverInterface & other);
16+
// copy constructor
17+
OsiMosekSolverInterface(const OsiConicSolverInterface * other);
1618
// copy assignment operator
1719
OsiMosekSolverInterface & operator=(const OsiMosekSolverInterface & rhs);
1820
virtual ~OsiMosekSolverInterface();
1921
// get conic constraints
2022
virtual void getConicConstraint(int index, OsiLorentzConeType & type,
21-
int & numMembers,
22-
int *& members) const;
23+
int & numMembers,
24+
int *& members) const;
2325
// add conic constraints
2426
// add conic constraint in lorentz cone form
2527
virtual void addConicConstraint(OsiLorentzConeType type,
26-
int numMembers,
27-
const int * members);
28+
int numMembers,
29+
const int * members);
2830
// add conic constraint in |Ax-b| <= dx-h form
2931
virtual void addConicConstraint(CoinPackedMatrix const * A, CoinPackedVector const * b,
30-
CoinPackedVector const * d, double h);
32+
CoinPackedVector const * d, double h);
3133
virtual void removeConicConstraint(int index);
3234
virtual void modifyConicConstraint(int index, OsiLorentzConeType type,
33-
int numMembers,
34-
const int * members);
35+
int numMembers,
36+
const int * members);
3537
virtual int getNumCones() const;
3638
virtual int getConeSize(int i) const;
3739
virtual OsiConeType getConeType(int i) const;
@@ -41,7 +43,7 @@ class OsiMosekSolverInterface: virtual public OsiConicSolverInterface,
4143
virtual OsiConicSolverInterface * clone(bool copyData=true) const;
4244
virtual int readMps(const char * filename, const char * extension="mps");
4345
virtual void writeMps (const char *filename, const char *extension="mps",
44-
double objSense=0.0) const;
46+
double objSense=0.0) const;
4547
// hot start methods
4648
// over-write linear mosek solver interface functions
4749
virtual void markHotStart();
@@ -71,4 +73,3 @@ class OsiMosekSolverInterface: virtual public OsiConicSolverInterface,
7173
};
7274

7375
#endif
74-

0 commit comments

Comments
 (0)