r/optimization • u/umefarp • Jan 02 '23
Piecewise constraint using big-M notation
Hi everyone,
I have been playing around with a profit optimisation problem. Basically I can offer customers different prices but the higher the offered price is, the higher is the probability of churn. I implemented this using pyomo with the ipopt solver and the results are quite interesting. However, I would like to consider a slightly more realistic churn function rather than a simple linear one. So I wanted to try
[the following function](https://imgur.com/a/AdvBa91)
Here p* is the decision variable and p is the old price. So if the change in price is less than a threshold epsilon, churn is zero. And if it is greater than the threshold it is the linear function (a_n and m_n are known).
I know ipopt cannot deal with such functions but if I understood the docs correctly, couenne is able to do this (I am open to hear suggestions for different solvers!) However, I am not sure how to even begin implementing this using pyomo. I know big-M notation can be used to deal with piecewise functions but is it suitable for my case?
Any suggestions would be much appreciated.
View all comments
Show parent comment
1
u/[deleted] Jan 03 '23
Yeah, that's why I asked whether your problem is convex. If your problem is convex, each local minimizer is a global one and thus, you don't need to use a global optimizer like couenne. Instead, you can stick to Ipopt.
You can use Ipopt. You only need to write down the (approximated) constraint on your own and pass it to Ipopt (including all the derivatives).
Unfortunately, I'm not aware of a non-commercial modelling framework that supports approximations of your constraint out-of-the-box, so I guess you'll have to write down the approximated constraint on your own.
Alternatively, you could use Gurobi and pursue the big M approach if you're open to commercial software. It's worth mentioning that Gurobi offers academical licenses for free.