Problem on Optimized Parameters are 0
AnsweredHello,
I'm trying to solve an optimization problem, where I have attempted to code up my problem, but the optimized parameters are all 0. So I was wondering if someone could please help me take a look at the formulation of my problem in my code, because the constraints are very complicated.
The optimization problem is as follows:
The constraint E_n(m^1) and E_n(m^2) are complicated functions that first it involves simulating a term omega, denoted by b=1,..B in the math formula, (s = 1, ...S in the code, sorry for the confusion) and taking the average of the calculated value for each i, where i = 1, ...n.
Here is the formulation for E_n(m^1):
where U's formulation is as follows:
(The code below is a simplier version of U)
The formulation for E_n(m^2) is very similar to E_n(m^1), so I won't repeat.
Therefore, in the code below, you would notice two loops that address the simulation of omega, and for each i.
Although I was able to run the optimization, the only non-zero optimized value is for C. The rest of the parameters are all 0.
Here is are pictures of my code: (sorry I do not know how to use code block to paste my code in its original format)
And here is the output of the optimization:
-
Hi Annie,
Posting screenshots of your code makes it very hard to provide help because one cannot copy and paste your code. If you would like to share big chunks of code, it is best to upload the files somewhere. Note that uploading files in the Community Forum is not possible but we discuss an alternative in Posting to the Community Forum.
Do you have a feasible solution at hand, i.e., a solution that you know has to be feasible for your model and does not set all variable to \(0\)? If yes, then you should try fixing the variable bounds to the respective value which you think should provide a feasible solution. If the model then gets infeasible, you can try to find out what is going wrong as discussed in the Knowledge Base article How do I determine why my model is infeasible?
Best regards,
Jaromił0 -
Hello Jaromil,
Thank you for the reply. Here is the Google Drive link to the Colab that contains the code.https://drive.google.com/file/d/1GDLDQaZp8cBuI-HH7XFEHggX8DUWqnS1/view?usp=sharing
I have tried your suggestion to set some parameters at the value of the true parameters since I have simulated the data myself.
I noticed that for alpha and deltas, and if I set them at the true parameter values, the rest of the optimized parameters are at 0, (except C and T2). And when I set eigen_cc to be at the true parameter values, the model becomes infeasible and unbounded. I tried to set the objective to be 0 to see if it becomes infeasible. And here is the output I got from the infeasibility test:
›\ Model _copy
\ LP format - for model browsing. Use MPS format to capture full model detail.
Minimize
Subject To
U_c_M1_4: - alpha + 2.113659049444557 eigen_cc + U_c = 0
Bounds
-infinity <= alpha <= 1
eigen_cc >= 0.5359145040785996
EndAnd the result is saying the constraint in the first loop is causing the problem, and I have highlighted that line of code that's causing the problem.
So I think maybe the way I code up the loops are not correct, and that's why this is causing the problem.
Thank you so much for your help and I really appreciate it!
Best regards,
Annie
0 -
Hi Annie,
From the IIS you posted, you can see what is causing the infeasibility.
Variable \(U_c\) is \(\geq 0\) and \(2.113 \cdot eigen_{cc} \geq 1.132740541274324 \). So in order to make the model feasible \(\alpha\) would have to take the value at least \(\alpha \geq 1.132740541274324\) or \(U_c\) should be allowed to attain negative values. Does this help?
Best regards,
Jaromił0 -
Hello Jaromil,
Thanks for the reply. That makes sense. And I just want to double-check with you that my code does reflect my mathematical equations since I'm adding many constraints, such as U_c in order to use the exp and log operations, and the loops for s and i.
Thank you so much!
Best regards,
Annie
0 -
Hi Annie,
And I just want to double-check with you that my code does reflect my mathematical equations since I'm adding many constraints, such as U_c in order to use the exp and log operations, and the loops for s and i.
One good way to check whether your model looks as expected is to use the write method to write a human-readable LP file.
model.write("myModel.lp")
This will generate a file named \(\texttt{myModel.lp}\) which you can analyze in any standard text editor. To make the analysis easier, you should provide a unique name for every variable and constraint in your model. It also makes sense to make the model smaller for this analysis.
One thing that looks suspicious is that the \(U_c\) variable is forced to be \(\geq 0\) (Note that Gurobi's default value for lower bound of variables is \(0\)). This limits the term \(\exp(U_c\) to be always \(\geq 1\). I don't know anything about your application so this might just be correct but it's definitely worth a look.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
5 comments