from gekko import GEKKO m = GEKKO() x = m.Var() y = m.if2(x,-x,2*x) m.Minimize(y) m.solve() print(x.value,y.value)