Piecewise linear for a supply function

Yip. Something like this:

using JuMP
fixed_cost = 5.0
regular_cost = 1.0
overtime_cost = 1.5
regular_capacity = 10.0
overtime_capacity = 5.0
total_capacity = regular_capacity + overtime_capacity
model = Model()
@variable(model, 0 <= x <= total_capacity)
@variable(model, 0 <= x_regular <= regular_capacity)
@variable(model, 0 <= x_overtime <= overtime_capacity)
@constraint(model, x == x_regular + x_overtime)
@variable(model, z, Bin)
@constraint(model, x <= total_capacity * z)
@objective(
    model, 
    Min,
    fixed_cost * z + regular_cost * x_regular + overtime_cost * x_overtime,
)

Are such ifelse statements allowed for problem statements that refer to a variable?

These are not allowed

1 Like