Issues with Gurobi Model
AnsweredDear Community,
We would please need some help with our call to Gurobi optimizer. It is not such a difficult task actually and even had it been running in the first place. So we did get at some earlier point some fairly decent results, as expected. Ever since we tried to „optimize“ our optimization — and now the results we get are dissatisfying (to none).
It is a make-and-pack problem. There are six products that need to be produced on six machines (the ultimate task would be to get it running with eighteen products; we startet with a „light version“ and reduced the number of products to six). Now not every machine can not produce every product and it takes some time for every machine to convert so it can either produce or pack a certain different product. Those are pretty common kinds of constraints, we assume. And those are well reflected in our code.
In the first (running) version Gurobi returned as those decent results to be seen here:
After this we tried to add another constraint and enhance the number of products (to eighteen). Something went obviously a bit wrong there and it did not work any more.
Sadly we did not keep the first running version that gave as the desired result as we tried to go back. Now everything seems to be messed up a bit in our code. It can’t be a lot that is going wrong, but maybe someone with some experience would notice the mistake with his educated eyes?
We could of course present anyone the code in more detail, if needed (and I guess it would be needed for the assistance).
Thanks a lot in advance.
.
-
Hi Nicolas,
If I understood correctly, the issue happened after increasing the model size and adding new constraints. Could you please elaborate on what you exactly mean by saying "it did not work anymore"?
- Does it mean that the model is proved to be infeasible?
- Does it mean that the model cannot find a feasible solution?
- Does it mean that the solution returned does not satisfy the constraints as you expect?
If the model is infeasible, you can have a look at the articles below to hopefully pinpoint the cause of infeasibility:
- How do I determine why my model is infeasible?
- How do I change variable or constraint bounds to make an infeasible model feasible using using feasRelax?
If the solution does not satisfy the constraints as you expect, it means that the constraints are not implemented correctly. You would need to double check the implementation of the constraints.
It would be more useful if you write the model into a file and share the model file with us via GoogleDrive, Dropbox, or any file hosting service.
Best regards,
Maliheh
0 -
Hi Maliheh, thanks a lot for your reply. We have been quite busy these days, so apologies for not getting back to that issue before now. Actually Gurobi did run through and also seemed to optimize, but it was slowing down amazingly (it took up to 10 minutes I think) and still did not quite return what we expected. So we even decided to -- apart from debugging, of course -- to dump the model to a file named model.mps. Sadly we can hardly make any sense of this output. We usually did not get the "INFEASIBLE" back, but once even this happened. The constraint we added -- which may have caused the problem -- was one concerning the time constraints. It was called "Infeasible times". But we tried to remove this one from the list of constraints (commented out in code simply) -- and still did not get a reply we hoped for.
We upload all the files to our Google drive folder, including the files model.mps and the gantt_chart. The link is here: https://drive.google.com/drive/folders/1schRR6E61-uvXuAHzWgIkYHuquxxcZfz?usp=sharing
For a better understanding: Lösungsansatz_6Produkte is more or less variable declaration plus the call of the function "Zeitberechnung", which you find in the file "function_f.jl". In this function we pre-sort the products (pretty meaningless), then we tried to set the infeasible time points (but this part is commented out as "not working"). Still we call the function "Optimize_Model" with all the parameters, including Infeasible_Time (all values set to 0). In the Optimize_Model there are all the constraints, but again the infeasible time part commented out.
We hope you bring some light into this darkness?
Thanks a lot for your time
Regards
Nico and Dirk0 -
Hi Nico and Dirk,
It seems that I do not have access to the Google drive folder. You might need to change the permission on the folder.
Best regards,
Maliheh
0 -
Hi Maliheh,
we have changed the permission. Now you should have access to the folder.
https://drive.google.com/drive/folders/1schRR6E61-uvXuAHzWgIkYHuquxxcZfz?usp=sharing
Regards
Nico and Dirk
0 -
to dump the model to a file named model.mps. Sadly we can hardly make any sense of this output.
You can consider saving your model file in LP format which is designed to be human readable. Please see the article What are the differences between LP and MPS file formats?
I can run the model (Model.mps) on a macOS M1 chip to optimality in ~50 seconds using the default setting. The runtime can be cut in almost half by setting the parameter Cuts=2 using the default seed.
To be able to help, we need to understand what you exactly mean by "still did not quite return what we expected". We do not know what you expect to get and the code or the Gannt charts also do not help.
- Run your model (Model.mps) and save its solution into a file
- Save the solution you expect to see into a file and share this file with us. You can also just point one or few variables that you expect to have different values in the optimal solution. For example, you can write that variable \(x\) gets value 1 in the optimal solution but you expect for this variable to be 0.
We can then try to understand why the solution you expect to see is not feasible or optimal for the model.
Best regards,
Maliheh
0 -
Hi Maliheh,
thanks a lot for your reply. Actually you are right. Also in our environment the Gurobi call took less than 50 seconds (it was 42.81 s to be exact). We followed your suggestion and exported the model in the lp format to the file model.lp. This file you find in the shared folder. We took a quick look at this one , as you claimed it was more humanly readable, but still still not make much sense of that one. Maybe you can?
Referring to your question what results we expacted: as you saw in thr first Gantt Chart (Gantt_chart_2 that you still find in the folder)
We would expect to get a similar kind of output in which the processing of the orders make and pack stage are made visible and seem to make some sense.
The problem we tried to explain in the first place. It is this: for our studies we needed to add the infeasible time, which obviously caused some kind of problem, but also there would be eigtheen products. The solution with the six products was just applied for testing purposes.
So even if this were running now it would not really be the ultimate solution (and in the example we sent you it was actually the six products version, which is not covering it all).
Apart from that in our code the gantt_chart is not being produced properly. So the only output we get by now is the still for us not usable and not readable model.lp file.
https://drive.google.com/drive/folders/1schRR6E61-uvXuAHzWgIkYHuquxxcZfz?usp=sharing
Thanks a lot for your kind assistence
Nico and Dirk
0 -
but still still not make much sense of that one.
I am not sure what you mean by saying that the LP file does not make sense to you. It shows your model. For example, you have:
minimize
obj: 1 C_4,1_ + 1 C_4,2_ + 1 C_5,1_ + 1 C_5,2_ + 1 C_2,1_ + 1 C_2,2_This is the objective you defined in your \(\texttt{Optimize_Model.jl}\) file.
@objective(m, Min, ∑(∑(C[i,l] for l ∈ L) for i ∈ Produkte))
The same is true for the constraints.
We would expect to get a similar kind of output in which the processing of the orders make and pack stage are made visible and seem to make some sense.
I am so sorry, but as I have mentioned it already, the only way I can investigate this further is if you can articulate the sentence "a solution should make sense" to a solution (assignment of values to the decision variables that you expect to see). I can then investigate why you do not get that expected solution.
Best regards,
Maliheh
0
Please sign in to leave a comment.
Comments
7 comments