1 / 59

# 物流运作优化-实验课.ppt

FICOXpress-IVE
MoselXpress-IVE
WritingamodelinMosel
modelTransportation
uses“mmxprs”

declarations
a:array(1..2)ofinteger
b:array(1..4)ofinteger
c:array(1..2,1..4)ofinteger
x:array(1..2,1..4)ofmpvar
end-declarations
forall(iin1..2,jin1..4)
x(i,j)is_integer
initializationsfrom&quot;&quot;
a
b
c
end-initializations!引入数据
WritingamodelinMosel 目标函数与限制条件
!设置总成本函数
Cost:=sum(iin1..2,jin1..4)c(i,j)*x(i,j)
!设置限制条件
forall(iin1..2)sum(jin1..4)x(i,j)&lt;=a(i)
forall(jin1..4)sum(iin1..2)x(i,j)&gt;=b(j)
minimize(Cost)!设置目标函数,成本变量不需要声明
WritingamodelinMosel Output&amp;results
!输出目标函数getobjval表示优化后的值
writeln(“Totalcost:“,getobjval)
!输出各个变量的值
forall(iin1..2,jin1..4)
writeln(“x(”,i,”,”,j,”)=“,getsol(x(i,j)))
Howtowriteamodel inMoselXpress-IVE
Nameofthemodel
Declarations(decisionvariables,arrays,etc.)
Datainput
Objectivefunction
Constraints
Output&amp;results
15
Howtowriteamodel (1)Nameofthemodel
modelModelName
uses“mmxprs”
16
Howtowriteamodel (2)Declarations(variables,arrays,etc.)
declarations
Variable(变量名):mpvar
VariableArray(变量名):array()ofmpvar
end-declarations
17
Howtowriteamodel (3)Datainput–optionalsection
initializationsfrom“Filename”
UnitCost;
end-initializations
18