Code Monkey home page Code Monkey logo

cppipm's Introduction

cppipm

C++ implementation of the Interior Point Method (CPPIPM)

Requirements

  • Eigen, "a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms". Eigen forms the linear algebra core of this software.

Compilation

  1. Compile the project using the qmake and the project file (cppipm) provided in the repo. This will require instllation of the qmake toolchain. The solver itself has NO dependency on Qt libraries.
  2. A simple way to compile and run the exmaple:
    cd examples
    g++ -std=c++14 -I ../lib/ -I ../include/   ../src/cppipm.cpp ../src/mpsReader.cpp test.cpp -o test
    ./test

How to use

QP:

  std::unique_ptr<Algorithm> test = std::make_unique<cppipm>(Q,A,b,c); test -> solve();

LP:

  std::unique_ptr<Algorithm> test = std::make_unique<cppipm>(Q,A,b,c);  test -> solve(); 

Or:

 std::unique_ptr<Algorithm> test = std::make_unique<cppipm>(otherProblem);  test -> solve();

Example

See test.cpp

TODO

This is a very old piece of work from my PhD time. As you can see my understanding of C++ at that time was not very upto the professional standard. ;) Will spend some time in the summer to refactor it.

  • Replace qmake project file with CMake
  • Refactor the code to comply with the SOLID principles at least
  • Setup continuous integration
  • Use c++11/14 features

Yiming Yan

cppipm's People

Contributors

yimingyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cppipm's Issues

Running examples/test.cpp

Hi,

I'm trying to use cppipm and as a starter I figured I'd run examples/test.cpp. I gitcloned this repo and tried to compile the C++ file as follows:

clang++ -I lib/ -I include/  examples/test.cpp

which produces the following error message:

Undefined symbols for architecture x86_64:
  "cppipm::cppipm(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&)", referenced from:
      _main in test-8cb9ec.o
  "cppipm::cppipm(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&)", referenced from:
      _main in test-8cb9ec.o
  "mpsReader::trans2standardForm(Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, 1, 0, -1, 1>&)", referenced from:
      _main in test-8cb9ec.o
  "mpsReader::mpsReader(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      _main in test-8cb9ec.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looks like (at least) this line is causing some grievance: Algorithm* qp_test = new cppipm(Q, A, b, c);

Additional information:

charlesm$ clang++ --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Am I using the wrong clang++ call? Same error with g++. Thank you for your help.

Quadratic Program Formulation

To be totally sure I'm using this correctly - could you please clarify how the (Q,A,b,c) formulation relates to the standard (H,f,Aeq,beq,Aineq,bineq) one?

min_x  1/2 H' x H + f' x
s.t.
A_eq x = b_eq
A_in x \leq b_ineq

Maybe an error in mpsReader::trans2standardForm

Line 82: cs.head(c.rows()) = c + 2Qlb;
It should be : cs.head(c.rows()) = c + Q*lb;

Here is an example 16.4 from Page 475 of (2nd edition), solution is correct while x1>=0 and x2>=0, solution is x1=1.4, x2=1.7,
But while set x1>=1 and x2>1 (see file EX164_1.QPS.txt) , solution is error.

EX164_0.QPS.txt
EX164_1.QPS.txt

For your information.

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.