source: trunk/Cbc/MSVisualStudio/v10/CbcWithInstalledLibraries/main.cpp @ 1989

Last change on this file since 1989 was 1989, checked in by tkr, 5 years ago

Adding project files for building a project linked to installed libraries

File size: 1.1 KB
Line 
1#include "OsiClpSolverInterface.hpp"
2#include "CbcModel.hpp"
3#include "CoinModel.hpp"
4
5#include <cstdio>
6
7int main() {
8  const int numcols = 2;
9  const int numrows = 1;
10  double obj[] = { 1.0, 1.0}; // obj: Max x0 + x1
11 
12  // Column-major sparse "A" matrix: x0 + 2 x1 <= 3.9
13  int start[] = {0, 1, 2};      // where in index columns start (?)
14  int index[] = {0, 0};         // row indexs for the columns
15  double values[] = {1.0, 2.0}; // the values in the sparse matrix
16  double rowlb[]  = {0.0};
17  double rowub[]  = {3.9};
18
19  //          0 <= x0 <= 10 and integer
20  //          0 <= x1 <= 10
21  double collb[] = {0.0, 0.0};
22  double colub[] = {10.0, 10.0};
23       
24  OsiClpSolverInterface model;
25  model.loadProblem(numcols, numrows, start, index, values, 
26                    collb, colub, obj, rowlb, rowub);
27  model.setInteger(0); // Sets x0 to integer
28  model.setObjSense(-1.0); // Maximise
29
30  CbcModel solver(model);
31  solver.branchAndBound();
32  bool optimal = solver.isProvenOptimal();
33  const double *val = solver.getColSolution();
34  printf("Solution %g %g\n", val[0], val[1]);
35
36  return 0;
37}
Note: See TracBrowser for help on using the repository browser.