first thanks for this awesome update! Unfortunately, I ran in some errors while trying to update my programm (metano.tu-bs.de) to the newest version of pymprog...
I am trying to describe it as simple as I can:
The flux balance analysis works pretty good with pymprog 1.0, unless I try to reset the objective function by running
min(sum(self.glpkVar[i]*0. for i in self.objIndices),
"objective")
and afterwards I set a new objective with this code:
objIndices = [i for i in range(len(obj)) if obj[i] != 0.]
min(sum(self.glpkVar[i]*obj[i] for i in objIndices),
"objective")
Then I am trying to solve the model and it gives me the following error message:
Traceback (most recent call last):
File "fba.py", line 804, in <module>
main()
File "fba.py", line 775, in main
options.minimizeFlux, not options.useFullMatrix)
File "fba.py", line 663, in runOnModel
lbSplit, ubSplit, fbaParams)
File "fba.py", line 379, in run
s = ps.minimize()[1]
File "/home/jhe/metano/metano-1.1-devel/src/linearproblem.py", line 237, in minimize
self.glpkP.solve()
File "/usr/local/lib/python2.7/dist-packages/pymprog.py", line 5259, in solve
me.update_lazy() #this takes care of rebuilding
File "/usr/local/lib/python2.7/dist-packages/pymprog.py", line 4443, in update_lazy
e.update(me)
File "/usr/local/lib/python2.7/dist-packages/pymprog.py", line 831, in update
for i, c in expr.mat:
AttributeError: 'float' object has no attribute 'mat'
When I am not trying to change the objective everything works just fine and the solver gives me the right result, so I thing there is an issue with the new update function? Hopefully you have some suggestions for me to solve the problem.
Thanks in advance and best regards,
Julia Helmecke
Last edit: Julia Helmecke 2017-02-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for the late response, it seems that problem is caused by a bad objective function: your objective is only a constant (i.e. the coefficients for all variables are zero).
Regards,
Yingjie
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thank you for your answer. Indeed, the program resets the objective value by giving an empty vector (all values are zero), since this was necessary in older pymprog versions. I have deleted this function and now the program runs without any error messages. The problem is, that it always returns an infeasible solution. Let me make it more clear: when I run the script for only one reaction of my model (the reaction is set as objective function), it works properly. But when I iterate through all reactions in the model and set them as objective function, it returns an unfeasible solution, even with the same values given in the single run.
My question is now: how do I reset the old objective function (if necessary) and set a new one? If you need a minimal working example, just let me now. You can also install metano via pip (see metano.tu-bs.de) and run the fva.py script to see my issue.
Best regards,
Julia
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry again for the late response, I should check it more often seriously. The usual way to modify your objective coeficients is to use parameters, you may look at this example:
I have solved the problem now. There was an issue in the first definition of the flux variable. I did not set both boundaries to None, so the default lower and upper bound was 0 and inf, respectively. This was not an issue in previous versions, so maybe you changed the default bounds in the var() function? If so, consider to include it in the "A word on compatability" section on your website. :)
However, thank you for your help with my objective function issue. Now everything works fine again.
Best regards,
Julia
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks for letting me know things worked out well in the end. And I will document it to help others out who might encounter similar problems, I suppose this is from really old version of pymprog.
Best regards,
Yingjie
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hallo PyMathProg Team,
first thanks for this awesome update! Unfortunately, I ran in some errors while trying to update my programm (metano.tu-bs.de) to the newest version of pymprog...
I am trying to describe it as simple as I can:
The flux balance analysis works pretty good with pymprog 1.0, unless I try to reset the objective function by running
and afterwards I set a new objective with this code:
Then I am trying to solve the model and it gives me the following error message:
When I am not trying to change the objective everything works just fine and the solver gives me the right result, so I thing there is an issue with the new update function? Hopefully you have some suggestions for me to solve the problem.
Thanks in advance and best regards,
Julia Helmecke
Last edit: Julia Helmecke 2017-02-15
Hi Julia,
Sorry for the late response, it seems that problem is caused by a bad objective function: your objective is only a constant (i.e. the coefficients for all variables are zero).
Regards,
Yingjie
Hello Yingjie,
thank you for your answer. Indeed, the program resets the objective value by giving an empty vector (all values are zero), since this was necessary in older pymprog versions. I have deleted this function and now the program runs without any error messages. The problem is, that it always returns an infeasible solution. Let me make it more clear: when I run the script for only one reaction of my model (the reaction is set as objective function), it works properly. But when I iterate through all reactions in the model and set them as objective function, it returns an unfeasible solution, even with the same values given in the single run.
My question is now: how do I reset the old objective function (if necessary) and set a new one? If you need a minimal working example, just let me now. You can also install metano via pip (see metano.tu-bs.de) and run the fva.py script to see my issue.
Best regards,
Julia
Hi Julia,
Sorry again for the late response, I should check it more often seriously. The usual way to modify your objective coeficients is to use parameters, you may look at this example:
http://pymprog.sourceforge.net/advanced.html#assign
I tried the fva.py script, but it requres options to start running. Can you give me a commandline with options so that I can replicate the problem?
Regards,
Yingjie
Hallo Yingjie,
I have solved the problem now. There was an issue in the first definition of the flux variable. I did not set both boundaries to None, so the default lower and upper bound was 0 and inf, respectively. This was not an issue in previous versions, so maybe you changed the default bounds in the var() function? If so, consider to include it in the "A word on compatability" section on your website. :)
However, thank you for your help with my objective function issue. Now everything works fine again.
Best regards,
Julia
Hi Julia,
thanks for letting me know things worked out well in the end. And I will document it to help others out who might encounter similar problems, I suppose this is from really old version of pymprog.
Best regards,
Yingjie