I am working on a simple case of convex optimization. I modeled the system on paper and now am using Python the RSOME library. I want to maximise $(x-5)^2$ (bounded between $0 \leqslant x \leqslant 10$) but the code keeps telling me that this is a nonconvex case. Does anyone know if it is nonconvex? a positive parabola is fundamentally convex no?
Here is my Python code:
import rsome as rso
import numpy as np
from rsome import ro
from rsome import dro
from rsome import E
#from rsome import eco_solver as grb
from rsome import grb_solver as grb
model = dro.Model('test') # create an RSOME model
x = model.dvar()
model.max(rso.square(x-5)) #working
#model.st(rso.square(x-5) <= 100)
#model.st(x <= 10)
#model.st(rso.square(x-5))
model.st(x= >= 0)
model.st(x <= 5)
model.solve(grb)
print(x.get())
user_value = x.get()
Here are the error messages:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-21-ffa94a01dc07> in <module>
21 model.st((x-5) <= 5)
22
---> 23 model.solve(grb)
24
25 print(x.get())
3 frames
/usr/local/lib/python3.8/dist-packages/rsome/lp.py in __ge__(self, other)
2935 elif isinstance(left, DecConvex):
2936 if left.sign == -1:
-> 2937 raise ValueError('Nonconvex constraints.')
2938 return DecCvxConstr(left, left.event_adapt)
2939 elif isinstance(left, DecPerspConvex):
ValueError: Nonconvex constraints.