I don’t know how to store inventory for later use¶

Similar to the previous point, our experiments have found that the current generation LLMs find it challenging to deal with specific problems that include multiple periods of time, where one period accumulates something that rolls over to the next month.
Take for instance the following (partial) problem description:
An investor has a capital of $500,000 and has some investment projects to choose from in the coming 3 years.
Amounts are invested at the start of the year once the investment duration has passed, the vested amount plus return rate is returned at the end of the year.
...
Objective: Maximize the capital at the end of year 3
Intuitively, it should be easy to understand how this works: You invest in a program for 1 year. At the end of year 1 you get back your initial investment plus returns which become available to invest in the coming year.
We can run this premise many times, and only get back a correct model 30% of the time. What is interesting is that the other 70% of incorrect models are wrong in so many different and subtle ways that it’s not clear what in the prompt is causing confusion.
Through some iterations we have managed to improve the prompt efficiency by:
explicitly stating how to model wealth accumulation (via intermediate variables), and
using terminology that is more consistent (solely mentioning wealth at the start of the month while removing the notion at the end of the month).
This increased the ratio of correct models to around 75%.
An investor has a capital of $500,000 and has some investment projects to choose from in the coming 3 years.
Amounts are invested at the start of the year once the investment duration has passed, the vested amount plus return rate is returned at the end of the year.
The investment project all have a duration and expected return. Some project are constrained on the maximum vested amount and when they can be invested in.
The investor can choose between the following 4 projects:
1. Can be invested in any year (and multiple times). Duration is 1 year and the total return is 20%
2. Can be only invested in year 1. Duration is 2 years and the total return during that period is 150%. Maximum vested amount is $120,000.
3. Can be only invested in year 2. Duration is 1 year and the total return during that period is 160%. Maximum vested amount is $150,000.
4. Can be only invested in year 3. Duration is 1 year and the total return during that period is 40%. Maximum vested amount is $100,000.
Objective: Maximize the capital at the end of year 3
Constraints:
- Initial capital at year 1 is $500,000
- All available capital at year i can be allocated to the different projects
- The available capital at year i consists of the vested amounts in the projects plus returns of the previous year.
An investor has a capital of $500,000 and has some investment projects to choose from in the coming 3 years.
Amounts are invested at the start of the year once the investment duration has passed, the vested amount plus return rate is returned at the end of the year.
The investment project all have a duration and expected return. Some project are constrained on the maximum vested amount and when they can be invested in.
The investor can choose between the following 4 projects:
1. Can be invested in any year (and multiple times). Duration is 1 year and the total return is 20%
2. Can be only invested in year 1. Duration is 2 years and the total return during that period is 150%. Maximum vested amount is $120,000.
3. Can be only invested in year 2. Duration is 1 year and the total return during that period is 160%. Maximum vested amount is $150,000.
4. Can be only invested in year 3. Duration is 1 year and the total return during that period is 40%. Maximum vested amount is $100,000.
Create intermediate variables Ci that represent the starting capital in year i.
Objective: Maximize C4
Constraints:
- Initial capital at year 1 is $500,000
- All available capital Ci at year i can be allocated to the different projects during the year. All capital should be fully invested every year.
- Ci is calculated by taking the consists of the vested amounts in the projects plus returns of the previous year.
🔢 Problem Definition
We are given an investment problem where an investor needs to allocate their capital over three years among different investment projects to maximize the capital at the end of year 3.
Decision Variables
\(x_{i,j}\): Amount of capital invested in project \(j\) during year \(i\) (where \(i \in \{1, 2, 3\}\) and \(j \in \{1, 2, 3, 4\}\)).
Intermediate Variables
\(C_i\): Capital available at the start of year \(i\) (where \(i \in \{1, 2, 3, 4\}\)).
Objective
Maximize the capital at the start of year 4, \(C_4\).
Constraints
Initial capital at year 1: \(C_1 = 500,000\).
Capital in subsequent years: - \(C_{i+1} = \sum_{j} x_{i,j} \times (1 + r_j)\), where \(r_j\) is the return rate of project \(j\).
Capital allocation constraints: - \(C_1 = x_{1,1} + x_{1,2}\) - \(C_2 = x_{2,1} + x_{2,3}\) - \(C_3 = x_{3,1} + x_{3,4}\)
Investment constraints: - \(x_{1,2} \leq 120,000\) - \(x_{2,3} \leq 150,000\) - \(x_{3,4} \leq 100,000\)
Return Rates
\(r_1 = 0.2\) (20%)
\(r_2 = 1.5\) (150%)
\(r_3 = 1.6\) (160%)
\(r_4 = 0.4\) (40%)
import gurobipy as gp
from gurobipy import GRB
# Create a new model
m = gp.Model("investment_planning")
# Parameters
C1_initial = 500000
r = [0.2, 1.5, 1.6, 0.4] # Return rates for each project
# Decision variables: Amount invested in each project in each year
x = m.addVars(3, 4, vtype=GRB.CONTINUOUS, name="x")
# Intermediate variables: Capital at the start of each year
C = m.addVars(4, vtype=GRB.CONTINUOUS, name="C")
# Objective: Maximize the capital at the start of year 4
m.setObjective(C[3], GRB.MAXIMIZE)
# Constraints
# Initial capital at year 1
m.addConstr(C[0] == C1_initial, "initial_capital")
# Capital at the start of each year
m.addConstr(C[1] == x[0, 0] * (1 + r[0]) + x[0, 1] * (1 + r[1]), "capital_year_2")
m.addConstr(C[2] == x[1, 0] * (1 + r[0]) + x[1, 2] * (1 + r[2]), "capital_year_3")
m.addConstr(C[3] == x[2, 0] * (1 + r[0]) + x[2, 3] * (1 + r[3]), "capital_year_4")
# Full investment constraints
m.addConstr(C[0] == x[0, 0] + x[0, 1], "investment_year_1")
m.addConstr(C[1] == x[1, 0] + x[1, 2], "investment_year_2")
m.addConstr(C[2] == x[2, 0] + x[2, 3], "investment_year_3")
# Investment constraints on specific projects
m.addConstr(x[0, 1] <= 120000, "max_investment_project_2")
m.addConstr(x[1, 2] <= 150000, "max_investment_project_3")
m.addConstr(x[2, 3] <= 100000, "max_investment_project_4")
# Optimize the model
m.optimize()
# Extract results
results = {
"C1": C[0].X,
"C2": C[1].X,
"C3": C[2].X,
"C4": C[3].X,
"Investments": {(i+1, j+1): x[i,j].X for i in range(3) for j in range(4)}
}