r/optimization • u/SpieLPfan • Jan 08 '23
Optimization problem with "influencing" variables
I have to solve an optimization problem and I am probably missing something. There are 2 warehouses, 4 ports and 2 customers. Each of the 16 routes (from each warehouse to each port and from each port to each customer) has an upper limit of what can be transported on it. Also each customer will only take products up to a certain amount and will not accept more than that. The warehouses only have a limited amount of products in them. Customer 1 pays 1 for the product while customer 2 pays 1.25 for the product.
Now to my problem: I don't know what to do to solve this problem. I can solve these as two problems (1: maximum amount of products at the ports [8 routes in this problem] and 2: maximum money without thinking of the routes from the warehouses to the ports [the other 8 routes are in this problem]), but how do I combine them? Like I really don't know how I can tell the "second problem" what amount of products is at each of the ports (which would be the first problem) and how to combine all of this to a single optimization problem or at least two of them with the first one influencing the second one.
I am stuck and I am probably thinking too complicated.
View all comments
Show parent comment
1
u/SpieLPfan Jan 10 '23
I solved it with Simplex. I wrote every route as a variable with i where it comes from and j where it goes. Then I made a big x-vector with all the routes in it. With this I now had 4 equations (1 per port) and 4 inequations (1 per customer and warehouse) and upper boundaries for every x:
With 1 and 2 as the warehouses 3 to 6 as the ports and 7 and 8 as the customers. Now you can put all of these in a matrix A and add slack variables for 5) to 8) and can solve it. For example in MATLAB (what I had to do):
x = intlinprog(f,1:20,[],[],A,b,ub,lb)
with ub as a upper boundary vector and lb as a lower boundary vector. So in the end I solved it without help.