Model-Based Calibration Toolbox 3.7
Using Constraints
This is a demonstration of creating and applying constraints to a design using Model-Based Calibration Toolbox™ command-line interface.
Contents
Create a Design
Create a Full Factorial design, because this will show the constraint boundaries as clearly as possible. Create the design from inputs. For simplicity, only 2 inputs (speed and load) are used.
inputs = mbcmodel.modelinput(... 'Symbol', {'N','L'},... 'Name', {'SPEED','LOAD'},... 'Range', {[500 6000],[0.0679 0.9502]}); design = CreateDesign( inputs, 'Type', 'Full Factorial' ); design = Generate( design, 'NumberOfLevels', [50 50] ); % design has a Constraints property, initially this is empty. constraints = design.Constraints
constraints = 0x0 array of mbcdoe.designconstraint
Create a Linear Constraint
cLinear = design.CreateConstraint( 'Type', 'Linear' ); cLinear.A = [-2.5e-4, 1]; cLinear.b = 0.25; cLinear design.Constraints = cLinear; design = Generate(design);
cLinear =
Linear design constraint: -0.00025*N + 1*L <= 0.25
Name: '-0.00025*N + 1*L <= 0.25'
NumberOfInputs: 2
Inputs: [2x1 mbcmodel.modelinput]
Type: 'Linear'
A: [-2.5000e-004 1]
b: 0.2500
Show Constraint
Plot the points to show the linear constraint.
Scatter2D(design, 1, 2);
title( 'Linear Constraint' );
Create a 1D Table Constraint
cTable1d = design.CreateConstraint( 'Type', '1D Table' ); cTable1d.Table = [0.9 0.5]; cTable1d.Breakpoints = [500 6000]; cTable1d design.Constraints = cTable1d; design = Generate(design);
cTable1d =
1D Table design constraint: L(N) <= Lmax
Name: 'L(N) <= Lmax'
NumberOfInputs: 2
Inputs: [2x1 mbcmodel.modelinput]
Type: '1D Table'
Table: [0.9000 0.5000]
Breakpoints: [500 6000]
Inequality: '<='
InputFactor: 'N'
TableFactor: 'L'
Show Constraint
Plot the points to show the 1D Table constraint.
Scatter2D( design, 1, 2 );
title( '1D Table Constraint ' );
Combining Constraints
Constraints is an array of the constraints to apply.
design.Constraints = [cLinear, cTable1d]; constraints = design.Constraints design = Generate(design);
constraints = 1x2 array of mbcdoe.designconstraint Linear design constraint: -0.00025*N + 1*L <= 0.25 1D Table design constraint: L(N) <= Lmax
Show Constraint
Plot the points to show both constraints.
Scatter2D( design, 1, 2 );
title( 'Linear and 1D Table Constraint ' );
Store