[SciPy-dev] openopt example mmp_1.py
Dave
dave.hirschfeld at gmail.com
Sun Feb 3 09:00:30 EST 2008
Very strange:
In [3]: debug
> c:\python25\lib\site-packages\scikits\openopt\kernel\oologfcn.py(12)ooerr()
11 def ooerr(msg):
---> 12 raise OpenOptException(msg)
13
ipdb> up
> c:\python25\lib\site-packages\scikits\openopt\kernel\objfunrelated.py(358)getC
orrectInd()
357 elif type(ind) not in (list, tuple):
--> 358 p.err('incorrect func index type!')
359 else: return ind
ipdb> ind
0
ipdb> type(ind)
<type 'numpy.int32'>
ipdb> type(ind) not in (list, tuple)
True
ipdb> type(ind) in [int, int32, int64]
False
ipdb> int32
<type 'numpy.int32'>
ipdb> int64
<type 'numpy.int64'>
ipdb> type(ind) is int
False
ipdb> type(ind) is int32
False
Works with Alan's code (after importing NoneType):
Alan G Isaac <aisaac <at> american.edu> writes:
>
> def getCorrectInd(p, ind):
from types import NoneType
> if type(ind) in [NoneType, list, tuple]:
> result = ind
> else:
> try:
> result = atleast_1d(ind).tolist()
> except:
> raise ValueError('%s is an unknown func index type!'%type(ind))
> return result
>
In [3]: run -i mmp_1.py
starting solver nsmm (license: BSD) with problem unnamed
Niter F
0 6.47e+003
44 1.45e+003
nsmm has finished solving the problem unnamed
istop: 4 (|| F[k] - F[k-1] || < ftol)
Solver: Time Elapsed = 0.26 CPU Time Elapsed = 0.248339942646
Plotting: Time Elapsed = 2.55 CPU Time Elapsed = 2.55752253429
objFunValue: 1449.79080685 (feasible, max constraint = 0)
MMP result: 1449.79080685
In [4]:
More information about the SciPy-Dev
mailing list