binary

Purpose

Constraints variable to be binary (0/1)

Syntax


Description

Adding this filter will constraint some (or all) elements of a given variable to take only binary values. To enable the filter, use model.signal.with('binary').

To impose binary on all elements of a given variable (say, model.u), use model.u.binary = true. To add binary only to elements indexed by idx, call model.u.binary = idx. To mark all elements of model.u as real variables, use model.u.binary = [].

To remove this filter, call model.signal.without('binary'), in which case all elements of signal will be considered as real-valued variables.

Example(s)

Example 1

Create a 1D LTI system ../../../../../fig/mpt/modules/ui/@SystemSignal/filter_binary1.png.
model = LTISystem('A', 0.9, 'B', 1);
Add constraints and penalties
		model.x.min = -4; model.x.max = 4;
		model.x.penalty = OneNormFunction(1);
		model.u.penalty = OneNormFunction(0.1);
	
Create an MPC controller with prediction horizon 3
M = MPCController(model, 3);
Constraint the control action to be binary and compute
		the open-loop optimizer for x0=-4
	
      
		M.model.u.with('binary'); 
		M.model.u.binary = true;
		[~, ~, openloop] = M.evaluate(-4);
		openloop.U
	
ans =

     1     1     0


© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk