Skip to content

Commit

Permalink
C Interface: read optimal basis
Browse files Browse the repository at this point in the history
  • Loading branch information
h-g-s committed Aug 17, 2020
1 parent 785ae6a commit c4a885e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Cbc_C_Interface.cpp
Expand Up @@ -1274,6 +1274,18 @@ Cbc_writeMps(Cbc_Model *model, const char *filename)
model->solver_->writeMps(filename, "mps", Cbc_getObjSense(model));
}

int Cbc_readBasis(Cbc_Model *model, const char *filename) {
OsiClpSolverInterface *solver = model->solver_;
ClpSimplex *clps = solver->getModelPtr();
return clps->readBasis(filename);
}

int Cbc_writeBasis(Cbc_Model *model, const char *filename, char writeValues, int formatType) {
OsiClpSolverInterface *solver = model->solver_;
ClpSimplex *clps = solver->getModelPtr();
return clps->writeBasis(filename, writeValues, formatType);
}

/** Writes an LP file
*
* @param model problem object
Expand Down
22 changes: 22 additions & 0 deletions src/Cbc_C_Interface.h
Expand Up @@ -826,6 +826,16 @@ Cbc_readMps(Cbc_Model *model, const char *filename);
CBCSOLVERLIB_EXPORT int CBC_LINKAGE
Cbc_readLp(Cbc_Model *model, const char *filename);

/** @brief Read the optimal basis for the linear program
*
* @param model problem object
* @param fileName file name
* @return returns -1 on file error, 0 if no values, 1 if values.
**/
CBCSOLVERLIB_EXPORT int CBC_LINKAGE
Cbc_readBasis(Cbc_Model *model, const char *filename);


/** @brief Write an MPS file from the given filename
*
* @param model problem object
Expand All @@ -842,6 +852,18 @@ Cbc_writeMps(Cbc_Model *model, const char *filename);
CBCSOLVERLIB_EXPORT void CBC_LINKAGE
Cbc_writeLp(Cbc_Model *model, const char *filename);

/** @brief Saves the optimal basis for the linear program
*
* @param model problem object
* @param fileName file name
* @param writeValues If writeValues = 1 writes values of structurals (and adds VALUES to end of NAME card), 0 otherwise
* @param formatType 0 - normal, 1 - extra accuracy, 2 - IEEE hex(later)
* @return non-zero on IO error
**/
CBCSOLVERLIB_EXPORT int CBC_LINKAGE
Cbc_writeBasis(Cbc_Model *model, const char *filename, char writeValues, int formatType);


/** @brief If Cbc was built with gzip compressed files support
*
* @return 1 if yes, 0 otherwise
Expand Down

0 comments on commit c4a885e

Please sign in to comment.