OpenMDAO/OpenMDAO-Framework — Issue #678: Can't use object attributes in expressions
Author: JustinSGray
Created: 2011-10-28 17:14:15+00:00
State: open

Should be able to use the attributes of output objects in expressions

from openmdao.main.uncertain_distributions import NormalDistribution

from openmdao.main.api import Assembly, Component
from openmdao.lib.datatypes.api import Float, Slot
from openmdao.lib.drivers.api import CONMINdriver

class Dummy(Component):
x = Float(10,iotype="in")
y = Slot(NormalDistribution(),iotype="out")

def __init__(self):
super(Dummy,self).__init__()

self.y = NormalDistribution()

def execute(self):
print "TEST"
self.y = NormalDistribution(0,1)

class Sim(Assembly):

def __init__(self):
super(Sim,self).__init__()

self.add('d',Dummy())

self.add('driver',CONMINdriver())

self.driver.add_parameter('d.x',low=-100,high=100)
self.driver.add_objective('d.y.mu')

sim = Sim()
sim.run()

give error:

File "test.py", line 33, in
sim.run()
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/component.py", line 432, in run
self.execute()
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/assembly.py", line 264, in execute
self.driver.run(ffd_order=self.ffd_order, case_id=self._case_id)
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/component.py", line 414, in run
self._pre_execute(force)
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/component.py", line 314, in _pre_execute
self.check_config()
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/driver_uses_derivatives.py", line 78, in check_config
self.check_gradients()
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/driver_uses_derivatives.py", line 85, in check_gradients
driver_inputs, driver_outputs = self._list_driver_connections()
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/driver_uses_derivatives.py", line 67, in _list_driver_connections
if get_metadata(vname, 'iotype')=='out']
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/container.py", line 712, in get_metadata
return obj.get_metadata(restofpath, metaname)
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/container.py", line 711, in get_metadata
return self._get_metadata_failed(traitpath, metaname)
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/container.py", line 697, in _get_metadata_failed
AttributeError)
File "/Users/jsgray/openmdao/OpenMDAO-Framework/openmdao.main/src/openmdao/main/container.py", line 1282, in raise_exception
raise exception_class(full_msg)
AttributeError: d: Couldn't find metadata for trait y.mu