Piecewise Linear Function as Constraint

343 views Asked by At

I'm trying to use pyscipopt to solve a linear programming problem, but am unable to fit the piecewise linear function as a constraint.

The constraint is expressed as follows:

Constraint

I've tried to write it as the following:

cfm = quicksum( max(quicksum(cf[i][t] * q[i] - L[t] for i in range(I)), 0) for t in range(T) / quicksum(L[t] for t in range(T)) <= cfm_max

Where cfm_max = 0.15, in this case.

But it is probably very wrong since it returns a NotImplementedError. I've seen examples in piecewise.py found together with the package, but their usage seems different enough to not work in my case.

Would appreciate any help, thanks.

1

There are 1 answers

3
Erwin Kalvelagen On BEST ANSWER

I think this can be written as:

sum(t,y[t]) <= 0.15*sum(t,L[t])
y[t] >= sum(i,CF[i,t]*q[i])-L[t]

where y[t] are non-negative variables. This is now completely linear (no division, no max()).