Dec-12-2018, 09:14 PM
(This post was last modified: Dec-12-2018, 09:14 PM by Mini_Miudo.)
Hey everyone. So, I don't know if this is the right place to post this, I'm starting my dissertation so this isn't really "homework" per se, but my first task for this was to solve a "simple" (not so simple for me it seems) Inventory Management problem, where I have to optimize the points at which I should order and how much I should order. However, I never used python before (thus the "simple" problem to start with), having only started 2 days ago, so I'm struggling. I'm trying to use the "minimize" function from SciPy. I'll try to give you a detailed explanation of the problem and then I'll post the code I have so far (which has no errors but isn't working as intended) if someone wants to try and help out, I've been trying to solve this pretty much non-stop during these 2 days to no avail.
The problem
Parameters (set by the user/me):
T - time span for the problem
d - demand during each day
RT - review time, which is the time between 2 placed orders
LT - lead time, which is the time that goes from when the order is placed until it arrives
h - on-hand inventory cost
I0 - initial stock
s - target stock
The variables to calculate: (NOTE: I used i as the counter in my code, but using j here so everything doesn't become italic)
Qt - quantity to order each day - main variable as it will influence all the others
It - on-hand inventory at the end of each day - I defined "today's" inventory as It[j] = It[j-1] - d[j] + Qt[j-LT] -> j-LT because the quantity I ordered arrives LT days later. It[0] = I0 - d[0]
NIt - net inventory at the start of each day - I defined it as NIt[j] = NIt[j-1] - d[j] + Qt[j-1] with NIt[0] = I0
I+ - on-hand inventory (It > 0), defined as I+ = It
I- - backorder (It < 0), defined as I- = -It
Constraints:
Qt >= 0
I+ >= 0
I- >= 0
Objective function:
minimize cost = h*I+ + b*I-
The code
Taking the above into account, I tried to create a program that optimizes the objective function by changing the value of Qt. However, it isn't working (Qt is always equal to the initial value I give it - if I say the initial value is 1 for every day, then the minimize function returns Qt = 1 for every day as well, same for every number) and it was brought to my attention that the while loop I'm doing in the "Objective" function I created doesn't make sense. So, how do I make the minimize function actually optimize the values for Qt, while also making sure these values for Qt affect It/NIt/I+/I- and, of course, the objective function? The code is in the spoiler:
Apologies if this is too much or if I said some nonsense and thanks in advance.
The problem
Parameters (set by the user/me):
T - time span for the problem
d - demand during each day
RT - review time, which is the time between 2 placed orders
LT - lead time, which is the time that goes from when the order is placed until it arrives
h - on-hand inventory cost
I0 - initial stock
s - target stock
The variables to calculate: (NOTE: I used i as the counter in my code, but using j here so everything doesn't become italic)
Qt - quantity to order each day - main variable as it will influence all the others
It - on-hand inventory at the end of each day - I defined "today's" inventory as It[j] = It[j-1] - d[j] + Qt[j-LT] -> j-LT because the quantity I ordered arrives LT days later. It[0] = I0 - d[0]
NIt - net inventory at the start of each day - I defined it as NIt[j] = NIt[j-1] - d[j] + Qt[j-1] with NIt[0] = I0
I+ - on-hand inventory (It > 0), defined as I+ = It
I- - backorder (It < 0), defined as I- = -It
Constraints:
Qt >= 0
I+ >= 0
I- >= 0
Objective function:
minimize cost = h*I+ + b*I-
The code
Taking the above into account, I tried to create a program that optimizes the objective function by changing the value of Qt. However, it isn't working (Qt is always equal to the initial value I give it - if I say the initial value is 1 for every day, then the minimize function returns Qt = 1 for every day as well, same for every number) and it was brought to my attention that the while loop I'm doing in the "Objective" function I created doesn't make sense. So, how do I make the minimize function actually optimize the values for Qt, while also making sure these values for Qt affect It/NIt/I+/I- and, of course, the objective function? The code is in the spoiler:
Apologies if this is too much or if I said some nonsense and thanks in advance.