一个关于用lingo解二次规划限制条件的问题model:data:H=@file('imageinfo.txt');W=@file('imageinfo.txt');r=@file('imageinfo.txt');c=@file('imageinfo.txt');height=@file('imageinfo.txt');width=@file('imageinfo.txt');Du=0;enddatasets:coordinate:x,y;rows/1..H/;cols/1..W/;rr/1..r/;cc/1..c/;salient(rows,cols):saliency;mesh(rr,cc):mesh_x,mesh_y,grid_x,grid_y,newmesh_x,newmesh_y,saliency;endsetsdata:saliency=@file('saliency.txt');mesh_x=@file('coordinate_x.txt');mesh_y=@file('coor

问题描述:

一个关于用lingo解二次规划限制条件的问题
model:
data:
H=@file('imageinfo.txt');
W=@file('imageinfo.txt');
r=@file('imageinfo.txt');
c=@file('imageinfo.txt');
height=@file('imageinfo.txt');
width=@file('imageinfo.txt');
Du=0;
enddata
sets:
coordinate:x,y;
rows/1..H/;
cols/1..W/;
rr/1..r/;
cc/1..c/;
salient(rows,cols):saliency;
mesh(rr,cc):mesh_x,mesh_y,grid_x,grid_y,newmesh_x,newmesh_y,saliency;
endsets
data:
saliency=@file('saliency.txt');
mesh_x=@file('coordinate_x.txt');
mesh_y=@file('coordinate_y.txt');
grid_x=@file('grid_x.txt');
grid_y=@file('grid_y.txt');
@text('result_x.txt')=newmesh_x;
@text('result_y.txt')=newmesh_y;
enddata
@for(mesh(I,J) | mesh_x(I,J) #ne# -1:newmesh_x(I,J)=mesh_x(I,J));
@for(mesh(I,J) | mesh_y(I,J) #ne# -1:newmesh_y(I,J)=mesh_y(I,J));
目标函数;
min=@sum(mesh(I,J) | (I #le# H) #and# (J #le#W):(saliency(I,J)+0.2)*(
( (newmesh_x(I,J)-newmesh_x(I,J+1) ) - (grid_x(I,J)-grid_x(I,J+1) ) )^2+( (newmesh_y(I,J)-newmesh_y(I,J+1) ) - (grid_y(I,J)-grid_y(I,J+1) ) )^2+
( (newmesh_x(I,J+1)-newmesh_x(I+1,J+1) ) - (grid_x(I,J+1)-grid_x(I+1,J+1) ) )^2+( (newmesh_y(I,J+1)-newmesh_y(I+1,J+1) ) - (grid_y(I,J+1)-grid_y(I+1,J+1) ) )^2+
( (newmesh_x(I+1,J+1)-newmesh_x(I+1,J) ) - (grid_x(I+1,J+1)-grid_x(I+1,J) ) )^2+( (newmesh_y(I+1,J+1)-newmesh_y(I+1,J) ) - (grid_y(I+1,J+1)-grid_y(I+1,J) ) )^2+
( (newmesh_x(I+1,J)-newmesh_x(I,J) ) - (grid_x(I+1,J)-grid_x(I,J) ) )^2+( (newmesh_y(I+1,J)-newmesh_y(I,J)) - (grid_y(I+1,J)-grid_y(I,J) ) )^2));
需求约束;
@for(mesh(I,J):
@gin(newmesh_x(I,J));
@gin(newmesh_y(I,J)));
@for(mesh(I,J) | J #le# W:newmesh_x(I,J)+1 @for(mesh(I,J) | I #le# H:newmesh_y(I,J)+1

问题应该在mesh_x(I,J) #ne# -1上面 你看是否有等价的限制条件 最好不要在下标这里做限制
而且如果可能为负必须用@free
另外下面所有的le应该换成lt才对吧
那 mesh_x(I,J) #ne#
差不多该给分了