File: test_cobyla.py

package info (click to toggle)
python-scipy 0.3.2-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,572 kB
  • ctags: 20,326
  • sloc: ansic: 87,138; fortran: 51,876; python: 47,747; cpp: 2,134; objc: 384; makefile: 175; sh: 83
file content (20 lines) | stat: -rw-r--r-- 545 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

from scipy_test.testing import *

set_package_path()
from optimize import cobyla as co
restore_path()

class test_cobyla(ScipyTestCase):
    def check_simple(self, level=1):

        function = lambda x: x[0]**2 + abs(x[1])**3
	con1 = lambda x: x[0]**2 + x[1]**2 - 25
	con2 = lambda x: -con1(x)

        x = co.fmin_cobyla(function, [4.95,0.66], [con1, con2], rhobeg=1, 
			   rhoend=1e-5, iprint=0, maxfun=100)
        print 'Result:',x,'(exact result = 4.955356249106168, 0.666666666666666)'

if __name__ == "__main__":
    ScipyTest().run()