Nonlinear Control Design Blockset    

Problem Formulation Details

The constraint bounds displayed in the Nonlinear Control Design Blockset constraint window are for visualization purposes only. Two matrices, ncdStruct.CnstrLB and ncdStruct.CnstrUB, contain all the constraint information. See the next section for more information about how ncdStruct.CnstrLB and ncdStruct.CnstrUB store constraint data and for a summary of other fields of the global variable ncdStruct defined by the Nonlinear Control Design Blockset. For now, it is enough to know that each constraint bound matrix consists of groups of weighted line segment data for each output constrained.

When the optimization is started, the Nonlinear Control Design Blockset invokes the routine nlinopt. Generation of the optimization problem involves three steps:

  1. Processing uncertainty data
  2. Expanding the constraint matrices ncdStruct.CnstrLB and ncdStruct.CnstrUB.
  3. Invoking the constrained optimization routine constr

The Nonlinear Control Design Blockset routine montevar processes uncertainty data input to the Uncertain Variables dialog box. It generates Monte Carlo plant data and performs certain error checks. The routine produces the Monte Carlo plants assuming a uniformly distributed probability density between the lower and upper bounds entered into the Uncertain Variables dialog box.

The Nonlinear Control Design Blockset routine convertm expands the constraint matrices, ncdStruct.CnstrLB and ncdStruct.CnstrUB, using the discretization interval Td = ncdStruct.Tdelta. Generally speaking, constraints are generated at an interval of Td, per constraint segment per constrained signal.

After more error checking, nlinopt vectorizes the tunable variables and invokes the constrained optimization routine constr. Specifically, if you input V1 V2... as tunable variables into the Optimization Parameters dialog box, the Nonlinear Control Design Blockset passes the vector x = [V1(:); V2(:); ... gamma] to constr. By calling constr with a special option flag, it expects gamma to contain the value of the cost function. The Nonlinear Control Design Blockset problem formulation defines the cost function as the (weighted) maximum constraint violation. The constr routine perturbs each tunable variable in turn and evaluates the resulting cost function and constraint equations. After determining a gradient (search direction) from this information, constr performs a line search along the gradient in an attempt to simultaneously minimize the cost while satisfying constraint equations.

The Nonlinear Control Design Blockset routine costfun returns the cost function and constraints. As mentioned above, costfun calculates the cost function

which corresponds to the (weighted) maximum constraint violation. The routine then initializes the constraint vector to the empty matrix and recovers (defines) the tunable variables from the vector x described above. Next, it initiates a for loop according to the number of plants constrained, Npc. Specifically, Npc is the number of Monte Carlo simulations to be constrained plus the nominal, upper bound, and lower bound plant if they are constrained.

Within each for loop, costfun assigns the uncertain plant variables (as defined by the routine montevar) and calls for a simulation. It next linearly interpolates the simulation output to the time basis Tstart:Td:Tstop using the table1 command. If necessary, it updates the plots of any open Nonlinear Control Design Blockset constraint figures. Finally, it augments the constraint vector.

To describe the constraint vector in detail, we define

Yout
a length(Tstart:Td:Tfinal) by p matrix corresponding to the linearly interpolated simulation output (i.e., the Simulink system has p NCD-masked Outport blocks)

Then convertm defines Mu and Ml, which have three columns described by

Ml
[AbsoluteYoutIndex Bound Weight]
Mu
[AbsoluteYoutIndex Bound Weight]

Given this, each pass through the for loop augments the constraint vector, ConstraintError, as

which implies that the system response should be less than upper bound constraints and greater than lower bound constraints.

The following pseudocode summarizes the optimization.

Notice that the number of simulations conducted at each iteration is given by

where Ntp is the total number of elements in the tunable parameters and Npc is the number of plants constrained as defined above. The extra term O(1) arises due to the line search, which is discussed in the next section. The term O(1) does not depend on either Ntp or Npc and is typically one. To decrease your optimization time, you should constrain as few plants and tune as few variables as possible. For example, when you optimize with uncertainty, try constraining only the upper and lower bound plant (i.e., do not constrain the nominal plant or any Monte Carlo generated plants). Once the optimization has completed, inspect the nominal plant response and a number of Monte Carlo plant responses by checking the appropriate boxes in the Uncertain Variables dialog box and selecting Initial response from the Options menu.

Each constrained output generates approximately
2*Npc*floor((Tstop-Tstart)/Td) constraints, where Npc equals the number of plants constrained, Tstop is the simulation stop time, Tstart is the simulation start time, and Td is the discretization interval. More specifically, each constraint bound segment defined between time T1 and T2 (T2>T1) generates exactly floor((T2-T1)/Td) constraints for each plant constrained. Since the optimization routine generates a square matrix of the same size as the number of constraints, care must be taken not to generate too many constraints for risk of encountering memory problems. Choosing a discretization interval of between 1 and 2 percent of the total simulation time should keep you safe from Out of memory errors while at the same time generating enough constraints to satisfactorily approximate the continuous time constraint bounds of the constraint figures.


  Optimization Details Optimization Algorithmic Details