In trying to run an assembly I have set up, I keep getting the following error. I have tried reproducing the error in a simple case but have not succeeded. Placing print statements revealed that the __Init__ method and the configure method of the assembly are both run to completion, and the __init__ method of each component runs as well, but none of the components' execute methods are entered. I have not been able to figure out what is causing this error based on the traceback, but I am hoping that one of you will have an idea of what to check or what may be causing this error. I have included both the error trace and my simple example that mimics the code structure I am using (but does not cause the error). While this assembly is intended to be run as an optimization, I am currently trying to run it a single time with the standard driver.

What are the likely causes of this error and what is a good what to find what is causing it?

Error Traceback

Traceback (most recent call last):
  File "/Users/user/Documents/Project/", line 118, in <module>
  File "/Users/user/OpenMDAO/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/", line 549, in run
  File "/Users/user/OpenMDAO/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/", line 469, in _pre_execute
  File "/Users/user/OpenMDAO/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/", line 1704, in _setup
  File "/Users/user/OpenMDAO/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/", line 1166, in setup_scatters
  File "/Users/user/OpenMDAO/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/", line 1739, in setup_scatters
  File "/Users/user/OpenMDAO/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/", line 1644, in _get_scatter_idxs
    src_idxs = offset + arg_idxs
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

Example of structure (this example does not cause the error)

from openmdao.main.api import Assembly, Component
from openmdao.lib.datatypes.api import Float, Array, List
from openmdao.lib.drivers.api import DOEdriver, SLSQPdriver, COBYLAdriver, CaseIteratorDriver
from pyopt_driver.pyopt_driver import pyOptDriver

import numpy as np

class component1(Component):

    x = Float(iotype='in')
    # y = Float(iotype='in', missing_deriv_policy='assume_zero')
    y = Float(iotype='in')
    term1 = Float(iotype='out')
    a = Float(iotype='in', default_value=1)
    def execute(self):
        x = self.x
        a = self.a

        term1 = a*x**2
        self.term1 = term1

        print "In comp1",, self.a, self.x, self.term1

    def list_deriv_vars(self):
        return ('x',), ('term1',)

    def provideJ(self):

        x = self.x
        a = self.a
        dterm1_dx = 2.*a*x

        J = np.array([[dterm1_dx]])
        print 'In comp1, J = %s' % J

        return J

class component2(Component):

    x = Float(iotype='in')
    y = Float(iotype='in')
    term1 = Float(iotype='in')
    f = Float(iotype='out')

    def execute(self):

        y = self.y
        x = self.x
        term1 = self.term1
        f = term1 + x + y**2

        self.f = f
        print "In comp2",, self.x, self.y, self.term1, self.f

class summer(Component):

    total = Float(iotype='out', desc='sum of all f values')

    def __init__(self, size):
        super(summer, self).__init__()
        self.size = size

        self.add('fs', Array(np.ones(size), iotype='in', desc='f values from all cases'))

    def execute(self): = sum(self.fs)
        print 'In summer, fs = %s and total = %s' % (self.fs,

class assembly(Assembly):

    x = Float(iotype='in')
    y = Float(iotype='in')
    total = Float(iotype='out')

    def __init__(self, size):

        super(assembly, self).__init__()

        self.size = size

        self.add('a_vals', Array(np.zeros(size), iotype='in', dtype='float'))

        print 'in init a_vals = %s' % self.a_vals

    def configure(self):

        # self.add('driver', SLSQPdriver())
        # self.add('driver', pyOptDriver())
        # self.driver.optimizer = 'SLSQP'
        # self.driver.pyopt_diff = True

        #create this first, so we can connect to it
        self.add('summer', summer(size=len(self.a_vals)))
        self.connect('', 'total')

        print 'in configure a_vals = %s' % self.a_vals

        # create instances of components
        for i in range(0, self.size):
            c1 = self.add('comp1_%d'%i, component1())
            c1.missing_deriv_policy = 'assume_zero'

            c2 = self.add('comp2_%d'%i, component2())
            self.connect('a_vals[%d]' % i, 'comp1_%d.a' % i)
            self.connect('x', ['comp1_%d.x'%i, 'comp2_%d.x'%i])
            self.connect('y', ['comp1_%d.y'%i, 'comp2_%d.y'%i])
            self.connect('comp1_%d.term1'%i, 'comp2_%d.term1'%i)

            self.connect('comp2_%d.f'%i, 'summer.fs[%d]'%i)

            self.driver.workflow.add(['comp1_%d'%i, 'comp2_%d'%i])


        # set up main driver (optimizer)
        # self.driver.iprint = 1
        # self.driver.maxiter = 100
        # self.driver.accuracy = 1.0e-6
        # self.driver.add_parameter('x', low=-5., high=5.)
        # self.driver.add_parameter('y', low=-5., high=5.)
        # self.driver.add_objective('')

if __name__ == "__main__":
    """ the result should be -1 at (x, y) = (-0.5, 0) """

    import time
    from openmdao.main.api import set_as_top
    a_vals = np.array([1., 1., 1., 1.])
    test = assembly(len(a_vals))
    test.a_vals = a_vals
    print test.a_vals
    test.x = -0.5
    test.y = 0.

    tt = time.time()

    print "Elapsed time: ", time.time()-tt, "seconds"

    print 'result = ',
    print '(x, y) = (%s, %s)' % (test.x, test.y)

asked 23 Jul '15, 14:37

jthomas's gravatar image


edited 23 Jul '15, 14:44

It's tough to answer this without having some code to debug. For some reason during the creation of the scatters, a get_distrib_idxs() call on a subsystem is returning None instead of an index array. Are any of your components overriding get_distrib_idxs()? Could be a framework bug too, but it's hard to tell. You could try printing out node and after line 1736 in when arg_idxs comes back None. At least that would tell you which variable and which system are having the issue.


answered 23 Jul '15, 15:46

naylorb's gravatar image


Thank you for your response, sorry for being slow to follow up. I have been in the process of moving.

Thanks to your print statement suggestions I was able to duplicate the error in my simple case and find a solution to the problem.

How do I know if a component is overriding get_distrib_idxs(), and what does that mean?

(28 Jul '15, 17:14) jthomas jthomas's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 23 Jul '15, 14:37

Seen: 11,360 times

Last updated: 28 Jul '15, 17:14

powered by OSQA