Create expanding input for linprog optimization

조회 수: 7 (최근 30일)
Simon Funder
Simon Funder 2012년 3월 16일
Hi,
I'm trying code an expanding constraint limitation vector for a linprog optimization that has to be able to run for any number of stages.
Basically, what I need is a way to create the following input for each linprog loop:
Loop 1: B*x1
Loop 2: B*x2 - B*x1
Loop 3: B*x3 - B*x2 - B*x1
Loop... and so on.
x_n being the output(s) of the linprog from previous loop(s) and x1 the output from an initial linprog.
Any ideas?
Cheers, Simon

답변 (1개)

Simon Funder
Simon Funder 2012년 3월 16일
Ok, solved this myself, in case anyone's interested :)
for h=3:q
% Constraint limitation input
B_start = B*x_val(:,h-1);
for j=h-2:-1:1
B_add = add + B*x_val(:,j);
end
b_con = b(:,h)+B_add;
end
q being the number of stages - stage 1 and 2 are solved individually prior to the loop.
Simon

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by