如何用lingo求解下面的问题呢?一个变量取多个值(或者数组)

2025-01-07 05:32:05
推荐回答(2个)
回答1:

MODEL:

SUBMODEL OBJ:
min=m/n;
ENDSUBMODEL

SUBMODEL CON:
m=2*d*(g*(b*c-a)+c*(h*h+2*f)+a);
n=a*(b*c-a)-s*c*c;
s=p*p;
a=2*d*p*p+2*e*p;
b=1+(1+u)*p*p+4*d*e*p;
c=2*d+2*(1+u)*e*p;
f=-(1+u)*p*p;
g=(1+u)*(1+u)*p*p;
h=2*(1+u)*e*p;
@free(f);
d=0.05;
ENDSUBMODEL
SUBMODEL CON1:
e=0;
ENDSUBMODEL
SUBMODEL CON2:
e=0.1;
ENDSUBMODEL
SUBMODEL CON3:
e=0.2;
ENDSUBMODEL
SUBMODEL CON4:
e=0.3;
ENDSUBMODEL
SUBMODEL CON5:
e=0.4;
ENDSUBMODEL
SUBMODEL CON6:
e=0.5;
ENDSUBMODEL
SUBMODEL CON7:
e=0.6;
ENDSUBMODEL
SUBMODEL CON8:
e=0.7;
ENDSUBMODEL
SUBMODEL CON9:
e=0.8;
ENDSUBMODEL
CALC:

@write('e=0的解:', @newline(1));
@solve(OBJ,CON,CON1);
@write('e=0.1的解:', @newline(1));
@solve(OBJ,CON,CON2);
@write('e=0.2的解:', @newline(1));
@solve(OBJ,CON,CON3);
@write('e=0.3的解:', @newline(1));
@solve(OBJ,CON,CON4);
@write('e=0.4的解:', @newline(1));
@solve(OBJ,CON,CON5);
@write('e=0.5的解:', @newline(1));
@solve(OBJ,CON,CON6);
@write('e=0.6的解:', @newline(1));
@solve(OBJ,CON,CON7);
@write('e=0.7的解:', @newline(1));
@solve(OBJ,CON,CON8);
@write('e=0.8的解:', @newline(1));
@solve(OBJ,CON,CON9);

ENDCALC

END

回答2:

写“e=?”
每次计算机会用对话框询问你e的取值,你可以运行一次,就填不同的e的值进去。
似乎没有比这更简单的方法了。。。