I am currently learning how to use Gurobi for Python using their official tutorial found here. In this example, they appear to formulate the objective by simply specifying a cost dictionary to the obj
argument in addVars
. However, I am not sure how to formulate more complicated objectives such as the example below:
I have formulated the cost to be $$\min\sum_{i=1}^{v}\sum_{j=1}^{w}\left[c_{ij}\sum_{k=1}^{p} x_{ijk}\right]$$ where $c_{ij}$ represents the fixed cost of shipping 1 unit of product from vineyard $i$ to winery $j$ and $x_{ijk}$ represents the amount of product $i$ shipped from vineyard $j$ to winery $k$.
The goal of this toy model is to minimize the cost of shipping while using up all the supply at the vineyards. However, I am having a hard time formulating the objective. I cannot simply use obj=
because the cost of shipping isn't multiplied by each individual decision variable. The tutorial does not showcase more complicated examples of constructing objectives using obj
argument.
How can I formulate my objective properly using Gurobi in Python?