In this example, we maximize the volume of a box with height , width , and depth , with limits on the wall area and the floor area , subject to bounds on the aspect ratios and . The optimization problem is
Problem Formulation
# Problem dataA_wall <-100A_flr <-10alpha <-0.5beta <-2gamma <-0.5delta <-2h <-Variable(pos =TRUE)w <-Variable(pos =TRUE)d <-Variable(pos =TRUE)volume <- h * w * dwall_area <-2* (h * w + h * d)flr_area <- w * dhw_ratio <- h / wdw_ratio <- d / wconstraints <-list( wall_area <= A_wall, flr_area <= A_flr, hw_ratio >= alpha, hw_ratio <= beta, dw_ratio >= gamma, dw_ratio <= delta)problem <-Problem(Maximize(volume), constraints)cat("Is problem DGP?", is_dgp(problem), "\n")
Is problem DGP? TRUE
Solution
result <-psolve(problem, gp =TRUE)check_solver_status(problem)cat("Optimal value (volume):", result, "\n")cat("h:", value(h), "\n")cat("w:", value(w), "\n")cat("d:", value(d), "\n")
Optimal value (volume): 77.45967
h: 7.745967
w: 3.872983
d: 2.581989
Sensitivity Analysis via Dual Values
The dual values provide sensitivity information. A 1% increase in the allowed wall area should yield approximately a proportional increase in the maximum volume value.
cat("Dual value for wall area constraint:", dual_value(constraints[[1]]), "\n")cat("Dual value for floor area constraint:", dual_value(constraints[[2]]), "\n")
Dual value for wall area constraint: 0.8333587
Dual value for floor area constraint: 0.6666413
The dual value for the wall area constraint is approximately 0.83, meaning a 1% increase in allowed wall space yields approximately a 0.83% increase in the maximum volume. The dual value for the floor area constraint is approximately 0.67, meaning a 1% increase in allowed floor space yields approximately a 0.67% increase in maximum volume.