Code Monkey home page Code Monkey logo

parnmpc's Introduction

ParNMPC Version 1903-1

New Features in Version 1903-1:

  • Primal-dual interior-point method
  • Improved user interface
  • Better performance
  • Line search

Introduction

Homepage: https://deng-haoyang.github.io/ParNMPC/

ParNMPC is a MATLAB real-time optimization toolkit for nonlinear model predictive control (NMPC). The purpose of ParNMPC is to provide an easy-to-use environment for NMPC problem formulation, closed-loop simulation, and deployment.

With ParNMPC, you can define your own NMPC problem in a very easy way and ParNMPC will automatically generate self-contained C/C++ code for single- or multi-core CPUs.

ParNMPC is very fast even with only one core (the computation time is usually in the range of $\mu$s), and a high speedup can be achieved when parallel computing is enabled.

Highlights

  • Symbolic problem representation
  • Automatic parallel C/C++ code generation with OpenMP
  • Fast rate of convergence (up to be superlinear)
  • Highly parallelizable (capable of using at most N cores, N is the # of discretization steps)
  • High speedup ratio
  • MATLAB & Simulink

Installation

  1. Clone or download ParNMPC.
  2. Extract the downloaded file.

Requirements

  • MATLAB 2016a or later
  • MATLAB Coder
  • MATLAB Optimization Toolbox
  • MATLAB Parallel Computing Toolbox
  • MATLAB Symbolic Math Toolbox
  • Simulink Coder
  • C/C++ compiler supporting parallel code generation

Getting Started (MATLAB 2018b)

  1. Select the Microsoft Visual C++ 2017 (C) compiler:
>> mex -setup
  1. Navigate to the Quadrotor/ folder.
>> cd  Quadrotor/
  1. Open NMPC_Problem_Formulation.m and run.

  2. Open Simu_Simulink_Setup.m and run.

  3. Open Simu_Simulink.slx and run.

Citing ParNMPC

Citing the parallel algorithm:

@article{deng2019parallel,
  title={A parallel Newton-type method for nonlinear model predictive control},
  author={Deng, Haoyang and Ohtsuka, Toshiyuki},
  journal={Automatica},
  volume={109},
  pages={108560},
  year={2019}}

Citing the toolbox (conference version):

@inproceedings{deng2018parallel,
  title={A parallel code generation toolkit for nonlinear model predictive control},
  author={Deng, Haoyang and Ohtsuka, Toshiyuki},
  booktitle={Proceedings of the 57th {IEEE} {C}onference on {D}ecision and {C}ontrol},
  pages={4920--4926},
  year={2018},
  address={Miami, USA}}

License

ParNMPC is distributed under the BSD 2-Clause "Simplified" License.

parnmpc's People

Contributors

deng-haoyang avatar ideadeng 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parnmpc's Issues

Supporting for inequality constraint

Version 1806-1 doesn't support inequality constraints explicitly. However, the method of barrier function requires careful tuning and are not user-friendly.

Functions to deal with inequalities will be included in a future release.

Active-set method support

Interior-point method is good for large-scale problems, however, it is not easy to warm start and its barrier parameter is usually set as a constant, and thus only sub-optimal solution is be obtained.

The future version of ParNMPC will support active-set method to deal with constraints.

Unix-style vs Windows-style paths

When running the Quadrotor example, I get following error:

??? OCP_F_Fu_Fx.c specified in custom source files string does not
exist in any of the following search directories:
"/Users/robin/ParNMPC/Quadrotor/.\codegen\lib\OCP_F_Fu_Fx"
"/Users/robin/ParNMPC/Quadrotor"

Code generation failed: View Error Report
Error using codegen

Error in OptimalControlProblem/codeGen (line 123)
    codegen -config cfg_OCP_KKTs...

Error in NMPC_Problem_Formulation (line 53)
    OCP.codeGen();

Error in run (line 91)
    evalin('caller', strcat(script, ';'));

Works if I replace the .\codegen\... path with codegen/lib/....

Failed to load custom code simulation

Dear Deng,
I have tried the Quadcopte example, but the simulink file at the last step didnt run.
I t gives me this error:

Failed to load custom code simulation
library:D:\Users\sanim\Documents\MATLAB\MPC\ParNMPC\Quadrotor\slprj_slcc\oSDpra6UYTzTcubJVwU2TH\oSDpra6UYTzTcubJVwU2TH_cclib.dll
Component:Simulink | Category:Model error

Gauss-Newton Method

Current version of ParNMPC requires the second derivatives of the dynamics, which is impratical for systems with complex dynamics.

TODO: Parallel Gauss-Newton method

confiction with "ss" function provided by the control system toolbox

When I use the function "ss" to create linear state space model after directory ParNMPC with the subfolders included into matlab path, the following error arised:
错误使用 ss
如果类定义了超类,则所有超类必须均为句柄类,或者所有超类均不为句柄类。

In English, which means when the class defined with superclass, then all of the superclasses must be handle class ,or none of them is handle class.

After excluded ParNMPC, the error disappeared.

So, I think the function "ss" maybe conflict with ParNMPC. I have searched the ParNMPC for the keyword "ss", but no result found.
@ideaDeng would you like to find which lines introudce this confliction and fix it.

Failed to run manipulator example

Hi developer,
I got the following error after running the script Simu_Matlab.m

>> Simu_Matlab
Error using f_fu_fx_Wrapper (line 7)
Output argument "dx" (and possibly others) not assigned a value in the execution with
"f_Wrapper" function.

Error in OCP_GEN_fdt_fudt_fxdt (line 2)
   [f,fu,fx] = f_fu_fx_Wrapper(u,x,p,parIdx);

Error in OCP_F_Fu_Fx (line 57)
                [fdt,fudt,fxdt] = OCP_GEN_fdt_fudt_fxdt(u,x,p,parIdx);

Error in coarse_update_func (line 58)
            [F_j_i,Fu_j_i,Fx_j_i] = OCP_F_Fu_Fx(u_j_i,x_j_i,p_j_i,discretizationMethod,isMEnabled,i);

Error in NMPC_Solve_SearchDirection (line 64)
    parfor (i=1:DoP,numThreads)

Error in NMPC_Solve (line 76)
            NMPC_Solve_SearchDirection(x0,pSplit,rho,lambdaSplit,muSplit,uSplit,xSplit,zSplit,LAMBDASplit);

Error in Simu_Matlab (line 73)
    [solution,output] = NMPC_Solve(x0Measured,p,options);

The matlab version I am using is 2021b. And I did not find any other script that can generate the figure in the README file.

macOS Compilation

Hi Deng,

I am using ParNMPC on MATLAB 2018a and macOS High Sierra 10.13.6. While code generation I am getting an error.

`1 error generated.
gmake: *** [NMPC_Iter.o] Error 1

Error(s) encountered while building "NMPC_Iter":

Failed to generate all binary outputs.


??? Build error: C compiler produced errors. See the Build Log for further details.

Code generation failed: View Error Report
Error using codegen

Error in NMPC_Iter_CodeGen (line 83)
codegen -config cfg ...

Error in Simu_Simulink_Setup (line 31)
NMPC_Iter_CodeGen('dll','C',DoP);
`
How to generate dylib insted of dll?

Thank you.

Error NMPC Problem Formulation

Hello,
First, thank you for share with us your work.
I was trying to run the first example but I got the following error

NMPC_Problem_Formulation
Error using sym/vertcat (line 17)
Error using maplemex
Error, (in ArrayTools:-Concatenate) number of columns must match

Error in DynamicSystem/setf (line 5)
obj.f = symfun(f,[obj.u;obj.x;obj.p]);

Error in OptimalControlProblem/setf (line 2)
setf@DynamicSystem(OCP,f);

Error in NMPC_Problem_Formulation (line 33)
OCP.setf(f);

I hope you can help with this.
Best regards,
Julio

Update CMakeLists.txt for pinocchio

Now the CMake packaging for pinocchio is updated and improved.
I think it is nice to fix CMakeLists.txt in RobotManipulator example.
I've done it in my branch, so I'd like to merge the change into this master branch if @deng-haoyang allows it.

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.