实验目的:
Lingo实现层次算法、Matlab用线性规划包解目标规划问题
实验要求:
报告内容:
Lingo实现:
代码:
model:
sets:
level/1..3/:p,z,goal;
variable/1..2/:x;
h_con_num/1..2/:b;
s_con_num/1..4/:g,dplus,dminus;
h_con(h_con_num,variable):a;
s_con(s_con_num,variable):c;
obj(level,s_con_num)/1 1,2 2,3 3,3 4/:wplus,wminus;
endsets
data:
ctr=?;
goal=? ? 0;
b=16
12;
g=12 0 12 8;
a=4 0
0 4;
c=2 3 1 -1 2 2 1 2;
wplus=0 1 3 1;
wminus=1 1 3 0;
enddata
min=@sum(level:p*z);
p(ctr)=1;
@for(level(i)|i#ne#ctr:p(i)=0);
@for(level(i):z(i)=@sum(obj(i,j):wplus(i,j)*dplus(j)+wminus(i,j)*
dminus(j)));
@for(h_con_num(i):@sum(variable(j):a(i,j)*x(j))<b(i));
@for(s_con_num(i):@sum(variable(j):c(i,j)*x(j))+dminus(i)-dplus(i
)=g(i));
@for(level(i)|i #lt# @size(level):@bnd(0,z(i),goal(i)));
end
- 输入Cr=1,goal(1)=100000,goal(2)=10000,得到一级优化目标d1-=0
- 输入Cr=1,goal(1)=0,goal(2)=10000,得到二级优化目标d2+,d2-=0
- 输入Cr=3,goal(1)=0,goal(2)=0,得到三级优化目标d1-=0
Matlab实现:
代码:
% 目标规划
% x3 = d1-, x7 = d1+
% x4 = d2-, x8 = d2+
% x5 = d3-, x9 = d3+
% x6 = d4-, x10 = d4+
function goalOptimal
f = zeros(10, 1);
f([3 4 5 8 9 10]) = [100000 10000 3000 10000 3000 1000];
A = -eye(10);
A(1,1)=4;A(2,2)=4;
b = zeros(10, 1);
lb=zeros(10, 1);
b(1)=16;b(2)=12;
A1 = [2 3;1 -1;2 2;1 2];
A2 = [eye(4) -eye(4)];
A3 = zeros(1, 10);
A3(5) = 1;
Aeq = [A1 A2];
beq = [12; 0; 12; 8];
x0 = linprog(f,A,b,Aeq,beq);
x = fmincon(@obj,x0,A,b,Aeq,beq,lb,[],@nlc)
function f = obj(x)
f = 100000 * x(3) + 10000 * (x(4)+x(8))+3000*(3*x(5)+3*x(9)+x(10));
function [c, ceq] = nlc(x)
c = [];
ceq = [];