# How can I formulate an objective function that minimises the number of items required to solve a problem

I am currently trying to solve a problem where I need to minimise transport cost through the choice of vehicle (and how many of each choice) subject to a given demand.

The problem:

There are currently 3 vehicle sizes corresponding to their haulage capacity, an associated daily cost, and a daily demand.

I need an objective function that minimises the cost through the choice of vehicle whilst satisfying the sales demand, however, I do not know how to define an expression that is based on the number of vehicles used * the cost per day, as it depends on the weight.

Data:

# Vehicle capacity
truck_capacity_dict = {
'7.5T': {'capacity': 7500},
'12T': {'capacity': 12000},
'44T': {'capacity': 44000}
}

# Vehicle daily costs
truck_capacity_dict = {
'7.5T': {'rate': 350},
'12T': {'rate': 660},
'44T': {'rate': 2000}
}

# Daily demand
sales_demand_tonnes = {
'2020-01-01': 300,
'2020-01-02': 293,
'2020-01-03': 176
}


Mathematically, this is similar to the below expression where the OF is to minimise the costs based on the choice of vehicle:

$$\min \sum V_{t, v} * C_{t, v} \forall t \subset T, v \subset V$$

However, I do not know how to formulate an expression in python that determines HOW MANY vehicles are chosen, as this depends on the weight.

• Are you trying to model a VRP variant or it is about the cargo optimization problem? Dec 16 '20 at 9:19

I suggest introducing $$3n$$ variables. Let $$c_{i}$$ be the daily rate of each vehicle $$i=1,2,3$$.
$$x_{i,j}$$ designates the quantity of vehicles which will be used every day: the subscript $$j$$ indicates the day in interest. Supposing to consider $$n$$ days, we have $$j=1, 2, \ldots, n$$ days. Clearly, $$x_{i,j}$$ is a non-negative integer numbe and $$x_{i,j}=0$$ means that no vehicle of kind $$i-th$$ is used in $$j-th$$ day.
The total cost based on the number of vehicles used is $$\min \sum_{j=1}^n \sum_{j=1}^3 c_i \cdot x_{ij}$$