Skip to content

Commit

Permalink
(#3962) qpoases/3.2.1
Browse files Browse the repository at this point in the history
* qpoases/3.2.1

* comments

* Update recipes/qpoases/all/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* no more glob

* remove shared as option

* Apply suggestions from code review

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* Update recipes/qpoases/all/test_package/CMakeLists.txt

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* c++ std 11 and fixed name of bin

Co-authored-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 5, 2021
1 parent 9b5f7eb commit 8cbc1ce
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 0 deletions.
7 changes: 7 additions & 0 deletions recipes/qpoases/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/qpoases/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"3.2.1":
url: "https://github.com/coin-or/qpOASES/archive/releases/3.2.1.tar.gz"
sha256: "a7d153b4e23ee66bd50cdb6e84291d0084d9967a9c788a4d873440a6b10ca13b"
59 changes: 59 additions & 0 deletions recipes/qpoases/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import os
from conans import ConanFile, CMake, tools


class ConanRecipe(ConanFile):
name = "qpoases"

description = "Open-source C++ implementation of the recently proposed online active set strategy."
topics = ("conan", "container", "parametric", "quadratic", "programming")

homepage = "https://github.com/coin-or/qpOASES"
url = "https://github.com/conan-io/conan-center-index"

license = "LGPL-2.1"

exports_sources = ["CMakeLists.txt"]
generators = "cmake"

settings = "os", "arch", "compiler", "build_type"
options = {"fPIC": [True, False]}
default_options = {"fPIC": True}

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "qpOASES-releases-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["QPOASES_BUILD_EXAMPLES"] = False
self._cmake.configure()
return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "qpOASES"
self.cpp_info.names["cmake_find_package_multi"] = "qpOASES"

self.cpp_info.libs = tools.collect_libs(self)
13 changes: 13 additions & 0 deletions recipes/qpoases/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

set(CMAKE_CXX_STANDARD 11)

include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup(TARGETS)

find_package(qpOASES REQUIRED)

add_executable(test_package test_package.cpp)

target_link_libraries(test_package PRIVATE qpOASES::qpOASES)
17 changes: 17 additions & 0 deletions recipes/qpoases/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
62 changes: 62 additions & 0 deletions recipes/qpoases/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// from: https://github.com/coin-or/qpOASES/blob/master/examples/example1.cpp

#include <qpOASES.hpp>


/** Example for qpOASES main function using the QProblem class. */
int main( )
{
USING_NAMESPACE_QPOASES

/* Setup data of first QP. */
real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 };
real_t A[1*2] = { 1.0, 1.0 };
real_t g[2] = { 1.5, 1.0 };
real_t lb[2] = { 0.5, -2.0 };
real_t ub[2] = { 5.0, 2.0 };
real_t lbA[1] = { -1.0 };
real_t ubA[1] = { 2.0 };

/* Setup data of second QP. */
real_t g_new[2] = { 1.0, 1.5 };
real_t lb_new[2] = { 0.0, -1.0 };
real_t ub_new[2] = { 5.0, -0.5 };
real_t lbA_new[1] = { -2.0 };
real_t ubA_new[1] = { 1.0 };


/* Setting up QProblem object. */
QProblem example( 2,1 );

Options options;
example.setOptions( options );

/* Solve first QP. */
int_t nWSR = 10;
example.init( H,g,A,lb,ub,lbA,ubA, nWSR );

/* Get and print solution of first QP. */
real_t xOpt[2];
real_t yOpt[2+1];
example.getPrimalSolution( xOpt );
example.getDualSolution( yOpt );
printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n",
xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2],example.getObjVal() );

/* Solve second QP. */
nWSR = 10;
example.hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, nWSR );

/* Get and print solution of second QP. */
example.getPrimalSolution( xOpt );
example.getDualSolution( yOpt );
printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n",
xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2],example.getObjVal() );

example.printOptions();
/*example.printProperties();*/

/*getGlobalMessageHandler()->listAllMessages();*/

return 0;
}
3 changes: 3 additions & 0 deletions recipes/qpoases/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"3.2.1":
folder: all

0 comments on commit 8cbc1ce

Please sign in to comment.