def test_initial_run(self): # Test the fix that puts a run_iteration call # at the top of the start_iteration method class MyComp(Component): x = Float(0.0, iotype='in', low=-10, high=10) xx = Float(0.0, iotype='in', low=-10, high=10) f_x = Float(iotype='out') y = Float(iotype='out') def execute(self): if self.xx != 1.0: self.raise_exception("Lazy", RuntimeError) self.f_x = 2.0*self.x self.y = self.x @add_delegate(HasParameters) class SpecialDriver(Driver): implements(IHasParameters) def execute(self): self.set_parameters([1.0]) top = set_as_top(Assembly()) top.add('comp', MyComp()) top.add('driver', COBYLAdriver()) top.driver.iprint = 0 top.add('subdriver', SpecialDriver()) top.driver.workflow.add('subdriver') top.subdriver.workflow.add('comp') top.subdriver.add_parameter('comp.xx') top.driver.add_parameter('comp.x') top.driver.add_constraint('comp.y > 1.0') top.driver.add_objective('comp.f_x') top.run()
def setUp(self): self.top = set_as_top(Assembly()) self.top.add('driver', COBYLAdriver()) self.top.add('comp', OptRosenSuzukiComponent()) self.top.driver.workflow.add('comp') self.top.driver.iprint = 0