赞
踩
##小型模型
###线性规划
model:
title Solve linear optimization;
max = 2 * x1 + 3 * x2;
2 * x1 + x2 <8;
4 * x1 + 3 * x2 < 15;
end
###二次规划
model:
title:Solving quadratic programming
!hahaha;
[opt]max = 98 * x1 + 277 * x2 - x1 ^ 2 - 0.3 * x1 * x2 - 2 * x2 ^ 2;
[st1]x1 + x2 < 100;
[st2]x1 < 2 * x2;
@gin(x1);
@gin(x2);
!对x1取整,lingo函数加@
end
##大型模型
数组型变量
###段
优化模型——六段
###基本集合与属性变量
####表示
sets: !集合段 ;
s/1…100/:x;
!基本集合,集合名与属性变量;
endsets
!目标与约束段;
@sum(s(i):x(i))<90;
!循环求和函数;
####怎样赋值
sets:
!集合段;
ss/1…10/:b;
endsets
data:
!数据段;
b = 1 0 1 2 3 5 2 6 1 2 ;
enddata
####表整数值
sets: !集合段;
a/1…100/:x;
b/1…200/:y;
endsets
!目标与约束段;
@for(b(j):@gin(y(j)));
@for(a(i):@gin(x(i)));
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。