LJIWY
Let \(R_1,R_2,...,R_6\) represent pairs produced by regular-time labor, \(O_1,O_2,...,O_6\) represent pairs produced by over-time labor, \(I_0,I_2,...,I_6\) represent inventory carried over to the next period (so \(I_1=0\))
\(min\ 7\sum R_i + 11\sum O_i + \sum I_i\)
\(s.t.\)
\((1)\ O_i \leq 100\)
\((2)\ R_i \leq 200\)
\((3)\ Balance\ Contraints:\ O_i+R_i+I_{i-1}-I_i-Di\geq 0,\ i=1,2,...,6\)
\((4)\ I_0=0\)
demand = c(200,260,240,340,190,150)
cost = c(rep(7,6),rep(11,6),rep(1,7))
vars1 = make.lp(0,19)
# Set Obj. Coef.
set.objfn(vars1,cost)
# Set Obj. Direc.
lp.control(vars1,sense = 'min')
## $anti.degen
## [1] "fixedvars" "stalling"
##
## $basis.crash
## [1] "none"
##
## $bb.depthlimit
## [1] -50
##
## $bb.floorfirst
## [1] "automatic"
##
## $bb.rule
## [1] "pseudononint" "greedy" "dynamic" "rcostfixing"
##
## $break.at.first
## [1] FALSE
##
## $break.at.value
## [1] -1e+30
##
## $epsilon
## epsb epsd epsel epsint epsperturb epspivot
## 1e-10 1e-09 1e-12 1e-07 1e-05 2e-07
##
## $improve
## [1] "dualfeas" "thetagap"
##
## $infinite
## [1] 1e+30
##
## $maxpivot
## [1] 250
##
## $mip.gap
## absolute relative
## 1e-11 1e-11
##
## $negrange
## [1] -1e+06
##
## $obj.in.basis
## [1] TRUE
##
## $pivoting
## [1] "devex" "adaptive"
##
## $presolve
## [1] "none"
##
## $scalelimit
## [1] 5
##
## $scaling
## [1] "geometric" "equilibrate" "integers"
##
## $sense
## [1] "minimize"
##
## $simplextype
## [1] "dual" "primal"
##
## $timeout
## [1] 0
##
## $verbose
## [1] "neutral"
# Regular-time <= 200
for (i in 1:6){
add.constraint(vars1,1,"<=",200,indices = i)
}
# Over-time <= 100
for (i in 7:12){
add.constraint(vars1,1,"<=",100,indices = i)
}
# Balance constraints
for (i in 1:6){
add.constraint(vars1,c(1,1,1,-1),"=",demand[i],indices = c(i,i+6,i+12,i+13))
}
# I_0 = 0
add.constraint(vars1,1,"=",0,indices = 13)
solve(vars1)
## [1] 0
print (get.objective(vars1))
## [1] 10660
print (get.variables(vars1))
## [1] 200 200 200 200 190 150 0 60 80 100 0 0 0 0 0 40 0
## [18] 0 0
Let \(A_1,A_2,B_1,B_2,C_1,C_2\) represent acres of one site a bidder is going to get, i.e. \(A_1\) for acres of site 1 Alexis can get.
\(max 1000A_1 + 1900A_2 + 900B_1 + 2200B_2 + 1000C_1 + 2000C_2\)
\(s.t.\)
\((1)\ Balance\ Constraint:\ A_1+B_1+C_1=10000\)
\((2)\ Balance\ Constraint:\ A_2+B_2+C_2=10000\)
\((3)\ A_1+A_2 \leq (10000+10000)*40%\)
\((4)\ B_1+B_2 \leq (10000+10000)*40%\)
\((5)\ C_1+C_2 \leq (10000+10000)*40%\)
sol2 = make.lp(0,6)
cost = c(1000,1900,900,2200,1000,2000)
# Obj. Coef.
set.objfn(sol2,cost)
# Obj. Direct.
lp.control(sol2,sense='max')
## $anti.degen
## [1] "fixedvars" "stalling"
##
## $basis.crash
## [1] "none"
##
## $bb.depthlimit
## [1] -50
##
## $bb.floorfirst
## [1] "automatic"
##
## $bb.rule
## [1] "pseudononint" "greedy" "dynamic" "rcostfixing"
##
## $break.at.first
## [1] FALSE
##
## $break.at.value
## [1] 1e+30
##
## $epsilon
## epsb epsd epsel epsint epsperturb epspivot
## 1e-10 1e-09 1e-12 1e-07 1e-05 2e-07
##
## $improve
## [1] "dualfeas" "thetagap"
##
## $infinite
## [1] 1e+30
##
## $maxpivot
## [1] 250
##
## $mip.gap
## absolute relative
## 1e-11 1e-11
##
## $negrange
## [1] -1e+06
##
## $obj.in.basis
## [1] TRUE
##
## $pivoting
## [1] "devex" "adaptive"
##
## $presolve
## [1] "none"
##
## $scalelimit
## [1] 5
##
## $scaling
## [1] "geometric" "equilibrate" "integers"
##
## $sense
## [1] "maximize"
##
## $simplextype
## [1] "dual" "primal"
##
## $timeout
## [1] 0
##
## $verbose
## [1] "neutral"
# Balance Constraints
for (i in 1:2){
add.constraint(sol2,rep(1,3),"=",10000,indices = seq(i,i+4,2))
}
# Constraint (3)-(5)
for (i in c(1,3,5)){
add.constraint(sol2,rep(1,2),"<=",8000,indices = c(i,i+1))
}
solve(sol2)
## [1] 0
print (get.objective(sol2))
## [1] 31600000
print (get.variables(sol2))
## [1] 8000 0 0 8000 2000 2000
Therefore,
Alexis should get 8000 acres of site 1
Blake should get 8000 acres of site 2
Cliff should get 2000 acres of site 1 and 2000 acres of site 2
Let \(x_{ij},\ i=1,2,3,4,\ j=1,2,3,4\) be 16 binary variables representing whether each swimmer will swim a certain stroke or not, and \(c_{ij}\) the corresponding time it takes.
i = 1 for Gary, 2 for Mark, 3 for Jim, 4 for Chet.
j = 1 for Free, 2 for Breat, 3 for Fly, 4 for Back.
\(min\ \sum c_{ij}x_{ij}\)
\(s.t.\)
\(\sum _i x_{ij}=1\)
\(\sum _j x_{ij}=1\)
\(x_{ij} is binary\)
sol3 = make.lp(0,16)
cost = c(54,54,51,53,
51,57,52,52,
50,53,54,56,
56,54,55,53)
# Obj. Coef.
set.objfn(sol3,cost)
# Obj. Direc.
lp.control(sol3,sense='min')
## $anti.degen
## [1] "fixedvars" "stalling"
##
## $basis.crash
## [1] "none"
##
## $bb.depthlimit
## [1] -50
##
## $bb.floorfirst
## [1] "automatic"
##
## $bb.rule
## [1] "pseudononint" "greedy" "dynamic" "rcostfixing"
##
## $break.at.first
## [1] FALSE
##
## $break.at.value
## [1] -1e+30
##
## $epsilon
## epsb epsd epsel epsint epsperturb epspivot
## 1e-10 1e-09 1e-12 1e-07 1e-05 2e-07
##
## $improve
## [1] "dualfeas" "thetagap"
##
## $infinite
## [1] 1e+30
##
## $maxpivot
## [1] 250
##
## $mip.gap
## absolute relative
## 1e-11 1e-11
##
## $negrange
## [1] -1e+06
##
## $obj.in.basis
## [1] TRUE
##
## $pivoting
## [1] "devex" "adaptive"
##
## $presolve
## [1] "none"
##
## $scalelimit
## [1] 5
##
## $scaling
## [1] "geometric" "equilibrate" "integers"
##
## $sense
## [1] "minimize"
##
## $simplextype
## [1] "dual" "primal"
##
## $timeout
## [1] 0
##
## $verbose
## [1] "neutral"
# Each swimmer swims once
for (i in c(1,5,9,13)){
add.constraint(sol3,rep(1,4),"=",1,indices = c(i:(i+3)))
}
# Each stroke is used once
for (i in 1:4){
add.constraint(sol3,rep(1,4),'=',1,indices = seq(i,16,4))
}
set.type(sol3,c(1:16),type='binary')
solve(sol3)
## [1] 0
print (get.variables(sol3))
## [1] 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0
print (get.objective(sol3))
## [1] 207
Therefore, Gary should swim Fly, Mark Back, Jim Free, Chet Breast, yielding a total of 207 seconds.