% some random problem data
A = [eye(2); -eye(2)];
b = [1; 1; -0.5; -0.5];
u = 2;
c = [1; 1];
d = [1; 1];
% first we formulate the problem in YALMIP
% optimization variable
nx = size(A, 2);
x = sdpvar(nx, 1);
% parameter
theta = sdpvar(1, 1);
% objective function
J = (c + theta*d)'*x;
% constraints
C = [ A*x <= b, x >= 0, 0 <= theta <= u ];
% convert the parametric linear program to the MPT format
plp = Opt(C, J, theta, x);
% obtain the parametric solution
solution = plp.solve();
% plot the primal optimizer as a function of the parameter
for i = 1:nx
figure;
solution.xopt.fplot('primal', 'index', i);
xlabel('t');
ylabel(sprintf('x_%d(t)', i));
end
% plot the objective function
figure;
solution.xopt.fplot('obj');
xlabel('t');
ylabel('J(t)');
% evaluate the parametric solution for a particular value of the parameter
t0 = 0.5;
xopt = solution.xopt.feval(t0, 'primal')
Jopt = solution.xopt.feval(t0, 'obj')