I want to use the sum of a series of linear expressions as objective and constraints. These linear expressions are chosen to be included or not based on some conditions. I can achieve it in Excel Solver but don't know how to code it in python.
I've seen a solution of adding conditional constraints here but it couldn't take the sum of all the needed expressions before binding a limit.
Here is the model to be solved.
Variables:
$x_0\ge0,\ x_1\ge0,\ x_2\ge0,\ x_3\ge0 $
There are $n$ linear expressions:
$f_i(x_0,x_1,x_2,x_3) = a_{i0}x_0 + a_{i1}x_1 + a_{i2}x_2 + a_{i3}x_3 + b_i\quad (i=0,1,\dots,n)$
Objective: to minimize the objective function below
$ objective = 0\\ for\ i\ in\ range(n): \\ \quad if\ f_i(x_0,x_1,x_2,x_3)\ge0:\\ \quad\quad objective\ = objective\ + f_i(x_0,x_1,x_2,x_3)\\ $
Constraints: sum $\ge$ -5000
$ sum=0\\ for\ i\ in\ range(n): \\ \quad if\ f_i(x_0,x_1,x_2,x_3)\lt0:\\ \quad\quad sum\ = sum\ + f_i(x_0,x_1,x_2,x_3)\\ $