Skip to content

Commit

Permalink
Useful constructor added.
Browse files Browse the repository at this point in the history
  • Loading branch information
aykutbulut committed Aug 4, 2016
1 parent 1ee1445 commit 535a72b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
25 changes: 25 additions & 0 deletions src/OsiMosekSolverInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ OsiMosekSolverInterface::OsiMosekSolverInterface(const OsiMosekSolverInterface &
checkMSKerror(res, "MSK_putintparam", "OsiMosekSolverInterface");
}

// copy constructor
OsiMosekSolverInterface::OsiMosekSolverInterface(const OsiConicSolverInterface * other):
OsiSolverInterface(*other){
MSKrescodee res;
MSKtask_t task = getLpPtr();
// set number of threads to 1
res = MSK_putintparam(task, MSK_IPAR_NUM_THREADS, 1);
checkMSKerror(res, "MSK_putintparam", "OsiMosekSolverInterface");
// ignore integrality constraints
res = MSK_putintparam(task, MSK_IPAR_MIO_MODE, MSK_MIO_MODE_IGNORED);
checkMSKerror(res, "MSK_putintparam", "OsiMosekSolverInterface");
// set optimizer to conic
res = MSK_putintparam (task, MSK_IPAR_OPTIMIZER, MSK_OPTIMIZER_CONIC);
checkMSKerror(res, "MSK_putintparam", "OsiMosekSolverInterface");
// add conic constraints
for (int i=0; i<other->getNumCones(); ++i) {
OsiLorentzConeType type;
int size;
int * members = 0;
other->getConicConstraint(i, type, size, members);
addConicConstraint(type, size, members);
delete[] members;
}
}

// copy assignment operator
OsiMosekSolverInterface & OsiMosekSolverInterface::operator=(const OsiMosekSolverInterface & rhs) {
// copy rhs to this
Expand Down
21 changes: 11 additions & 10 deletions src/OsiMosekSolverInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,34 @@
#include <CoinPackedMatrix.hpp>

class OsiMosekSolverInterface: virtual public OsiConicSolverInterface,
virtual public OsiMskSolverInterface {
virtual public OsiMskSolverInterface {
OsiLorentzConeType getLorentzConeType(int i) const;
public:
// default constructor
OsiMosekSolverInterface();
// copy constructor
OsiMosekSolverInterface(const OsiMosekSolverInterface & other);
// copy constructor
OsiMosekSolverInterface(const OsiConicSolverInterface * other);
// copy assignment operator
OsiMosekSolverInterface & operator=(const OsiMosekSolverInterface & rhs);
virtual ~OsiMosekSolverInterface();
// get conic constraints
virtual void getConicConstraint(int index, OsiLorentzConeType & type,
int & numMembers,
int *& members) const;
int & numMembers,
int *& members) const;
// add conic constraints
// add conic constraint in lorentz cone form
virtual void addConicConstraint(OsiLorentzConeType type,
int numMembers,
const int * members);
int numMembers,
const int * members);
// add conic constraint in |Ax-b| <= dx-h form
virtual void addConicConstraint(CoinPackedMatrix const * A, CoinPackedVector const * b,
CoinPackedVector const * d, double h);
CoinPackedVector const * d, double h);
virtual void removeConicConstraint(int index);
virtual void modifyConicConstraint(int index, OsiLorentzConeType type,
int numMembers,
const int * members);
int numMembers,
const int * members);
virtual int getNumCones() const;
virtual int getConeSize(int i) const;
virtual OsiConeType getConeType(int i) const;
Expand All @@ -41,7 +43,7 @@ class OsiMosekSolverInterface: virtual public OsiConicSolverInterface,
virtual OsiConicSolverInterface * clone(bool copyData=true) const;
virtual int readMps(const char * filename, const char * extension="mps");
virtual void writeMps (const char *filename, const char *extension="mps",
double objSense=0.0) const;
double objSense=0.0) const;
// hot start methods
// over-write linear mosek solver interface functions
virtual void markHotStart();
Expand Down Expand Up @@ -71,4 +73,3 @@ class OsiMosekSolverInterface: virtual public OsiConicSolverInterface,
};

#endif

0 comments on commit 535a72b

Please sign in to comment.