# Mixed Integer Programming - How to model the dependency of two variables in an objective function

I have two variables $$a$$ and $$b$$, in which $$a$$ is the amount of goods and $$b$$ is the amount of boxes of the given sizes. So $$b$$ (box size + number) is dependent on a (goods quantity). If $$a$$ is allocated to a given path, then $$b$$ will increase based on $$a$$, based on a rule to increase the number of boxes and select the best size.

The objective is to minimize the total cost of using boxes for all paths (i.e. tells the proportion of $$a$$ that is allocated to path_1, path_2, path_n, where the combined cost (spending on boxes) is minimal.)

Problem: How to express the relationship between $$a$$ and $$b$$ in the model? Should I model their dependency in the objective function or in the constraint? If constraint, how to describe such a relationship?

You should model this using a set of constraints. Off the cuff you could try this:

$$$$\begin{array}{ll} \text{minimize} & \sum_{i} c_ib_i \\ \text{subject to} & a \leq A_i \rightarrow b_i = n_i \end{array}$$$$

where $$A_i$$ is meant to be the path allocation and $$n_i$$ the number of boxes assigned. The $$\rightarrow$$ constraint is called an indicator constraint, and most modern MIP solvers support it. I would start with this.

• many thanks. could you take a look at a fuller problem description with data is here: or.stackexchange.com/questions/5980/…
– Jack
Mar 24 at 7:37
• is indicator constraint = Channeling constraints? is this "If-Then-Else expressions" an implementation of what you say to model the relationship between a and b? github.com/google/or-tools/blob/master/ortools/sat/doc/…
– Jack
Mar 24 at 7:59
• Indicator constraints are essentially an "If-Then" implementation, see also here: or.stackexchange.com/questions/4367/… Mar 24 at 8:51
• $a \leq A_i \rightarrow b_i = n_i$ is not really an indicator constraint. Indicator constraints have the form $\delta=0 \text{ (or 1)} \Rightarrow \text{linear constraint}$ (where $\delta$ is a binary variable, a.k.a. indicator variable). Mar 25 at 0:29
• @Erwin Kalvelagen any thought?
– Jack
Mar 25 at 7:48