首页 > 电脑 > 请问这个模型用lingo写代码怎么写?

请问这个模型用lingo写代码怎么写?

电脑 2022-09-28

数学建模怎样用lingo程序编写?

model: sets: liu/1..7/:t,w,p; wen/1..2/:; jie(liu,wen):x; endsets min=obj; obj=2*k-@sum(jie(i,j):x(i,j)*t(i)); @for(wen(j):@sum(liu(i):x(i,j)*t(i))<=k); @for(wen(j):@sum(liu(i)|i#ge#5:x(i,j)*t(i))<=q); @for(wen(j):@sum(liu(i):x(i,j)*w(i))<=M); @for(liu(i):@sum(wen(j):x(i,j))<=p(i)); @for(jie(i,j):@g

如何用lingo编写这题的代码

sets: ii/1..100/; jj/1..20/:B; links(ii,jj):c,x; endsets max=@sum(links(i,j): c(i,j)*x(i,j)); @for(ii(i): @sum(links(i,j): x(i,j))=3); @for(jj(j): @sum(links(i,j): x(i,j))<=B(j)); @for(links(i,j): @bin(x(i,j))); data: B=8 1 22 10 8 40 40 1 8 15 19 20 10 2 5 8 30 10 8 38; c=@file('路径+文件名.txt'); endda

lingo求和代码怎么写比如

要定义一个集合,集合确定了i的维度,再用@sum求和

sets:

s1/1..4/: i;

endsets

S=@sum(s1:i);

例如:

sets:

r/1..100/:;

endsets

calc:

sum=0;

@baifor(s(i):sum=sum+i);

endcalc

单用sum函数

sets:

r/1..100/:;

endsets

sum=@sum(r(i):i);

扩展资料;

Objective value: 46.00000

Variable Value Reduced Cost

x1 14.00000 0.000000

x2 0.000000 1.000000

x3 -4 .000000 0.000000

由此可知,当 x1 =14,x2 =0,x3 =-4 时,模型得到最优值,且最优值为 46。

说明:在利用LINGO 求解线性规划时,如自变量都为非负的话,在LINGO 中输入的信息和模型基本相同;如自变量为自由变量,可以使用函数 @free来把系统默认的非负变量定义自由变量,如实例一中的 x3。

参考资料来源:百度百科-LINGO

哪位大侠帮助我们看一下这个lingo程序怎么写,有急用,高分跪求!!!!!!!!!

model: sets: row/1..13/:y; col/1..15/; link(row,col):a,d; endsets max=@sum(row:y); @for(row(i):@sum(col(j):a(i,j))=1); @for(col(j):@sum(row(i):a(i,j))<=1); @for(link(i,j):a(i,j)*d(i,j)*y(i)<=3); @for(link(i,j):y(i)<=a(i,j)); end

如何用lingo10编写这题的代码

model: sets: Ci/1..6/ : c; Cj/1..5/; links(Ci,Cj) : x,y,a;!分别是系数a;变量x,y; endsets data: c=10 10 9.9 9.8 10.8 11.3; !给c,a赋予初值,具体的自己输入; a=6 0 6 0 7 0 6 0 6 0 4 8 3 0 5 5 5 6 0 4 3 0 4 8 0 0 6 0 6 3; enddata min=@sum(links(i,j) : c(i)*x); @for(links : 2*y<=x); @for(links : x<=a*y); @for(Ci(i) | i #le# 4

标签:IT技术 编程

大明白知识网 Copyright © 2020-2022 www.wangpan131.com. Some Rights Reserved. 京ICP备11019930号-18