Quick update for those interested: I’ve wrapped up the first iteration on the original code. It exposes a couple of new derived-types and interfaces for solving (strictly) convex quadratic programs. Here is a simple example
program test_program
use QuadProg
implicit none
integer, parameter :: n = 3
! Size of the problem.
type(qp_problem) :: problem
type(OptimizeResult) :: result
real(dp) :: P(n, n), q(n), C(n, n), d(n)
! Qyadratic cost.
P = 0.0_dp; forall (i=1:n) P(i, i) = 1.0_dp
q = [0.0_dp, 5.0_dp, 0.0_dp]
! Inequality constraints
C(1, :) = [-4, -3, 0]
C(2, :) = [2, 1, 0]
C(3, :) = [0, -2, 1]
d = [-8, 2, 0]
problem = qp_problem(P, q, C=C, d=d)
result = solve(problem)
print *, "Success ?", result%success
print *, "Solution :", result%x
print *, "Lagrange multipliers :", result%y
print *, "Objective function :", result%obj
end program
You can also find a rudimentary model predictive control (MPC) example using a double integrator with bounded actuation signal in the example folder.