已知量随另一量变化。下表列出一组和的对应值。
0.0 0.5 1.0 1.5 1.9 2.5 3.0 3.5 4.0 4.5
1.0 0.9 0.7 1.5 2.0 2.4 3.2 2.0 2.7 3.5
5.0 5.5 6.0 6.5 7.0 7.5 8.5 9.0 10.0
1.0 4.0 3.6 2.7 5.7 4.6 6.0 6.8 7.3
(1)拟合一条对这组数据点“最好的”直线。目标是使线性关系式的计算值与每个观测值间所构成的绝对偏差之和最小。
(2)拟合一条“最好的”直线,目标是使线性关系式的计算值与每个观测值间的最大偏差为最小。
(3)为这组数据点拟合一条“最好的”二次曲线,其目标与(1)和(2)相同。
(1)该问题是不可优微化的问题,求常数a,b使得绝对偏差总和达到最小,即
相应的Lingo语言如下:
model:
sets:
quantity/1..19/:x,y;
endsets
min=@sum(quantityabs(a*x+b-y));
@free(a);
@free(b);
data:
x=0.0,0.5,1.0,1.5,1.9,2.5,3.0,3.5,4.0,4.5,
5.0,5.5,6.0,6.6,7.0,7.6,8.5,9.0,10.0;
y=1.0,0.9,0.7,1.5,2.0,2.4,3.2,2.0,2.7,3.5,
1.0,4.0,3.6,2.7,5.7,4.6,6.0,6.8,7.3;
enddata
end
其运行如下:
Linearization components added:
Constraints: 76
Variables: 76
Integers: 19
Global optimal solution found.
Objective value: 11.46625
Extended solver steps: 0
Total solver iterations: 29
Variable Value Reduced Cost
A 0.6375000 0.000000
B 0.5812500 0.000000
最优解为:a=0.6375 ,b=0.5813 ,即
(2)其最优化问题为
相应的Lingo语言如下:
model:
sets:
quantity/1..19/:x,y;
endsets
min=@max(quantityabs(a*x+b-y));
@free(a);
@free(b);
data:
x=0.0,0.5,1.0,1.5,1.9,2.5,3.0,3.5,4.0,4.5,
5.0,5.5,6.0,6.6,7.0,7.6,8.5,9.0,10.0;
y=1.0,0.9,0.7,1.5,2.0,2.4,3.2,2.0,2.7,3.5,
1.0,4.0,3.6,2.7,5.7,4.6,6.0,6.8,7.3;
enddata
end
运行结果如下:
Variable Value Reduced Cost
A 0.6250000 0.000000
B -0.4000000 0.000000
相应的最优直线方程为
(3)用(1)目标下的最优化问题为
相应的Lingo语言如下:
model:
sets:
quantity/1..19/:x,y;
endsets
min=@sum(quantityabs(c*x^2+b*x+a-y));
@free(a);
@free(b);
data:
x=0.0,0.5,1.0,1.5,1.9,2.5,3.0,3.5,4.0,4.5,
5.0,5.5,6.0,6.6,7.0,7.6,8.5,9.0,10.0;
y=1.0,0.9,0.7,1.5,2.0,2.4,3.2,2.0,2.7,3.5,
1.0,4.0,3.6,2.7,5.7,4.6,6.0,6.8,7.3;
enddata
end
其运行结果为:
Variable Value Reduced Cost
C 0.3372549E-01 0.000000
B 0.2945098 0.000000
A 0.9823529 0.000000
于是其相应的最优解为:
若用(2)的目标,即其相应的最优化问题为:
相应的Lingo语言如下:
model:
sets:
quantity/1..19/:x,y;
endsets
min=@max(quantityabs(c*x^2+b*x+a-y));
@free(a);
@free(b);
data:
x=0.0,0.5,1.0,1.5,1.9,2.5,3.0,3.5,4.0,4.5,
5.0,5.5,6.0,6.6,7.0,7.6,8.5,9.0,10.0;
y=1.0,0.9,0.7,1.5,2.0,2.4,3.2,2.0,2.7,3.5,
1.0,4.0,3.6,2.7,5.7,4.6,6.0,6.8,7.3;
enddata
end
其运行结果如下:
Variable Value Reduced Cost
C 0.1250000 0.000000
B -0.6250000 0.000000
A 2.475000 0.000000
其最优解为:
|