Hi, I am struggling to construct a code that solves a convex problem.
The problem is a maximization problem with an objective function which is continuous, smooth, and concave, but piecewised.
The problem is as follows:
In the above problem, B is a given constant, and C_i for all i are also given constants.
g_{i,1}(x), g_{i,2}(x), g_{i,3}(x) are all concavely increasing function with respect to x.
Also at x=C_i, g_{i,2} and g_{i,3} have the same values and the same derivatives, i.e., g_{i,2}(C_i)=g_{i,3}(C_i) and g_{i,2}β(C_i)=g_{i,3}β(C_i).
Actually functions, g, are explicitly given for me. So, I made a code with them, but the condition (xi>Ci) makes an error. Thank you for link, I will read it.
You canβt just express your function using if-else where the if-else conditions include values of optimization variables. You would have to model it carefully using binary variables as in the link you got from @Erling or some variation of that. There are resources on mixed-integer modeling of piecewise defined functions online.