Hello, I've encountered a strange error in OpenMDAO v0.13.0 when attempting to run a problem. The script will run, giving outputs that suggest proper iterations of the drivers, but then halts and spits out

unexpected array size: new_size=1, got array with arr_size=0 Traceback (most recent call last): File "OptimizationTemplate.py", line 220, in <module> Loop.run() File "/Users/anon/Documents/SURE/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/component.py", line 559, in run self.execute() File "/Users/anon/Documents/SURE/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/assembly.py", line 725, in execute self._system.run(self.itername, case_uuid=self._case_uuid) File "/Users/anon/Documents/SURE/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/systems.py", line 1944, in run sub.run(iterbase, case_label=case_label, case_uuid=case_uuid) File "/Users/anon/Documents/SURE/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/systems.py", line 1168, in run self._comp.run(case_uuid=case_uuid) File "/Users/anon/Documents/SURE/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/driver.py", line 568, in run super(Driver, self).run(case_uuid) File "/Users/anon/Documents/SURE/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/component.py", line 559, in run self.execute() File "/Users/anon/Documents/SURE/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/driver.py", line 596, in execute self.run_iteration() File "/Users/anon/Documents/SURE/openmdao-0.13.0/lib/python2.7/site-packages/openmdao.lib-0.13.0-py2.7.egg/openmdao/lib/drivers/slsqpdriver.py", line 149, in run_iteration self._func, self._grad) slsqp.error: failed in converting 6th argument `xl' of slsqp.slsqp to C/Fortran array

Changing the driver to COBYLA and CONMIN produced similar errors.
My code is an implementation of ATC. Specifically of the problem

minimize: z1^2 + z2^2
subject to
Equality constraints (disciplines)
z1^2 = z3^2 + z4^(-2) + z5^2
z2^2 = z5^2 + z6^(-2) + z7^2
z3^2 = z8^2 + z9^(-2) + z10^(-2) + z11^2
z6^2 = z11^2 + z12^2 + z13^2 + z14^2
Inequality constraints
z3^(-2) + z4^2 - z5^2 <= 0
z5^2 + z6^(-2) - z7^2 <= 0
z8^2 + z9^2 - z11^2 <= 0
z8^(-2) + z10^2 - z11^2 <= 0
z11^2 + z12^(-2) - z13^2 <= 0
z11^2 + z12^2 - z14^2 <= 0

I can also post my components file if need be (though I have posted it before in the help forum) my code:

from openmdao.lib.datatypes.api import Float, Array
from openmdao.main.api import Assembly, set_as_top
from openmdao.lib.drivers.api import SLSQPdriver
import DisciplineTemplate
from numpy import ones, array, float

class Optimization0(Assembly):
    """my optimization template"""

    def configure(self):

        # Create Optimizer instance
        self.add('driver', SLSQPdriver())
        self.driver.accuracy = 1.0e-6

        # Create component instances
        self.add('Multipliers', DisciplineTemplate.Multipliers())

        # Iteration Hierarchy
        self.driver.workflow.add(['Multipliers'])

        # SLSQP Flags
        self.driver.iprint = 0

class Optimization1(Assembly):
    """my optimization template"""

    v = Array(array([1.0,1.0,1.0]), dtype=float, desc = "Penalty", iotype='in')
    w = Array(array([1.0,1.0,1.0]), dtype=float, desc = "Penalty", iotype='in')
    pR11 = Float(1.0, desc='Target', iotype='in')
    pR12 = Float(1.0, desc='Coupling', iotype='in')

    def configure(self):

        # Create Optimizer instance
        self.add('driver', SLSQPdriver())

        # Create component instances
        self.add('R01', DisciplineTemplate.R01())
        self.add('R02', DisciplineTemplate.R02())

        # Iteration Hierarchy
        self.driver.workflow.add(['R01', 'R02'])

        #x0[z4 z5 z7]
        self.driver.add_parameter('R01.z4', low=0., high=10.)
        self.driver.add_parameter(('R01.z5','R02.z5'), low = 0.0,   high=10.0)
        self.driver.add_parameter('R02.z7', low=0., high=10.)
        #T11=z3
        self.driver.add_parameter('R01.z3', low=0., high=10.)
        #T12=z6
        self.driver.add_parameter('R02.z6', low=0., high=10.)

        #Targets
        #self.create_passthrough('R01.z3', 'pT11')
        #self.create_passthrough('R02.z6', 'pT12')
        self.add('pT11', Float(1.0, iotype='in'))
        self.connect('R01.z3', 'pT11')
        self.add('pT12', Float(1.0, iotype='in'))
        self.connect('R02.z6', 'pT12')

        #Constraints
        self.driver.add_constraint('(R01.z3)**(-2) + (R01.z4)**(2) - (R01.z5)**(2) <= 0')
        self.driver.add_constraint('(R02.z5)**(2) + (R02.z6)**(-2) - (R02.z7)**(2) <= 0')

        # SLSQP Flags
        self.driver.iprint = 0

class Optimization2(Assembly):
    """my optimization template"""

    v = Array(array([1.0,1.0,1.0]), dtype=float, desc = "Penalty", iotype='in')
    w = Array(array([1.0,1.0,1.0]), dtype=float, desc = "Penalty", iotype='in')
    pT11 = Float(1.0, desc='Target', iotype='in')
    py12 = Float(1.0, desc='Coupling', iotype='in')

    def configure(self):

        # Create Optimizer instance
        self.add('driver', SLSQPdriver())

        # Create component instances
        self.add('R11', DisciplineTemplate.R11())

        # Iteration Hierarchy
        self.driver.workflow.add(['R11'])

        #x11[z8,z9,z10]
        self.driver.add_parameter('R11.z8', low=0., high=10.)
        self.driver.add_parameter('R11.z9', low=0., high=10.)
        self.driver.add_parameter('R11.z10', low=0., high=10.)
        #y11=z11
        self.driver.add_parameter('R11.z11', low=0., high=10.)

        #Out Targets
        #self.create_passthrough('R11.z3', 'pR11')
        self.add('pR11', Float(1.0, iotype='out'))
        self.connect('R11.z3', 'pR11')
        #self.create_passthrough('R11.z11', 'py11')
        self.add('py11', Float(1.0, iotype='out'))
        self.connect('R11.z11', 'py11')

        #Constraints
        self.driver.add_constraint('(R11.z8)**(2) + (R11.z9)**(2) - (R11.z11)**(2) <= 0')
        self.driver.add_constraint('(R11.z8)**(-2) + (R11.z10)**(2) - (R11.z11)**(2) <= 0')

        # SLSQP Flags
        self.driver.iprint = 0

class Optimization3(Assembly):
    """my optimization template"""

    v = Array(array([1.0,1.0,1.0]), dtype=float, desc = "Penalty", iotype='in')
    w = Array(array([1.0,1.0,1.0]), dtype=float, desc = "Penalty", iotype='in')
    pT12 = Float(1.0, desc='Target', iotype='in')
    py11 = Float(1.0, desc='Coupling', iotype='in')

    def configure(self):

        # Create Optimizer instance
        self.add('driver', SLSQPdriver())

        # Create component instances
        self.add('R12', DisciplineTemplate.R12())

        # Iteration Hierarchy
        self.driver.workflow.add(['R12'])

        #x12[z12,z13,z14]
        self.driver.add_parameter('R12.z12', low=0., high=10.)
        self.driver.add_parameter('R12.z13', low=0., high=10.)
        self.driver.add_parameter('R12.z14', low=0., high=10.)
        #y12=z11
        self.driver.add_parameter('R12.z11', low=0., high=10.)

        #Targets
        #self.create_passthrough('R12.z6', 'pR12')
        self.add('pR12', Float(1.0, iotype='out'))
        self.connect('R12.z6', 'pR12')
        #self.create_passthrough('R12.z11', 'py12')
        self.add('py12', Float(1.0, iotype='out'))
        self.connect('R12.z11', 'py12')

        #Constraints
        self.driver.add_constraint('(R12.z11)**(2) + (R12.z12)**(-2) - (R12.z13)**(2) <= 0')
        self.driver.add_constraint('(R12.z11)**(2) + (R12.z12)**(2) - (R12.z14)**(2) <= 0')

        # SLSQP Flags
        self.driver.iprint = 0

if __name__ == "__main__":

    #Hierarchy
    Loop = set_as_top(Optimization0())

    Loop.add('P0', Optimization1())
    Loop.driver.workflow.add('P0')

    Loop.add('P11', Optimization2())
    Loop.driver.workflow.add('P11')

    Loop.add('P12', Optimization3())
    Loop.driver.workflow.add('P12')

    #connections
    Loop.connect('[P11.pT11-P11.pR11,P12.pT12-P12.pR12,P12.py12-P11.py11]','Multipliers.c')

    Loop.connect('Multipliers.v','P0.v')
    Loop.connect('Multipliers.w','P0.w')
    Loop.connect('P11.pR11','P0.pR11')
    Loop.connect('P12.pR12','P0.pR12')

    Loop.connect('Multipliers.v','P11.v')
    Loop.connect('Multipliers.w','P11.w')
    Loop.connect('P0.pT11','P11.pT11')
    Loop.connect('P12.py12','P11.py12')

    Loop.connect('Multipliers.v','P12.v')
    Loop.connect('Multipliers.w','P12.w')
    Loop.connect('P0.pT12','P12.pT12')
    Loop.connect('P11.py11','P12.py11')

    #Objectives
    Loop.driver.add_objective('(P0.pR11-P0.pT11)**2 + (P0.pR12-P0.pT12)**2 + (P12.py12-P11.py11)**2')

    Loop.P0.driver.add_objective('(R01.z1-0.0)**2 + (R02.z2-0.0)**2 + v[0]*(R01.z3-pR11) + v[1]*(R02.z6-pR12) + w[0]*w[0]*(R01.z3-pR11)**2 + w[1]*w[1]*(R02.z6-pR12)**2')

    Loop.P11.driver.add_objective('v[0]*(pT11-R11.z3) + v[2]*(py12-R11.z11) + w[0]*w[0]*(pT11-R11.z3)**2 + w[2]*w[2]*(py12-R11.z11)**2')

    Loop.P12.driver.add_objective('v[1]*(pT12-R12.z6) + v[2]*(R12.z11-py11) + w[1]*w[1]*(pT12-R12.z6)**2 + w[2]*w[2]*(R12.z11-py11)**2')

    import time
    tt = time.time()

    Loop.run()

    official=[2.80,3.03,2.35,0.76,0.87,2.79,0.95,0.97,0.87,0.80,1.30,0.84,1.75,1.54]

    z=ones(14)
    z[0]=Loop.P0.R01.z1
    z[1]=Loop.P0.R02.z2
    z[2]=Loop.P0.R01.z3
    z[3]=Loop.P0.R01.z4
    z[4]=Loop.P0.R01.z5
    z[5]=Loop.P0.R02.z6
    z[6]=Loop.P0.R02.z7
    z[7]=Loop.P11.R11.z8
    z[8]=Loop.P11.R11.z9
    z[9]=Loop.P11.R11.z10
    z[10]=Loop.P11.R11.z11
    z[11]=Loop.P12.R12.z12
    z[12]=Loop.P12.R12.z13
    z[13]=Loop.P12.R12.z14

    for i in range(0, 14):
        print "\t\t z%d & %f & %f \\\\" % (i+1, z[i],official[i])

    print "\n"

    for i in range(0, 14):
        print "z%d=%f vs official value: %f" % (i+1, z[i], official[i])

    print "\nElapsed time: ", time.time()-tt, "seconds \n"

    print "Function calls R01: %d, R02: %d, R11: %d, R12: %d"%(Loop.P0.R01.exec_count, Loop.P0.R02.exec_count, Loop.P11.R11.exec_count, Loop.P12.R12.exec_count)

asked 04 Aug '15, 16:32

Grasshopper's gravatar image

Grasshopper
3719

edited 05 Aug '15, 09:00

justingray's gravatar image

justingray ♦♦
1.8k13


The top optimization (assembly Optimization0) has no parameters. You need to add some parameters to run any optimization-type driver. We probably should put in a check for that so that it gives a clear error message.

link

answered 06 Aug '15, 09:51

Kenneth%20T%20Moore's gravatar image

Kenneth T Moore ♦
1.1k1212

edited 06 Aug '15, 09:51

Thanks, adding a dummy variable to the driver for the main iteration loop (Optimization0) has suppressed this error.

(06 Aug '15, 15:10) Grasshopper Grasshopper's gravatar image

without being able to run your models, its this is just a guess. You can get that error if your codes somehow fail to return values. This could happen if you have some kind of other error being raised that its halting execution.

link

answered 05 Aug '15, 09:12

justingray's gravatar image

justingray ♦♦
1.8k13

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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

Tags:

×43
×39
×17

Asked: 04 Aug '15, 16:32

Seen: 2,198 times

Last updated: 06 Aug '15, 15:10

powered by OSQA