hi all, So now I'm trying to make all the tests for tnc 1.3 running ok. But there is a problem encountered: here's a code from tnc.py, lines 210-213: for i in range(n): l,u = bounds[i] if l is None: low[i] = -HUGE_VAL So if bounds are for example ([-inf, -1.5], None), as it is written in test1fg(x), it yields error "None object is not iterable". (because it tries to get lb, ub = None ) Do you think it's a sort of bug that should be fixed in svn or not? Regards, D.
so I commit the tnc 1.3 to svn (rev. 3185); the code related to the problem mentioned (about lb-ub) I decided to implement in the following way: if user pass bounds as (for example) ((-1,1), (-1, None), None, (3,4)) then it means 3rd variable is unconstrained. also I think ticket 384 (tnc:argument 2 must be python list, not numpy.ndarray) is ready to be closed (scipy svn rev. 3186) D.
dmitrey wrote:
so I commit the tnc 1.3 to svn (rev. 3185); the code related to the problem mentioned (about lb-ub) I decided to implement in the following way: if user pass bounds as (for example) ((-1,1), (-1, None), None, (3,4)) then it means 3rd variable is unconstrained.
also I think ticket 384 (tnc:argument 2 must be python list, not numpy.ndarray) is ready to be closed (scipy svn rev. 3186)
D.
_______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.org
Dmitrey, scipy.test(1) results in one error connected with tnc ====================================================================== ERROR: test_tnc (scipy.tests.test_optimize.test_tnc) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib64/python2.4/site-packages/scipy/optimize/tests/test_optimize.py ", line 220, in test_tnc err = "Failed optimization of %s.\n" \ TypeError: list objects are unhashable Nils
Nils Wagner wrote:
dmitrey wrote:
so I commit the tnc 1.3 to svn (rev. 3185); the code related to the problem mentioned (about lb-ub) I decided to implement in the following way: if user pass bounds as (for example) ((-1,1), (-1, None), None, (3,4)) then it means 3rd variable is unconstrained.
also I think ticket 384 (tnc:argument 2 must be python list, not numpy.ndarray) is ready to be closed (scipy svn rev. 3186)
D.
_______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.org
Dmitrey,
scipy.test(1) results in one error connected with tnc
====================================================================== ERROR: test_tnc (scipy.tests.test_optimize.test_tnc) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib64/python2.4/site-packages/scipy/optimize/tests/test_optimize.py ", line 220, in test_tnc err = "Failed optimization of %s.\n" \ TypeError: list objects are unhashable
Nils
_______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-dev
Dmitrey,
You have also reverted the order of the output of optimize.fmin_tnc Now it returns (rc, nfeval, x).
It was x, nfeval, rc before. Is this wanted ?
Afaik Robert Kern or someone else had mentioned the problem, but I forgot to check the one. C-compiled tnc module returns the values (x, funevals, rc) in revert order. I have fix this in svn. About failing tests: So I see that test38fg returns x: array([ 0.99327293, 0.98673917, 1.00557938, 1.01114086]) y: array([ 1., 1., 1., 1.]) since they differs more than numpy.assert_array_almost_equal allows, tnc test fails. in scipy.sandbox.newoptimize there is only check for ||f_final - f_opt|| <=1e-8, that's why all test in tnc.py run successfully (and I didn't know that something related to tnc fails). So now I decided just remove check for ||x_final-x_opt|| (I will commit it some minuties later). On the one hand, having ||f_final - f_opt|| is enough - we don't care how far will x_final be from x_opt, if our objfunc values differ very small. On the other, it should be checked that all constraints are ok in x_final. So I think in future, maybe, it's worth to have additional checks added to scipy.optimize tests, that will check is solution feasible or not (but since it will take too much time (for all those fmin_cobyla, l_bfgs_b, tnc), I can't provide it now).
I have some trouble with fmin_ncg. Ok, I will take a look now. afaik scipy tests pass the fmin_ncg ok.
Regards, D.
On Tue, 24 Jul 2007, dmitrey apparently wrote:
So now I decided just remove check for ||x_final-x_opt||
Hmmm. I am not completely comfortable with this. Loosening the test would be better than eliminating it. But can some others please chime in on how to approach this? Also, Nils, any idea why this used to pass and now does not?
it should be checked that all constraints are ok in x_final. So I think in future, maybe, it's worth to have additional checks added to scipy.optimize tests, that will check is solution feasible or not
This seems right; please open a ticket for this. Thank you, Alan
Alan G Isaac wrote:
On Tue, 24 Jul 2007, dmitrey apparently wrote:
So now I decided just remove check for ||x_final-x_opt||
Hmmm. I am not completely comfortable with this.
But the idea is not mine - it had been already done by someone in scipy/sandbox/newoptimize/tnc.py in function test: ex = pow(enorm/norm, 0.5) print "X Error =", ex ef = abs(fg(xopt)[0] - fg(x)[0]) print "F Error =", ef if ef > 1e-8: raise "Test "+fg.__name__+" failed" so, as you see, check for ex is absent (and I think it's rigth, elseware we should provide different error-rising barriers for EACH test func from all those lots related to scipy.optimize test). But in scipy.optimize check of ||x-x_opt|| is still present. I intend just to move the changes to scipy.optimize. BTW if someone will run one of the well-known test func Hilbert(50) (or other rather big n), the typical ||x-x_opt|| (for different solvers) could be something like 100-500, while ||f-f_opt|| can be very small (like 1e-6). This is due to ill-conditioned matrix A from the unconstrained problem (A = hilb(50), b = sum(A), objfunc = x'Ax - bx) HTH, D. D.
Alan G Isaac wrote:
On Tue, 24 Jul 2007, dmitrey apparently wrote:
So now I decided just remove check for ||x_final-x_opt||
Hmmm. I am not completely comfortable with this. Loosening the test would be better than eliminating it. But can some others please chime in on how to approach this? Also, Nils, any idea why this used to pass and now does not?
No idea. Probably Jean-Sébastien Roy could respond to your question. http://www.jeannot.org/~js/code/index.en.html#TNC Nils
it should be checked that all constraints are ok in x_final. So I think in future, maybe, it's worth to have additional checks added to scipy.optimize tests, that will check is solution feasible or not
This seems right; please open a ticket for this.
Thank you, Alan
_______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-dev
dmitrey wrote:
so I commit the tnc 1.3 to svn (rev. 3185); the code related to the problem mentioned (about lb-ub) I decided to implement in the following way: if user pass bounds as (for example) ((-1,1), (-1, None), None, (3,4)) then it means 3rd variable is unconstrained.
also I think ticket 384 (tnc:argument 2 must be python list, not numpy.ndarray) is ready to be closed (scipy svn rev. 3186)
D.
_______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-dev
Dmitrey, You have also reverted the order of the output of optimize.fmin_tnc Now it returns (rc, nfeval, x). It was x, nfeval, rc before. Is this wanted ? Nils
On Tue, 24 Jul 2007, dmitrey apparently wrote:
so I commit the tnc 1.3 to svn (rev. 3185); the code related to the problem mentioned (about lb-ub) I decided to implement in the following way: if user pass bounds as (for example) ((-1,1), (-1, None), None, (3,4)) then it means 3rd variable is unconstrained.
This seems right to me. Nils, do you see any problems with this approach? Cheers, Alan Isaac
Alan G Isaac wrote:
On Tue, 24 Jul 2007, dmitrey apparently wrote:
so I commit the tnc 1.3 to svn (rev. 3185); the code related to the problem mentioned (about lb-ub) I decided to implement in the following way: if user pass bounds as (for example) ((-1,1), (-1, None), None, (3,4)) then it means 3rd variable is unconstrained.
This seems right to me. Nils, do you see any problems with this approach?
No.
Cheers, Alan Isaac
_______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-dev
Hi Dmitrey On Tue, Jul 24, 2007 at 11:38:31AM +0300, dmitrey wrote:
hi all, So now I'm trying to make all the tests for tnc 1.3 running ok. But there is a problem encountered:
here's a code from tnc.py, lines 210-213:
for i in range(n): l,u = bounds[i] if l is None: low[i] = -HUGE_VAL
So if bounds are for example ([-inf, -1.5], None), as it is written in test1fg(x), it yields error "None object is not iterable". (because it tries to get lb, ub = None )
You may want to replace all instances of HUGE_VAL with inf, as was done in http://projects.scipy.org/scipy/scipy/changeset/3037 That changeset also updated the documentation and refactored the tests. Regards Stéfan
Ok, I committed scipy rev 3193 with +/-numpy.inf instead of +/-HUGE_VAL I checked in Python 2.5 all is OK But I'm not sure that all OS, C compilers and hardware platforms will handle the numpy.inf correctly. Updates to documentation and new tests had been implemented from scipy.newoptimize, seems like they are more detailed here. Also, test38fg contains arg2 being numpy.array, not python list, and works correctly (was committed earlier). However, maybe x from tnc output is also better do as numpy.ndarray, not Python list? Regards, D. Stefan van der Walt wrote:
Hi Dmitrey
On Tue, Jul 24, 2007 at 11:38:31AM +0300, dmitrey wrote:
hi all, So now I'm trying to make all the tests for tnc 1.3 running ok. But there is a problem encountered:
here's a code from tnc.py, lines 210-213:
for i in range(n): l,u = bounds[i] if l is None: low[i] = -HUGE_VAL
So if bounds are for example ([-inf, -1.5], None), as it is written in test1fg(x), it yields error "None object is not iterable". (because it tries to get lb, ub = None )
You may want to replace all instances of HUGE_VAL with inf, as was done in
http://projects.scipy.org/scipy/scipy/changeset/3037
That changeset also updated the documentation and refactored the tests.
Regards Stéfan _______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-dev
Hi Dmitrey On Thu, Jul 26, 2007 at 10:37:38AM +0300, dmitrey wrote:
Updates to documentation and new tests had been implemented from scipy.newoptimize, seems like they are more detailed here. Also, test38fg contains arg2 being numpy.array, not python list, and works correctly (was committed earlier).
Your patch caused two regressions: 1. The patch I referred to reformatted the documentation to use restructured text, which you changed back to plain text. 2. The patch corrected the order of the returned arguments, which now again again does does not correspond to the documentation. Regards Stéfan
please check the rev. 3204, is all correct? Regards, D Stefan van der Walt wrote:
Hi Dmitrey
On Thu, Jul 26, 2007 at 10:37:38AM +0300, dmitrey wrote:
Updates to documentation and new tests had been implemented from scipy.newoptimize, seems like they are more detailed here. Also, test38fg contains arg2 being numpy.array, not python list, and works correctly (was committed earlier).
Your patch caused two regressions:
1. The patch I referred to reformatted the documentation to use restructured text, which you changed back to plain text.
2. The patch corrected the order of the returned arguments, which now again again does does not correspond to the documentation.
Regards Stéfan _______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-dev
participants (4)
-
Alan G Isaac -
dmitrey -
Nils Wagner -
Stefan van der Walt