I'm currently trying to solve a problem. According to some people I know it's a linear programming problem, however, I've not had the course just yet.

Situation: At my warehouse we get different types of materials to craft the final product $r$. The production depends on how well you can manage the stock so that you won't run out of intermediate resources. I basically have to maximize crafting product $r$. In order to do so, I need to know how much I need to craft from each intermediate step. The final working code will provide me information on how much $gp$ and then $e$ I should craft.

To make one $r$, you need 150 $gp$ and 10 $e$. So I formulated my steps as follows:

$$r = 150 gp + 10 e$$ $$10 gp = 20 s$$ $$e = 50 gp + 10 s$$

Obviously you cannot craft more than your stock allows you to, so I am upperbound by my stock. This stock is variable every cycle I need it, as the stock constantly changes.

$$s \leq 500000$$

$$gp \leq 11866$$

$$e \leq 1107$$

Also said stock cannot be negative as it is a real problem.

For visualization I've attached a diagram to see what the relations are between each resource.

I've found a function in MATLAB that should be able to be able to solve my problem.

[X,Z] = linprog(f,A,b,Aeq,beq,lb,ub)

I know I need to set up an objective function to maximize/minimize over, and I need to replace the variables with $x_1 ... x_n$. However, I don't know how to tackle it right at the moment.

  • 1
    $\begingroup$ Did you read the documentation for linprog? $\endgroup$ – user3417 Aug 24 '19 at 17:08
  • $\begingroup$ Yes I've read the documentation, however, I cannot formulate a suitable objective function f to use linprog. $\endgroup$ – Kevin Laemers Aug 24 '19 at 17:48
  • $\begingroup$ There is a bit of problem. Your optimization is not linear here since you also have non-linear constraints $\endgroup$ – Mostafa Ayaz Aug 24 '19 at 20:30
  • $\begingroup$ @MostafaAyaz do you know a way of optimizing this problem? I would love knowing which direction I should be looking to get a solution. $\endgroup$ – Kevin Laemers Aug 24 '19 at 21:48
  • $\begingroup$ You can use the fmincon MATLAB toolbox. I also suggest you to simplify the optimization problem as much as you can. For example, the objective function can be explicitly written as a function of $s$. $\endgroup$ – Mostafa Ayaz Aug 24 '19 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.