Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code #116

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
ignore = D203,E741,W503
max-complexity = 10
max-line-length = 160
80 changes: 38 additions & 42 deletions Dip/bugs/OsiCbc/main.cpp
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
//[magala@orclus71 OsiCbc]$ g++ main.cpp -L ../../../build-g/lib -I ../../../build-g/include/coin/ -lCbc -lOsi -lCbc -lCgl -lCoinUtils -lOsiCbc -lClp -lOsi -lCoinUtils -lCbcSolver -lCbc -lOsiClp -lClp -lCgl -lCoinUtils -lOsi

//[magala@orclus71 OsiCbc]$ g++ main.cpp -L ../../../build-g/lib -I
//../../../build-g/include/coin/ -lCbc -lOsi -lCbc -lCgl -lCoinUtils -lOsiCbc
//-lClp -lOsi -lCoinUtils -lCbcSolver -lCbc -lOsiClp -lClp -lCgl -lCoinUtils
//-lOsi

#include "OsiCbcSolverInterface.hpp"
#include <string>
using namespace std;

int main(int argc, char ** argv){
const int numCols = 2;
const int numNzs = 10;
const int numRows = 6;
bool isRowOrdered = false;
double objective [numCols] = {1,0};
int rowIndices [numNzs] = {0,0,1,2,2,3,3,4,5,5};
int colIndices [numNzs] = {0,1,1,0,1,0,1,1,0,1};
double elements [numNzs] = { 7.0, -1.0, 1.0, -1.0, 1.0,
-4.0, -1.0, -1.0, 0.2, -1.0};
CoinPackedMatrix M(isRowOrdered,
rowIndices, colIndices, elements, numNzs);
double rowLB[numRows] = {13.0, 1.0, -3.0, -27.0, -5.0, -4.0};
double rowUB[numRows] = {OsiCbcInfinity,
OsiCbcInfinity,
OsiCbcInfinity,
OsiCbcInfinity,
OsiCbcInfinity,
OsiCbcInfinity};
double colLB[numCols] = {0,0};
double colUB[numCols] = {6,6};
int integerVars[numCols] = {0,1};

OsiCbcSolverInterface osi;
osi.messageHandler()->setLogLevel(0);
osi.loadProblem(M, colLB, colUB, objective, rowLB, rowUB);
osi.setInteger(integerVars, 2);

osi.branchAndBound();
assert(!osi.isProvenPrimalInfeasible());
assert(osi.isProvenOptimal());
int main(int argc, char **argv) {
const int numCols = 2;
const int numNzs = 10;
const int numRows = 6;
bool isRowOrdered = false;
double objective[numCols] = {1, 0};
int rowIndices[numNzs] = {0, 0, 1, 2, 2, 3, 3, 4, 5, 5};
int colIndices[numNzs] = {0, 1, 1, 0, 1, 0, 1, 1, 0, 1};
double elements[numNzs] = {7.0, -1.0, 1.0, -1.0, 1.0,
-4.0, -1.0, -1.0, 0.2, -1.0};
CoinPackedMatrix M(isRowOrdered, rowIndices, colIndices, elements, numNzs);
double rowLB[numRows] = {13.0, 1.0, -3.0, -27.0, -5.0, -4.0};
double rowUB[numRows] = {OsiCbcInfinity, OsiCbcInfinity, OsiCbcInfinity,
OsiCbcInfinity, OsiCbcInfinity, OsiCbcInfinity};
double colLB[numCols] = {0, 0};
double colUB[numCols] = {6, 6};
int integerVars[numCols] = {0, 1};

OsiCbcSolverInterface osi;
osi.messageHandler()->setLogLevel(0);
osi.loadProblem(M, colLB, colUB, objective, rowLB, rowUB);
osi.setInteger(integerVars, 2);

//osi-cbc changes internal column bounds, must reset
double redCostX[numCols] = {1.34019,-0.10562};
osi.setColLower(colLB);
osi.setColUpper(colUB);
osi.setObjective(redCostX);
osi.writeMps("tmp");
osi.branchAndBound();
assert(!osi.isProvenPrimalInfeasible());
assert(osi.isProvenOptimal());
osi.branchAndBound();
assert(!osi.isProvenPrimalInfeasible());
assert(osi.isProvenOptimal());

// osi-cbc changes internal column bounds, must reset
double redCostX[numCols] = {1.34019, -0.10562};
osi.setColLower(colLB);
osi.setColUpper(colUB);
osi.setObjective(redCostX);
osi.writeMps("tmp");
osi.branchAndBound();
assert(!osi.isProvenPrimalInfeasible());
assert(osi.isProvenOptimal());
}
47 changes: 24 additions & 23 deletions Dip/bugs/main.cpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
// [magala@orclus71 bugs]$ g++ main.cpp -L ../../build-g/lib -I ../../build-g/incli -lClp -lCbc -lCoinUtils -lCgl -lOsi -lCbcSolver -lCbc -lCgl -lClp

// [magala@orclus71 bugs]$ g++ main.cpp -L ../../build-g/lib -I
// ../../build-g/incli -lClp -lCbc -lCoinUtils -lCgl -lOsi -lCbcSolver -lCbc
// -lCgl -lClp

#include "CbcSolver.hpp"
#include "OsiClpSolverInterface.hpp"
#include <string>
using namespace std;

int main(int argc, char ** argv){
string lpFile = argv[1];
int main(int argc, char **argv) {
string lpFile = argv[1];

OsiClpSolverInterface si;
si.readLp(lpFile.c_str());
OsiClpSolverInterface si;
si.readLp(lpFile.c_str());

CbcModel cbc(si);
CbcMain0(cbc);
CbcModel cbc(si);
CbcMain0(cbc);

const char * cbcArgv[20];
int cbcArgc = 0;
string cbcExe = "cbc";
string cbcSolve = "-solve";
string cbcQuit = "-quit";
string cbcLog = "-log";
string cbcLogSet = "3";
cbcArgv[cbcArgc++] = cbcExe.c_str();
cbcArgv[cbcArgc++] = cbcLog.c_str();
cbcArgv[cbcArgc++] = cbcLogSet.c_str();
cbcArgv[cbcArgc++] = cbcSolve.c_str();
cbcArgv[cbcArgc++] = cbcQuit.c_str();
CbcMain1(cbcArgc, cbcArgv, cbc);
printf("cbc.status() = %d\n", cbc.status());
printf("cbc.isProveOptimal() = %d\n", cbc.isProvenOptimal());
const char *cbcArgv[20];
int cbcArgc = 0;
string cbcExe = "cbc";
string cbcSolve = "-solve";
string cbcQuit = "-quit";
string cbcLog = "-log";
string cbcLogSet = "3";
cbcArgv[cbcArgc++] = cbcExe.c_str();
cbcArgv[cbcArgc++] = cbcLog.c_str();
cbcArgv[cbcArgc++] = cbcLogSet.c_str();
cbcArgv[cbcArgc++] = cbcSolve.c_str();
cbcArgv[cbcArgc++] = cbcQuit.c_str();
CbcMain1(cbcArgc, cbcArgv, cbc);
printf("cbc.status() = %d\n", cbc.status());
printf("cbc.isProveOptimal() = %d\n", cbc.isProvenOptimal());
}
Loading