Real time MPC For each MPC problem, we need to solve an optimization problem for each sampling. So MPC limited to applications with slow dynamics (sampling time in seconds or minutes). A well-known technique for implementing fast MPC is to compute the entire control law offline (explicit MPC), in which case the online controller can be implemented as a lookup table. The control action is then implemented online in the form of a lookup table. The major drawback here is that the number of entries in the table can grow exponentially with the horizon, state, and input dimensions, so that “explicit MPC” can only be applied reliably to small problems (where the state dimension is no more than around five). So this method is not applicable for more complex problems.
The new methods for fast MPC, develops by professor Boyd research group in Stanford university. These methods are based on combination of MPC with automatic code generation.
This report describe the capabilities and implementation of CVXGEN software package. CVXGEN takes a high level description of a convex optimization family, and automatically generate flat, library-free C code that can be compiled into high speed custom solver for the problem family
Problem statement energy storage system that can be charged or discharged from a source with varying energy price. A simple example is a battery connected to a power grid The goal is to alternate between charging and discharging in order to maximize the average revenue
Let first introduce problem variables and parameters:
the energy price at time t denote discourage excessive charging and discharging time horizon T=50
The easiest way to use this interface is via the ‘Matlab’ screen in CVXGEN's online interface, Go to the website “www.cvxgen.com” and create new project, then impose your project data’s to the blank spaces shown in windowwww.cvxgen.com
The second step is creating custom C codes for using in Matlab : Download and extract the ‘cvxgen.zip’ archive for your problem. This will create a subdirectory called CVXGEN. Inside the cvxgen/ folder in Matlab, call make_csolve. This will use the mex command to compile and build your custom solver and creates a csolve.mex* file.