[SciPy-dev] openopt example mmp_1.py

Dave dave.hirschfeld@gmail....
Sun Feb 3 07:19:19 CST 2008


dmitrey <dmitrey.kroshko <at> scipy.org> writes:

> I guess we should wait - will other users report the bug or not.
> As for import from numpy, since python doesn't fails with "undefined 
> variable int32" in line 355, hence int32 is imported successfully from 
> numpy

I appear to get the same bug from a just updated svn checkout:

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
IPython 0.8.2.svn.r2848 -- An enhanced Interactive Python.

In [1]: cd C:\src\openopt\scikits\openopt\examples
C:\src\openopt\scikits\openopt\examples

In [2]: run -i mmp_1.py
starting solver nsmm (license: BSD)  with problem  unnamed
incorrect func index type!
---------------------------------------------------------------------------
OpenOptException                          Traceback (most recent call last)

C:\src\openopt\scikits\openopt\examples\mmp_1.py in <module>()
     20 # optional, matplotlib is required:
     21 p.plot=1
---> 22 r = p.solve('nsmm')
     23 print 'MMP result:',  r.ff
     24

c:\python25\lib\site-packages\scikits\openopt\Kernel\BaseProblem.py in solve(sel
f, solvers, *args, **kwargs)
    205
    206     def solve(self, solvers, *args, **kwargs):
--> 207         return runProbSolver(self, solvers, *args, **kwargs)
    208
    209     def auxFunc(self, x, *args, **kwargs):

c:\python25\lib\site-packages\scikits\openopt\Kernel\runProbSolver.py in runProb
Solver(p_, solver_str, *args, **kwargs)
    154     if p.iprint >= 0: print 'starting solver',  p.solverName,  '(license
: ' +  p.solverLicense + ')', ' with problem ', p.name
    155     try:
--> 156         solver(p)
    157     except isSolved:
    158         p.xf = p.xk

c:\python25\lib\site-packages\scikits\openopt\solvers\UkrOpt\nsmm.py in __solver
__(self, p)
     52         p2.primalIterFcn,  p2.iterfcn = p2.iterfcn, iterfcn
     53
---> 54         r2 = p2.solve('ralg')
     55         #xf = fsolve(p.f, p.x0, fprime=p.df, xtol = p.xtol, maxfev = p.m
axFunEvals)
     56         xf = r2.xf

c:\python25\lib\site-packages\scikits\openopt\Kernel\BaseProblem.py in solve(sel
f, solvers, *args, **kwargs)
    205
    206     def solve(self, solvers, *args, **kwargs):
--> 207         return runProbSolver(self, solvers, *args, **kwargs)
    208
    209     def auxFunc(self, x, *args, **kwargs):

c:\python25\lib\site-packages\scikits\openopt\Kernel\runProbSolver.py in runProb
Solver(p_, solver_str, *args, **kwargs)
    154     if p.iprint >= 0: print 'starting solver',  p.solverName,  '(license
: ' +  p.solverLicense + ')', ' with problem ', p.name
    155     try:
--> 156         solver(p)
    157     except isSolved:
    158         p.xf = p.xk

c:\python25\lib\site-packages\scikits\openopt\solvers\UkrOpt\ralg.py in __solver
__(self, p)
     60         p.fk = fk
     61
---> 62         g,  fname,  ind = self.getRalgDirection(x, p)
     63         p._df = copy(g)
     64

c:\python25\lib\site-packages\scikits\openopt\solvers\UkrOpt\ralg.py in getRalgD
irection(self, x, p)
    228             d = p.getMaxConstrGradient(x)
    229         else:
--> 230             d = p.df(x)
    231         return d, fname, ind
    232

c:\python25\lib\site-packages\scikits\openopt\Kernel\objFunRelated.py in user_df
(p, x, IND, ignorePrev)
    136                 return DF
    137
--> 138         df = user_df_func(*(x,) + p.args.f)
    139         if ind is not None: df = df[ind]
    140         if p.useScaling:

c:\python25\lib\site-packages\scikits\openopt\solvers\UkrOpt\nsmm.py in df(x)
     29             F = p.f(x)
     30             ind = argmax(F)
---> 31             return p.df(x, ind)
     32
     33         def iterfcn(*args,  **kwargs):

c:\python25\lib\site-packages\scikits\openopt\Kernel\objFunRelated.py in user_df
(p, x, IND, ignorePrev)
    103
    104     def user_df(p, x, IND = None, ignorePrev=False):
--> 105         if IND is not None: ind = p.getCorrectInd(IND)
    106         else: ind = None
    107         if hasattr(p, 'xPrevDF') and all(x == p.xPrevDF) and not ignoreP
rev and ind is None:

c:\python25\lib\site-packages\scikits\openopt\Kernel\objFunRelated.py in getCorr
ectInd(p, ind)
    356             elif type(ind) == ndarray: return atleast_1d(ind).tolist()
    357             elif type(ind) not in (list, tuple):
--> 358                 p.err('incorrect func index type!')
    359             else: return ind
    360         else: return None

c:\python25\lib\site-packages\scikits\openopt\Kernel\oologfcn.py in ooerr(msg)
     10
     11 def ooerr(msg):
---> 12     raise OpenOptException(msg)
     13
     14 def ooPWarn(msg):

OpenOptException: <oologfcn.OpenOptException instance at 0x01CE9D28>
WARNING: Failure executing file: <mmp_1.py>

In [3]: from scikits import openopt; openopt.__version__
Out[3]: '0.15'

In [4]: import numpy; numpy.__version__
Out[4]: '1.0.3.1'

In [5]: from numpy import *

In [6]: a=0

In [7]: b = int32(15)

In [8]: print type(a), type(b)
<type 'int'> <type 'numpy.int32'>

In [9]:

In [10]: L = [int, int32, int64]

In [11]:

In [12]: if type(a) in L:
   ....:
   ....:          print 'works for me'
   ....:
works for me

In [13]: if type(b) in L:
   ....:
   ....:          print 'works for me'
   ....:
works for me

In [14]:




More information about the Scipy-dev mailing list