我从线性化方法中看到了一些尺寸错误。具体来说,
File "/usr/local/lib/python2.7/site-packages/openmdao/core/system.py", line 726, in _apply_linear_jac
arg_vec[param] += J.T.dot(dresids._flat(unknown)).reshape(shape)
ValueError: shapes (6,108) and (36,) not aligned: 108 (dim 1) != 36 (dim 0)
我有一些二维数组,它们为所有输入向量的单个输出向量定义雅可比行列式的一部分。我无法查明错误的确切原因,因为有几种情况符合给定的形状。我想知道问题是否可以通过自己展平阵列来解决。
关于如何解决此错误的任何其他想法将不胜感激。这些渐变在 1.0 之前的版本中运行良好。
完整的错误消息如下:
Traceback (most recent call last):
File "/Users/user/directory/exampleOptimization.py", line 82, in <module>
prob.run()
File "/usr/local/lib/python2.7/site-packages/openmdao/core/problem.py", line 789, in run
self.driver.run(self)
File "/usr/local/lib/python2.7/site-packages/openmdao/drivers/scipy_optimizer.py", line 191, in run
options=self.opt_settings)
File "/usr/local/lib/python2.7/site-packages/scipy/optimize/_minimize.py", line 452, in minimize
constraints, callback=callback, **options)
File "/usr/local/lib/python2.7/site-packages/scipy/optimize/slsqp.py", line 383, in _minimize_slsqp
g = append(fprime(x),0.0)
File "/usr/local/lib/python2.7/site-packages/scipy/optimize/optimize.py", line 285, in function_wrapper
return function(*(wrapper_args + args))
File "/usr/local/lib/python2.7/site-packages/openmdao/drivers/scipy_optimizer.py", line 306, in _gradfunc
return_format='array')
File "/usr/local/lib/python2.7/site-packages/openmdao/core/driver.py", line 666, in calc_gradient
sparsity=sparsity)
File "/usr/local/lib/python2.7/site-packages/openmdao/core/problem.py", line 899, in calc_gradient
sparsity=sparsity)
File "/usr/local/lib/python2.7/site-packages/openmdao/core/problem.py", line 1261, in _calc_gradient_ln_solver
dx_mat = root.ln_solver.solve(rhs, root, mode)
File "/usr/local/lib/python2.7/site-packages/openmdao/solvers/scipy_gmres.py", line 104, in solve
callback=self.monitor)
File "<string>", line 2, in gmres
File "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/iterative.py", line 85, in non_reentrant
return func(*a, **kw)
File "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/iterative.py", line 478, in gmres
work[slice2] += sclr1*matvec(work[slice1])
File "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py", line 220, in matvec
y = self._matvec(x)
File "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py", line 460, in _matvec
return self.__matvec_impl(x)
File "/usr/local/lib/python2.7/site-packages/openmdao/solvers/scipy_gmres.py", line 162, in mult
system._sys_apply_linear(mode, ls_inputs=self.system._ls_inputs, vois=(voi,))
File "/usr/local/lib/python2.7/site-packages/openmdao/core/group.py", line 680, in _sys_apply_linear
gs_outputs=gs_outputs)
File "/usr/local/lib/python2.7/site-packages/openmdao/core/group.py", line 680, in _sys_apply_linear
gs_outputs=gs_outputs)
File "/usr/local/lib/python2.7/site-packages/openmdao/core/system.py", line 619, in _sys_apply_linear
self.apply_linear(self.params, self.unknowns, dparams, dunknowns, dresids, mode)
File "/usr/local/lib/python2.7/site-packages/openmdao/core/component.py", line 512, in apply_linear
mode)
File "/usr/local/lib/python2.7/site-packages/openmdao/core/system.py", line 726, in _apply_linear_jac
arg_vec[param] += J.T.dot(dresids._flat(unknown)).reshape(shape)
ValueError: shapes (6,108) and (36,) not aligned: 108 (dim 1) != 36 (dim 0)