Minimizing cost using derivative

justkieting

New member
Joined
Feb 19, 2021
Messages
10
Hi guys, could someone please help me derive a formula to solve for the following? I'm trying to find the best combination of Uber & Rental Car to minimize total cost. I think there's a way to use derivative to find the minimal cost without doing trial and error. Please assist. If you need more clarification about the problem statement, please let me know. Thank you!
 

Attachments

  • Minimal cost (Uber & Rental Car).pdf
    75.6 KB · Views: 4
Rental car reservation cost : $200 per 30 day per car [can only rent 30 days each time]
Uber (on demand): $30 day per car

Based on actual usage below, what is the best combination of Rental Car and Uber to minimize total cost? Please help create an equation (using derivative?) so I can modify the rates and usage as needed.

Actual usage:
1st 10 days = 4 cars for 5 days
10th - 20th day = 5 cars for 6 days
20th - 30th day = 3 cars for 4 days

To minimize cost, what combination of rental car to reserve and uber to get for the 30 day period?

Example:
Situation 1 - All on demand:
Car to reserve 0
Rental car cost $0
On demand cost $1,860
Total cost $1,860


Situation 2 - All reservation:
Car to reserve 5
Rental car cost $1,000
On demand cost $0
Total cost $1,000


Situation 3 - Partial:

Car to reserve 1
Rental car cost $200
On demand cost $1,410
Total cost $1,610


Formula to minimize total cost ?
 
Rental car reservation cost : $200 per 30 day per car [can only rent 30 days each time]
Uber (on demand): $30 day per car

Based on actual usage below, what is the best combination of Rental Car and Uber to minimize total cost? Please help create an equation (using derivative?) so I can modify the rates and usage as needed.

Actual usage:
1st 10 days = 4 cars for 5 days
10th - 20th day = 5 cars for 6 days
20th - 30th day = 3 cars for 4 days

To minimize cost, what combination of rental car to reserve and uber to get for the 30 day period?

Example:
Situation 1 - All on demand:
Car to reserve 0
Rental car cost $0
On demand cost $1,860
Total cost $1,860


Situation 2 - All reservation:
Car to reserve 5
Rental car cost $1,000
On demand cost $0
Total cost $1,000


Situation 3 - Partial:
Car to reserve 1
Rental car cost $200
On demand cost $1,410
Total cost $1,610


Formula to minimize total cost ?
Please show us what you have tried and exactly where you are stuck.

Please follow the rules of posting in this forum, as enunciated at:


Please share your work/thoughts about this problem.
 
Please show us what you have tried and exactly where you are stuck.

Please follow the rules of posting in this forum, as enunciated at:


Please share your work/thoughts about this problem.
Hi Subhotosh Khan,

I've tried creating a formula as follow:

