用lingo写代码maxz=1.15x4A+1.40 x2c +1.25 x3B +1.06 x5D (xiA,XiB,Xic,XiD ≥ 0( i = 1, 2, 3, 4, 5) X3B ≤ 40000 X2c ≤ 30000 s,ti -1.15x3A-1.06 x4D + X5D=0 -1.15x2a-1.06 xD +X4A + X4D=0 -1.15x1A-1.06 x2D+X3A+X3B+X3D=0 -1.06x1D+X2A+X2c+X2D=0(X1A+X1D=100000
时间: 2023-05-26 17:02:14 浏览: 132
排队论(MATLAB+LINGO源码).zip_Matlab代码_lingo 排队论_paiduilun_排队论_排队论matl
on startMovie
global maxz,x1A,x2c,x3B,x4A,x4D,x5D,x1D,x2A,x2D,x3A,x3D
-- set initial values
maxz = 0
x1A = 100000
x2c = 0
x3B = 0
x4A = 0
x4D = 0
x5D = 0
x1D = 100000
x2A = 0
x2D = 0
x3A = 0
x3D = 0
-- create simplex table
set simplexTable to [[1.15,0,0,1.06,-1,0,0,0,0,0,0],
[0,1.40,0,0,0,1,-1,0,0,0,0],
[0,0,1.25,0,0,0,0,0,-1,0,0],
[-1.15,0,0,-1.06,0,0,0,0,0,1,0],
[-1.15,0,0,0,0,0,0,-1,-1,0,1],
[0,0,0,0,0,0,1,0,0,0,0]]
-- set constraints
set constraints to [x1A,x2c,x3B,x4A,x4D,x5D,x1D,x2A,x2D,x3A,x3D]
-- while there are negative coefficients in the objective function row
repeat while oneOrMore(count(if(x<0,x,0)) in simplexTable[1]) do
-- find entering variable and pivot column
set minColValue to 9999999
repeat with i = 1 to count(simplexTable[1])
if simplexTable[1][i] < 0 then
set colValue to -1 * simplexTable[1][i] / simplexTable[i+1][oneOrMore(count(if(x>0,1,0)) in simplexTable[i+1])]
if colValue < minColValue then
set minColValue to colValue
set pivotCol to i
end if
end if
end repeat
-- find exiting variable and pivot row
set minRowValue to 9999999
repeat with i = 2 to count(simplexTable)
if simplexTable[i][pivotCol] > 0 then
set rowValue to simplexTable[i][1] / simplexTable[i][pivotCol]
if rowValue < minRowValue then
set minRowValue to rowValue
set pivotRow to i
end if
end if
end repeat
-- perform pivot operation
set pivotValue to simplexTable[pivotRow][pivotCol]
repeat with i = 1 to count(simplexTable[pivotRow])
set simplexTable[pivotRow][i] to simplexTable[pivotRow][i] / pivotValue
end repeat
repeat with i = 1 to count(simplexTable)
if i != pivotRow then
set rowMultiplier to simplexTable[i][pivotCol]
repeat with j = 1 to count(simplexTable[i])
set simplexTable[i][j] to simplexTable[i][j] - rowMultiplier * simplexTable[pivotRow][j]
end repeat
end if
end repeat
-- update solution
set constraints[pivotRow-1] to pivotCol
end repeat
-- set final values
set maxz to simplexTable[1][1] * -1
set x1A to constraints[0]
set x2c to constraints[1]
set x3B to constraints[2]
set x4A to constraints[3]
set x4D to constraints[4]
set x5D to constraints[5]
set x1D to constraints[6]
set x2A to constraints[7]
set x2D to constraints[8]
set x3A to constraints[9]
set x3D to constraints[10]
end on
阅读全文