Code Monkey home page Code Monkey logo

cplex-example's Introduction

Small CPLEX C++ API tutorial

Prerequisites

  • CPLEX must be installed, of course. Academics can obtain it via the IBM Academic Initiative.
  • You also need a modern version of GCC, that supports at least C++14.

Compile and run

  • Get the code: git clone https://github.com/alberto-santini/cplex-example.git.
  • Move to the new directory: cd cplex-example.
  • Create a build directory: mkdir build.
  • Move to the build directory: cd build.
  • Run cmake: cmake -DCPLEX_ROOT_DIR=</path/to/ilog> -DCMAKE_BUILD_TYPE=Debug ...
    • The path to your CPLEX installation must be such that </path/to/ilog>/cplex/include/ilcplex/cplex.h exists.
    • If your compiler is in a non-standard location, you can use -DCMAKE_CXX_COMPILER=</path/to/compiler>.
    • Change Debug into Release if you want to compile in release mode.
  • Run make: make.
  • Run the executable: ./cplex_example.

Structure

The Graph class (src/graph.h) is a minimal description of a graph; it only stores the number of nodes and the distance matrix. The graph is created randomly, with nodes lying on a plane and euclidean distances. The Solver class (src/solver.h) does all the CPLEX magic: it builds the model, it solves it, and it prints the solution.

License

The present work is distributed under the terms of ghe GNU General Public License v3 (see the LICENSE file).

cplex-example's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.