muAO-MPC document is given clear idea of usage, but still some more insights are given below . Here strictly follow the version of each software package mentioned.
steps to do -
0) Download the muAO MPC package version1.0.0-alpha-20160805.
1) Install anaconda2.
2) check versions of following python packages on anaconda 2 prompt CLI interface. (keep it open we require this further till end)
Find python version using command: >>python --version
Find the versions of other packages : >>pip list
Find the specific package version: >>print numpy.__version__
3) Numpy-1.6.2, 1.10.4. It basically manages the linear algebra operations, and some extra features are used. if not present use command: >>pip install numpy-1.10.4
4) SciPy, tested with versions 0.10. It is used for some tiny features are used. if not present use command: >>pip install scipy-0.10
5) PyParsing, tested with versions 2.1.4. It is used for parsing the problem. If not present use command: >>pip install pyparsing-2.1.4
6) Cython to compile the Python interface to the generated C-code. If not present use command: >>pip install cython
7) A C89/C90 compiler. To compile the generated code, a C/C++ compiler that supports C89/C90 or later standards is required. - for this install MinGW , visual studio and Microsoft build tools.
8) Install MinGW. - add the environment path - mingw/mingw32/lib; mingw/mingw32/bin
8) Install Microsoft Visual Studio and also microsoft build tools any version - then add path in the system variable - Microsoft visual studio/ 2019/build/vc/auxilary/build.
command: SET VS90COMNTOOLS=%VS140COMNTOOLS% (to avoid the error: error: Unable to find vcvarsall.bat)
9) On anaconda2 prompt type command: python setup.py install --force
10) Now the the muAO MPC ready to use.
11) Go to location : muAO-MPC-1.0.0-alpha-20160805\examples\ldt\tutorial
12) See the file created there names as: mydat.dat, and myprb.prb
13) Run command on python script : >>python main.py
14) Check the folder created with name myprb_mpc.
15) Move to location: muAO-MPC-1.0.0-alpha-20160805\examples\ldt\tutorial\myprb_mpc\src\matlab
16) On matlab console run: >>mpcmake.
17) Come to location : muAO-MPC-1.0.0-alpha-20160805\examples\ldt\tutorial and enter the commane on MATLAB console:
>>addpath matlab;
>>ctl = mpcctl('myprb_mpc/data/mydat/mpcmydat.json');
>>ctl.conf.in_iter = 10;
>>ctl.parameters.x_bar = [0.1; -0.5];
>>ctl.solve_problem();
even after this the error will persist but don't worry the code will be generated. that is because of the c compiler in not properly installed on python but if we are using the Matlab interface no need to worry about this error.
Some Required software packages websites to use muAO MPC -
1) muAO MPC source code. : muAO-MPC Documentation (PDF)
1) MingGW : http://www.mingw.org/wiki/InstallationHOWTOforMinGW,
https://www.rose-hulman.edu/class/csse/resources/MinGW/installation.htm
1) Install the muAOMPC module as given above.
2) Copy muaompc folder into your working folder.
3) Configure your problem in .m file with all specified data ans save .mat file
4) Write python code for generation of the mpc structure and c code generation of the same. ans save code with name main.py
5) on anaconda prompt go to your folder location and run command >>python main.py
6) check the cmpc folder generated inside the folder
7) Open Matlab browse to folder inside cmpc/matlab/ and on matlab command prompt run make.m file
with this your matlab interface is ready for working.
8) Matlab and Simulink both interfaces are ready - mex version required for Matlab interfacing, and s function required for Simulink interfacing.
9) Generated C code want to access then the respective library data structure explained here in mpctool
10) Take care about type cast of real_t whenever passing the values to mpctool structures or functions.
1) Once the c code generated then you can see Simulink S-builder already available inside cmpc/simulink folder.
2) Copy that s-builder outside of the cmpc function (as if in any case c code generation executed once again ti will rpelace the cmpc folder)
3) Now also copy all the files from folder cmpc/include outside of cpmc.
4) open the s-buider in simulink.
5) Double clock on s-builder and check the boxes as given below
i. Initialization number of discrete states put as 1, discrete state ICs as 1, number of continuous state as 0, Continuous states ICs as 0
ii Data properties : define inputs output and parameter as per requirement and strictly data type attributes for input and outputs defined as double.
iii. Output: inside this box put your c code logic for execution.
6) Give s-function name and select language.
7) finally press build in the same dialog box and wait for successful Compilation.
8) Now s-builder ready for use in simulink.
reference images are given below: