def configure(self):

        self.add('d1', Discipline1_WithDerivatives())
        self.d1.x1 = 1.0
        self.d1.y1 = 1.0
        self.d1.y2 = 1.0
        self.d1.z1 = 5.0
        self.d1.z2 = 2.0

        self.add('d2', Discipline2_WithDerivatives())
        self.d2.y1 = 1.0
        self.d2.y2 = 1.0
        self.d2.z1 = 5.0
        self.d2.z2 = 2.0

        self.add('P1', Paraboloid())
        self.add('P2', Paraboloid())

        self.connect('d1.y1', 'd2.y1')
        self.connect('P1.f_xy', 'd1.x1')
        self.connect('d1.y1', 'P2.x')
        self.connect('d2.y2', 'P2.y')

        self.add('driver', SimpleDriver())
        self.add('driver2', Driver())
        self.add('subdriver', NewtonSolver())
        self.driver.workflow.add(['P1', 'subdriver', 'P2'])
        self.subdriver.workflow.add(['d1', 'd2'])

        self.subdriver.add_parameter('d1.y2', low=-1e99, high=1e99)
        self.subdriver.add_constraint('d1.y2 = d2.y2')

        self.driver.add_parameter('P1.x', low=-1e99, high=1e99)
        self.driver.add_constraint('P2.f_xy < 0')
    def configure(self):
        self.add('paraboloid', Paraboloid())

        self.add('driver', DOEdriver())
        self.driver.log_level = logging.INFO

        # Configure the generator.
        self.driver.DOEgenerator = MonteCarlo()
        self.driver.DOEgenerator.num_samples = 5000
        self.driver.DOEgenerator.dist_types = {
            'Default':random.uniform, 'y':random.standard_normal}
        self.driver.DOEgenerator.dist_args = {'Default':[0, 1], 'y':[]}
        self.driver.DOEgenerator.parameters = ['x', 'y']

        # Configure driver parameters.
        self.driver.add_parameter('paraboloid.x', low=0, high=1)
        self.driver.add_parameter('paraboloid.y', low=0, high=1)

        #tell the DOEdriver to also record f_xy.
        self.driver.add_response('paraboloid.f_xy')

        #Simple recorder which stores the cases in memory.
        self.recorders = [ListCaseRecorder(),]

        self.driver.workflow.add('paraboloid')
예제 #3
0
    def configure(self):

        self.add('paraboloid', Paraboloid())

        self.add('driver', DOEdriver())
        #There are a number of different kinds of DOE available in openmdao.lib.doegenerators
        self.driver.DOEgenerator = MonteCarlo()
        self.driver.DOEgenerator.num_samples = 5000
        self.driver.DOEgenerator.dist_types = {
            'Default': random.uniform,
            'y': random.standard_normal
        }
        self.driver.DOEgenerator.dist_args = {'Default': [0, 1], 'y': []}
        self.driver.DOEgenerator.parameters = ['x', 'y']

        #DOEdriver will automatically record the values of any parameters for each case
        self.driver.add_parameter('paraboloid.x', low=0, high=1)
        self.driver.add_parameter('paraboloid.y', low=0, high=1)
        #tell the DOEdriver to also record any other variables you want to know for each case
        self.driver.case_outputs = [
            'paraboloid.f_xy',
        ]

        #Simple recorder which stores the cases in memory.
        self.driver.recorders = [
            ListCaseRecorder(),
        ]

        self.driver.workflow.add('paraboloid')
예제 #4
0
    def __init__(self):
        """ Creates a new Assembly containing a Paraboloid and an optimizer"""

        # pylint: disable-msg=E1101

        super(OptimizationConstrained, self).__init__()

        # Create Paraboloid component instances
        self.add('paraboloid', Paraboloid())

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

        # Driver process definition
        self.driver.workflow.add('paraboloid')

        # CONMIN Flags
        self.driver.iprint = 0
        self.driver.itmax = 30
        self.driver.fdch = .000001
        self.driver.fdchm = .000001

        # CONMIN Objective
        self.driver.add_objective('paraboloid.f_xy')

        # CONMIN Design Variables
        self.driver.add_parameter('paraboloid.x', low=-50., high=50.)
        self.driver.add_parameter('paraboloid.y', low=-50., high=50.)

        # CONMIN Constraints
        self.driver.add_constraint('paraboloid.x-paraboloid.y >= 15.0')
    def test_linearGS_single_comp(self):

        top = set_as_top(Assembly())
        top.add('comp', Paraboloid())
        top.add('driver', SimpleDriver())
        top.driver.workflow.add(['comp'])
        top.driver.add_parameter('comp.x', low=-1000, high=1000)
        top.driver.add_parameter('comp.y', low=-1000, high=1000)
        top.driver.add_objective('comp.f_xy')

        top.driver.gradient_options.lin_solver = 'linear_gs'
        top.driver.gradient_options.maxiter = 1

        top.comp.x = 3
        top.comp.y = 5
        top.run()

        self.assertEqual(top.comp.f_xy, 93.)
        self.assertEqual(top._pseudo_0.out0, 93.)

        J = top.driver.workflow.calc_gradient(inputs=['comp.x', 'comp.y'],
                                              outputs=['comp.f_xy'],
                                              mode='forward')

        assert_rel_error(self, J[0, 0], 5.0, 0.0001)
        assert_rel_error(self, J[0, 1], 21.0, 0.0001)

        J = top.driver.workflow.calc_gradient(inputs=['comp.x', 'comp.y'],
                                              mode='adjoint')

        assert_rel_error(self, J[0, 0], 5.0, 0.0001)
        assert_rel_error(self, J[0, 1], 21.0, 0.0001)
    def configure(self):
        """ Creates a new Assembly containing a Paraboloid and an optimizer"""

        # pylint: disable=E1101

        # Create Paraboloid component instances
        self.add('paraboloid', Paraboloid())

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

        # Driver process definition
        self.driver.workflow.add('paraboloid')

        # CONMIN Objective
        self.driver.add_objective('paraboloid.f_xy')

        # CONMIN Design Variables
        self.driver.add_parameter('paraboloid.x', low=-50., high=50.)
        self.driver.add_parameter('paraboloid.y', low=-50., high=50.)

        # CONMIN Constraints
        self.driver.add_constraint('paraboloid.x-paraboloid.y >= 15.0')

        self.driver.print_results = False
예제 #7
0
파일: doe2.py 프로젝트: sebasanper/doe
 def configure(self):
     self.add('paraboloid', Paraboloid())
     doe = self.add('driver', DOEdriver())
     doe.DOEgenerator = Uniform(num_samples=1000)
     doe.add_parameter('paraboloid.x', low=-50, high=50)
     doe.add_parameter('paraboloid.y', low=-50, high=50)
     doe.case_outputs = ['paraboloid.f_xy']
     doe.workflow.add('paraboloid')
예제 #8
0
    def configure(self):
        self.add('paraboloid', Paraboloid())

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

        self.driver.add_parameter('paraboloid.x', low=-50, high=50)
        self.driver.add_parameter('paraboloid.y', low=-50, high=50)

        self.driver.add_objective('paraboloid.f_xy')

        self.recorders = [ListCaseRecorder()]
예제 #9
0
    def configure(self):
        self.add('paraboloid', Paraboloid())

        self.add('driver', DOEdriver())
        self.driver.DOEgenerator = Uniform(1000)

        self.driver.add_parameter('paraboloid.x', low=-50, high=50)
        self.driver.add_parameter('paraboloid.y', low=-50, high=50)

        self.driver.add_response('paraboloid.f_xy')

        self.recorders = [JSONCaseRecorder(out='doe.json')]
예제 #10
0
    def configure(self):
        """ Creates a new Assembly containing a chain of Paraboloid components"""

        self.add("paraboloid", Paraboloid())
        self.add("optimizer", SLSQPdriver())

        self.optimizer.add_parameter("paraboloid.x", low='-50', high='50')
        self.optimizer.add_parameter("paraboloid.y", low='-50', high='50')

        self.optimizer.add_objective("paraboloid.f_xy")

        self.optimizer.workflow.add('paraboloid')
    def test_petsc_ksp_single_comp_dict(self):

        top = set_as_top(Assembly())
        top.add('comp', Paraboloid())
        top.add('driver', SimpleDriver())
        top.driver.workflow.add(['comp'])
        top.driver.add_parameter('comp.x', low=-1000, high=1000)
        top.driver.add_parameter('comp.y', low=-1000, high=1000)
        top.driver.add_objective('comp.f_xy')

        top.driver.gradient_options.lin_solver = 'petsc_ksp'

        top.comp.x = 3
        top.comp.y = 5
        top.run()

        self.assertEqual(top.comp.f_xy, 93.)
        self.assertEqual(top._pseudo_0.out0, 93.)

        J = top.driver.workflow.calc_gradient(inputs=['comp.x', 'comp.y'],
                                              outputs=['comp.f_xy'],
                                              mode='forward',
                                              return_format='dict')

        assert_rel_error(self, J['comp.f_xy']['comp.x'][0][0], 5.0, 0.0001)
        assert_rel_error(self, J['comp.f_xy']['comp.y'][0][0], 21.0, 0.0001)

        J = top.driver.workflow.calc_gradient(inputs=['comp.x', 'comp.y'],
                                              mode='adjoint',
                                              return_format='dict')

        assert_rel_error(self, J['_pseudo_0.out0']['comp.x'][0][0], 5.0,
                         0.0001)
        assert_rel_error(self, J['_pseudo_0.out0']['comp.y'][0][0], 21.0,
                         0.0001)

        # Make sure we aren't add-scattering out p vector

        top.run()
        J = top.driver.workflow.calc_gradient(inputs=['comp.x', 'comp.y'],
                                              mode='forward',
                                              return_format='dict')
        assert_rel_error(self, J['_pseudo_0.out0']['comp.x'][0][0], 5.0,
                         0.0001)
        assert_rel_error(self, J['_pseudo_0.out0']['comp.y'][0][0], 21.0,
                         0.0001)
예제 #12
0
 def configure(self):
     
     self.add('paraboloid',Paraboloid())
     
     self.add('driver',DOEdriver())
     #There are a number of different kinds of DOE available in openmdao.lib.doegenerators
     self.driver.DOEgenerator = FullFactorial(10) #Full Factorial DOE with 10 levels for each variable
     
     #DOEdriver will automatically record the values of any parameters for each case
     self.driver.add_parameter('paraboloid.x',low=-50,high=50)
     self.driver.add_parameter('paraboloid.y',low=-50,high=50)
     #tell the DOEdriver to also record any other variables you want to know for each case
     self.driver.case_outputs = ['paraboloid.f_xy',]
     
     #Simple recorder which stores the cases in memory. 
     self.driver.recorders = [ListCaseRecorder(),]
     
     self.driver.workflow.add('paraboloid')
예제 #13
0
    def configure(self):
        self.add('paraboloid', Paraboloid())

        self.add('driver', DOEdriver())
        # There are a number of different kinds of DOE available in openmdao.lib.doegenerators
        # self.driver.DOEgenerator = FullFactorial(10) #Full Factorial DOE with 10 levels for each variable
        self.driver.DOEgenerator = Uniform(1000)

        # DOEdriver will automatically record the values of any parameters for each case
        self.driver.add_parameter('paraboloid.x', low=-50, high=50)
        self.driver.add_parameter('paraboloid.y', low=-50, high=50)
        # tell the DOEdriver to also record any other variables you want to know for each case
        self.driver.add_response('paraboloid.f_xy')

        self.recorders = [
            JSONCaseRecorder('doe.json'),
            BSONCaseRecorder('doe.bson')
        ]
예제 #14
0
 def configure(self):
     
     self.add('p1pre', Paraboloid())
     #self.add('p1', Paraboloid())
     self.add('down', Downstream())
     
     self.add('driver', SimpleDriver())
     self.add('sens', SensitivityDriver())
     
     self.driver.add_parameter('p1pre.x', low=-100, high=101)
     self.driver.add_objective('down.y')
     
     self.sens.add_parameter('p1pre.x', low=100, high=101)
     self.sens.add_objective('p1pre.f_xy')
     self.connect('sens.dF', 'down.x')
     
     self.driver.workflow.add(['sens', 'down'])
     self.sens.workflow.add(['p1pre'])
예제 #15
0
    def configure(self):

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

        # Create Paraboloid component instances
        self.add('paraboloid', Paraboloid())

        # Iteration Hierarchy
        self.driver.workflow.add('paraboloid')

        # SLSQP Flags
        self.driver.iprint = 0

        # Objective
        self.driver.add_objective('paraboloid.f_xy')

        # Design Variables
        self.driver.add_parameter('paraboloid.x', low=-50., high=50.)
        self.driver.add_parameter('paraboloid.y', low=-50., high=50.)

        # SQLSQP Flags
        self.driver.iprint = 1
예제 #16
0
    def configure(self):
        """ Creates a new Assembly containing a Paraboloid and an optimizer"""

        # pylint: disable-msg=E1101

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

        # Create Paraboloid component instances
        self.add('paraboloid', Paraboloid())

        # Driver process definition
        self.driver.workflow.add('paraboloid')

        # SQLSQP Flags
        self.driver.iprint = 0

        # Objective
        self.driver.add_objective('paraboloid.f_xy')

        # Design Variables
        self.driver.add_parameter('paraboloid.x', low=-50., high=50.)
        self.driver.add_parameter('paraboloid.y', low=-50., high=50.)
예제 #17
0
파일: cases.py 프로젝트: michaelXDzhang/doe
    def configure(self):
        """ Creates counter new Assembly containing counter Paraboloid and an optimizer"""

        # Create Paraboloid component instances
        self.add('paraboloid', Paraboloid())

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

        # Driver process definition
        self.driver.workflow.add('paraboloid')

        # Optimzier Flags
        self.driver.iprint = 0

        # Objective
        self.driver.add_objective('paraboloid.f_xy')

        # Design Variables
        self.driver.add_parameter('paraboloid.x', low=-50., high=50.)
        self.driver.add_parameter('paraboloid.y', low=-50., high=50.)

        # Constraints
        self.driver.add_constraint('paraboloid.x-paraboloid.y >= 15.0')
예제 #18
0
# In[ ]:

get_ipython().magic(u'matplotlib inline')
import pylab as plt
import numpy as np
from fusedwind.fused_helper import *

# In[ ]:


def contour_plot(func):
    rose = func()
    XS, YS = plt.meshgrid(np.linspace(-2, 2, 20), np.linspace(-2, 2, 20))
    ZS = np.array([
        rose(x1=x, x2=y).f_xy for x, y in zip(XS.flatten(), YS.flatten())
    ]).reshape(XS.shape)
    plt.contourf(XS, YS, ZS, 50)
    plt.colorbar()


contour_plot(Paraboloid())

df.plot(x='paraboloid.x', y='paraboloid.y', ls='', marker='.')
plt.draw()

# In[ ]:

plt.show()

# In[ ]:
    def configure(self):
        """ Creates a new Assembly containing a chain of Paraboloid components"""

        self.add("paraboloid", Paraboloid())