Skip to content

jacquev6/QuadProgMm

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
doc
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

Introduction

QuadProgMm is a C++ library providing a domain specific language to express Quadratic programming problems as literal C++ equations on named variables.

These problems are generally specified using matrices and vectors, because it is the generic mathematical form used by resolution algorithms. This is sometime tedius, and QuadProgMm tries to fix that.

Note that QuadProgMm does not implement the arguably complex linear algebra algorithms for solving these problems and delegates all that hard work to QuadProg++, by Luca Di Gaspero.

It's licensed under the MIT license. Its documentation and its source code are on GitHub.

Questions? Remarks? Bugs? Want to contribute? Open an issue!

Quick start

Clone and build:

$ git clone https://github.com/jacquev6/QuadProgMm.git
$ cd QuadProgMm
$ make lib

Start with Includes:

#include <iostream>
#include <QuadProgMm.hpp>

using namespace QuadProgMm;

int main() {

Create variables:

Variable a, b, c;

And a quadratic expression to optimize:

QuadraticExpression q = a + b + (a - b) * (a - b) + c + (b - c) * (b - c);

And constraints:

std::vector<Constraint> constraints {
  a <= 1,
  c >= 4,
  a - 2 * b <= 12,
};

Finally, solve:

  Solution solution = minimize(q, constraints);

  std::cout << "a: " << solution.get(a) << std::endl;
  std::cout << "b: " << solution.get(b) << std::endl;
  std::cout << "c: " << solution.get(c) << std::endl;
  std::cout << "Cost: " << solution.getCost() << std::endl;
}

Build and run:

$ g++ -Ipath/to/QuadProgMm/src quick_start.cpp path/to/QuadProgMm/build/libquadprogmm.a path/to/QuadProgMm/QuadProgpp/src/libquadprog.a -o quick_start
$ ./quick_start

Result:

a: 1
b: 2
c: 4
Cost: 16

About

Specify QP problems as literal C++ equations on named variables

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published