Skip to content

Commit 5649110

Browse files
darnstromDon-Chris
andauthored
Version 0.6.0 (#55)
* Fix fval bound and activate equality constraints in setup_ldp (#46) * Make fval_bound consistent with internal objective function * Activate equality constraints inside update_ldp * Update CI * Fix python interface when blower and sense are not given (#47) * Add function to remove redundant constraints in polyhedron (#48) * Add minrep to Python interface (#49) * Set target_include_directories and modify Cmake export (#53) * Set target_include_directories * Simulink Interface (#42) * Correctly generate code for RinvD * Do not explicitly store v and scaling in generated code --------- Co-authored-by: Christopher Schulte <38617646+Don-Chris@users.noreply.github.com>
1 parent 3d6dffc commit 5649110

26 files changed

Lines changed: 2680 additions & 34 deletions

.github/workflows/aarch64_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
python -m pip install --upgrade twine
5656
twine upload wheelhouse/*
5757
- name: Upload artifacts to github
58-
uses: actions/upload-artifact@v1
58+
uses: actions/upload-artifact@v4
5959
with:
6060
name: wheels
6161
path: interfaces/daqp-python/wheelhouse

.github/workflows/arm64_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
python -m pip install --upgrade twine
5353
twine upload wheelhouse/*
5454
- name: Upload artifacts to github
55-
uses: actions/upload-artifact@v1
55+
uses: actions/upload-artifact@v4
5656
with:
5757
name: wheels
5858
path: interfaces/daqp-python/wheelhouse

.github/workflows/ci_python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
build:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-22.04
1515
strategy:
1616
matrix:
1717
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ jobs:
4545

4646
steps:
4747
- name: Check out repository
48-
uses: actions/checkout@v2
48+
uses: actions/checkout@v4
4949

5050
- name: Install MATLAB
51-
uses: matlab-actions/setup-matlab@v1
51+
uses: matlab-actions/setup-matlab@v2
5252

5353
- name: Build and package MATLAB interface
54-
uses: matlab-actions/run-command@v1
54+
uses: matlab-actions/run-command@v2
5555
with:
5656
command: cd interfaces/daqp-matlab, make_daqp, make_daqp('package')
5757

.github/workflows/wheels.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
python -m pip install --upgrade twine
6161
twine upload wheelhouse/*
6262
- name: Upload artifacts to github
63-
uses: actions/upload-artifact@v1
63+
uses: actions/upload-artifact@v4
6464
with:
65-
name: wheels
66-
path: interfaces/daqp-python/wheelhouse
65+
name: wheels-${{ matrix.os }}-${{ strategy.job-index }}
66+
path: interfaces/daqp-python/wheelhouse/*.whl

CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.10)
2-
project(daqp VERSION 0.5.0)
2+
project(daqp VERSION 0.6.0)
33

44
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
55
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/codegen)
@@ -18,7 +18,16 @@ if(SOFT_WEIGHTS)
1818
endif()
1919

2020
add_library(daqpstat STATIC ${daqp_src} ${daqp_headers} ${daqp_codegen_src} ${daqp_codegen_headers})
21+
target_include_directories(daqpstat PUBLIC
22+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
23+
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>
24+
)
25+
2126
add_library(daqp SHARED ${daqp_src} ${daqp_headers} ${daqp_codegen_src} ${daqp_codegen_headers})
27+
target_include_directories(daqp PUBLIC
28+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
29+
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>
30+
)
2231

2332
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2433
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}") # math for C api
@@ -28,17 +37,17 @@ target_link_libraries(daqpstat daqp)
2837

2938
# Install
3039
include(GNUInstallDirs)
31-
install(TARGETS daqpstat EXPORT ${PROJECT_NAME}
40+
install(TARGETS daqpstat EXPORT ${PROJECT_NAME}Config
3241
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
3342
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
3443
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
35-
install(TARGETS daqp EXPORT ${PROJECT_NAME}
44+
install(TARGETS daqp EXPORT ${PROJECT_NAME}Config
3645
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
3746
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
3847
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
3948
install(FILES ${daqp_headers} ${daqp_codegen_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/daqp")
4049

41-
install(EXPORT ${PROJECT_NAME} DESTINATION cmake)
50+
install(EXPORT ${PROJECT_NAME}Config DESTINATION cmake)
4251

4352
if(MATLAB)
4453
find_package(Matlab)

codegen/codegen.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ void write_daqp_workspace_h(FILE *f, DAQPWorkspace* work){
9494
fprintf(f, "extern c_float dupper[%d];\n", m);
9595
fprintf(f, "extern c_float dlower[%d];\n", m);
9696
fprintf(f, "extern c_float Rinv[%d];\n", n*(n+1)/2);
97-
fprintf(f, "extern c_float v[%d];\n", n);
97+
//fprintf(f, "extern c_float v[%d];\n", n);
9898
fprintf(f, "extern int sense[%d];\n\n", m);
99-
fprintf(f, "extern c_float scaling[%d];\n\n", m);
99+
//fprintf(f, "extern c_float scaling[%d];\n\n", m);
100100

101101
fprintf(f, "extern c_float x[%d];\n", n+1);
102102
fprintf(f, "extern c_float xold[%d];\n\n", n+1);
@@ -134,7 +134,7 @@ void write_daqp_workspace_src(FILE* f, DAQPWorkspace* work){
134134
write_float_array(f,work->Rinv,n*(n+1)/2,"Rinv");
135135
//write_float_array(f,work->v,n, "v");
136136
write_int_array(f,work->sense, m,"sense");
137-
write_float_array(f,work->scaling, m,"scaling");
137+
//write_float_array(f,work->scaling, m,"scaling");
138138

139139
// Iteratates
140140
fprintf(f, "c_float x[%d];\n", n+1);
@@ -155,8 +155,9 @@ void write_daqp_workspace_src(FILE* f, DAQPWorkspace* work){
155155
fprintf(f, "DAQPWorkspace daqp_work= {\n");
156156
fprintf(f, "NULL,\n"); // DAQPProblem
157157
fprintf(f, "%d, %d, %d,\n",n,m,ms); // dimensions
158-
fprintf(f, "M, dupper, dlower, Rinv, NULL, NULL, sense,\n"); //LDP
159-
fprintf(f, "scaling,\n"); // scaling
158+
fprintf(f, "M, dupper, dlower, Rinv, NULL, sense,\n"); //LDP
159+
fprintf(f, "NULL,\n"); // scaling
160+
fprintf(f, "NULL,\n"); // RinvD
160161
fprintf(f, "x, xold,\n");
161162
fprintf(f, "lam, lam_star, u, %d,\n",-1); // fval
162163
fprintf(f, "L, D, xldl,zldl,%d,\n",0); // reuse_ind

docs/docs/install.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,12 @@ In the REPL run the command
5656
```shell
5757
pip install daqp
5858
```
59+
60+
## Installing the Simulink interface
61+
The Simulink interface can be installed directly by running the following commands in MATLAB in the directory where you want to store interface:
62+
```shell
63+
websave('daqp.tar.gz','https://github.com/darnstrom/daqp/archive/refs/heads/master.tar.gz')
64+
untar('daqp.tar.gz')
65+
cd(fullfile('daqp-master','interfaces','daqp-simulink'))
66+
make_sfunc
67+
```

docs/docs/simulink.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
layout: page
3+
title: Simulink
4+
permalink: /start/simulink
5+
nav: 3
6+
parent: Interfaces
7+
grand_parent: Getting started
8+
math: mathjax3
9+
---
10+
11+
12+
## Setting up the problem
13+
14+
In Simulink, an s-function block can be used to solve a quadratic program. The s-function needs to link to the compiled c-code called "daqp_sfunc". To compile the c-code, the following matlab-script can be used in the terminal:
15+
16+
```matlab
17+
make_sfunc()
18+
```
19+
20+
_Note_: Please make sure to have a C-compiler installed on your system and linked in matlab. This can be checked by running ``mex -setup`` in the terminal:
21+
22+
After the c-code has been compiled, a new file called ``daqp_sfunc.mexw64`` (windows) or ``daqp_sfunc.mexa64`` (linux, mac) should be found.
23+
24+
The corresponding S-function block has the following inputs:
25+
| Inputs | Description | Size |
26+
| --- | --- | --- |
27+
| $H$ | The Hessian matrix of the quadratic objective function | [$n$ x $n$] |
28+
| $f$ | The linear part of the objective function | [$n$ x 1]
29+
| $A$ | The matrix of linear constraints | [$m_g$ x $n$]
30+
| $b_l$ | The lower bound of the linear constraints | [$m$ x 1]
31+
| $b_u$ | The upper bound of the linear constraints | [$m$ x 1]
32+
| sense | The type of the constraints | [$m$ x 1]
33+
34+
_Note_: When $b_u$ and $b_l$ have more elements than the number of rows in $A$, the first elements in $b_u$ and $b_l$ are interpreted as simple bounds.
35+
36+
The following parameters are used to set up the problem and need to be set in the mask of the s-function block:
37+
38+
| Parameters | Description | Size |
39+
| --- | --- | --- |
40+
| maxIter | Maximum number of iterations | 1 |
41+
42+
The block has the following outputs:
43+
44+
| Outputs | Description | Size |
45+
| --- | --- | --- |
46+
| $x$ | The optimal solution | [$n$ x 1] |
47+
| $\lambda$ | The optimal Lagrange multipliers | [$m$ x 1] |
48+
| $f_{val}$ | The optimal value of the objective function | 1 |
49+
| exitflag | The exit flag of the solver | 1 |
50+
| iter | The number of iterations used by the solver | 1 |

include/api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ void free_daqp_bnb(DAQPWorkspace* work);
3838

3939
void daqp_extract_result(DAQPResult* res, DAQPWorkspace* work);
4040
void daqp_default_settings(DAQPSettings *settings);
41+
void daqp_minrep(int* is_redundant, c_float* A, c_float* b, int n, int m, int ms);
4142

4243
# ifdef __cplusplus
4344
}

0 commit comments

Comments
 (0)