Total cost = (# of rental car reserved x rental car rate) + (Uber cost per day x [number of car needed during day 1 - number of car reserved]) + (Uber cost per day x [number of car needed during day 2 - number of car reserved]) + (Uber cost per day x [number of car needed during day 3 - number of car reserved])


This is the formula that I have created, but after taking the first derivative of Total Cost and set it to zero, I get a constant. Please help derive a formula so I don't have to rely on trial and error to find the number of car to reserve in order to minimize cost. Thank you!
 
You could write up a cost function and a LaGrangian function and find where the partial derivatives are zero, but the answer would almost certainly not be an integer so you would still need to do some trial and errors. If you had thousands of options, that might be an efficient way to go, but trial and error here seems far more efficient.
 
Hi Subhotosh Khan,

I've tried creating a formula as follow:

Total cost = (# of rental car reserved x rental car rate) + (Uber cost per day x [number of car needed during day 1 - number of car reserved]) + (Uber cost per day x [number of car needed during day 2 - number of car reserved]) + (Uber cost per day x [number of car needed during day 3 - number of car reserved])


This is the formula that I have created, but after taking the first derivative of Total Cost and set it to zero, I get a constant. Please help derive a formula so I don't have to rely on trial and error to find the number of car to reserve in order to minimize cost. Thank you!
You say:

"...after taking the first derivative of Total Cost..."

You calculated first derivative of total cost - with respect to which variable. There are many variables in your equation. Please show your mathematical work - instead of talking about it.
 
You say:

"...after taking the first derivative of Total Cost..."

You calculated first derivative of total cost - with respect to which variable. There are many variables in your equation. Please show your mathematical work - instead of talking about it.

The variable is the number of car to reserve
 
You could write up a cost function and a LaGrangian function and find where the partial derivatives are zero, but the answer would almost certainly not be an integer so you would still need to do some trial and errors. If you had thousands of options, that might be an efficient way to go, but trial and error here seems far more efficient.

Hi Jeff,
I understand that trial and error is the most efficient way to go about solving for this specific question. This is just an example I am using to simplify another real life example that I am trying to solve for, which have alot more number of usage data. Could you please demonstrate how to use cost function and LaGrangian function to find where the partial derivatives are zero for this example? Once I get the idea, I would be able to apply it to my real life example. Thank you!
 
The variable is the number of car to reserve
Total cost = (# of rental car reserved x rental car rate) + (Uber cost per day x [number of car needed during day 1 - number of car reserved]) + (Uber cost per day x [number of car needed during day 2 - number of car reserved]) + (Uber cost per day x [number of car needed during day 3 - number of car reserved])
Things that are "not variable" does NOT CHANGE their values (another name CONSTANT). So are you saying:

# of rental car reserved → CONSTANT

Uber cost per day → CONSTANT

# of car needed during day 1 → CONSTANT
.
.
and so on?
 
# of rental car reserved → VARIABLE

Uber cost per day → CONSTANT

# of car needed during day 1 → CONSTANT

.
.
and so on
 
I was wrong: you can ignore LaGrangian multipliers. You cannot use calculus because your functions are not differentiable. They are discrete piecewise functions.

Your data are not sufficient to determine anything. What you need to know is the distribution of cars demanded per day, and then minimize expected cost. I am going to assume that H is the highest required on any day and L is the lowest required every day, and that you know the probability distribution of cars demanded.

[MATH]c(r,\ d) = \text {cost per day if r cars are reserved and d are demanded.}[/MATH]
[MATH]c(r, d) = \dfrac{20r}{3} \text { if } d \le r \text { and } c(r,\ d) = \dfrac{20r}{3} + 30d - 30r.[/MATH]
Buy that? On my assumptions, d will be an integer from L to H rather than a continuous variable.

[MATH]p(d) = \text {probability that d will be demanded on a day.}[/MATH]
[MATH]e(r) = \text {expected daily cost if r reserved} = \sum_{d=L}^H p(d) * c(r,\ d).[/MATH]
It is obvious that r < L is higher cost than r [MATH]\ge[/MATH] L.

Now pick the lowest expected cost.

If you have hundreds of data points, this is easy to do with a spread sheet.

If you have hundreds of thousands, you will need to get more sophisticated.
 
I was wrong: you can ignore LaGrangian multipliers. You cannot use calculus because your functions are not differentiable. They are discrete piecewise functions.

Your data are not sufficient to determine anything. What you need to know is the distribution of cars demanded per day, and then minimize expected cost. I am going to assume that H is the highest required on any day and L is the lowest required every day, and that you know the probability distribution of cars demanded.

[MATH]c(r,\ d) = \text {cost per day if r cars are reserved and d are demanded.}[/MATH]
[MATH]c(r, d) = \dfrac{20r}{3} \text { if } d \le r \text { and } c(r,\ d) = \dfrac{20r}{3} + 30d - 30r.[/MATH]
Buy that? On my assumptions, d will be an integer from L to H rather than a continuous variable.

[MATH]p(d) = \text {probability that d will be demanded on a day.}[/MATH]
[MATH]e(r) = \text {expected daily cost if r reserved} = \sum_{d=L}^H p(d) * c(r,\ d).[/MATH]
It is obvious that r < L is higher cost than r [MATH]\ge[/MATH] L.

Now pick the lowest expected cost.

If you have hundreds of data points, this is easy to do with a spread sheet.

If you have hundreds of thousands, you will need to get more sophisticated.
-----------------------

Hi Jeff:

Thank you very much for your input on this. Using the formula that you have created, I have computed the total costs by plugging in different scenario (r = 1, r= 2, r = 3, etc.), and was able to find which "r" that would give me the minimal total cost . However, it is still a pretty manual effort even with a spread sheet. I just wish there is a more straightforward way to derive the optimal number of "r" to give me the minimal cost without doing brute force trial and error. Understood that calculus would not work since this is not a differentiable equation.

If we were to think about this from a graphical standpoint, where y axis = total cost, and x axis = number of reserved car, is there not a way to find out at which "x" where the slope will turn from negative to positive (i.e. total cost would stop decreasing and start increasing)?
 
Send me your email address by private message. I think the spreadsheet can be done easily. If so, I shall send it to you.

By the way, you need to include r = 0 unless you are positive that at least one will be demanded every day.

The problem with thinking about slopes is that these are so called Diophantine equations. That is a topic I know very little about; it is an active field of mathematical research. There is also a field called integer programming, which I know nothing about. Of course, these are very simple Diophantine equations; numerical methods seem promising. Let me see what I can do with a spreadsheet before I start to plunge into something that I'll need to do research on.

I want to warn you. I'll have to guess on the probabilities. You probably have the data to make good estimates of the probabilities. The correct answer may turn out to be sensitive to the probabilities, meaning fairly small changes in the probabilities may have material effects on the answer.
 
Send me your email address by private message. I think the spreadsheet can be done easily. If so, I shall send it to you.

By the way, you need to include r = 0 unless you are positive that at least one will be demanded every day.

The problem with thinking about slopes is that these are so called Diophantine equations. That is a topic I know very little about; it is an active field of mathematical research. There is also a field called integer programming, which I know nothing about. Of course, these are very simple Diophantine equations; numerical methods seem promising. Let me see what I can do with a spreadsheet before I start to plunge into something that I'll need to do research on.

I want to warn you. I'll have to guess on the probabilities. You probably have the data to make good estimates of the probabilities. The correct answer may turn out to be sensitive to the probabilities, meaning fairly small changes in the probabilities may have material effects on the answer.

Hi Jeff:
Thank you so much for all your help. I was able to actually use the "what-if" analysis in excel to quickly find the minimal cost and corresponding "r." Thank you so much for your help and guidance!!!!
 
Top