Ejemplo n.º 1
0
 def test_CSVCaseRecorder_messages(self):
     rec = CSVCaseRecorder(filename=self.filename)
     rec.startup()
     rec.record(Case(inputs=[('comp1.x',2.0),('comp1.y',4.3),('comp2.x',1.9)]))
     try:
         rec.record(Case(inputs=[('comp1.x',2.0),('comp2.x',1.9)]))
     except Exception as err:
         self.assertEqual(str(err), "number of data points doesn't match header size in CSV recorder")
     else:
         self.fail("Exception expected")
     finally:
         rec.close()
Ejemplo n.º 2
0
    def test_inoutCSV_empty_inputs(self):
        
        # now create some Cases
        outputs = ['comp1.z']
        cases = []
        for i in range(10):
            cases.append(Case(inputs=[], outputs=outputs, label='case%s'%i))
        self.top.driver.iterator = ListCaseIterator(cases)
            
        self.top.driver.recorders = [CSVCaseRecorder(filename=self.filename)]
        self.top.run()

        # now use the CSV recorder as source of Cases
        self.top.driver.iterator = self.top.driver.recorders[0].get_iterator()
        
        sout = StringIO.StringIO()
        self.top.driver.recorders = [DumpCaseRecorder(sout)]
        self.top.run()
        expected = [
            'Case: case8',
            '   uuid: ad4c1b76-64fb-11e0-95a8-001e8cf75fe',
            '   outputs:',
            '      comp1.z: 0.0',
            ]
        lines = sout.getvalue().split('\n')
        for index, line in enumerate(lines):
            if line.startswith('Case: case8'):
                for i in range(len(expected)):
                    if expected[i].startswith('   uuid:'):
                        self.assertTrue(lines[index+i].startswith('   uuid:'))
                    else:
                        self.assertEqual(lines[index+i], expected[i])
                break
        else:
            self.fail("couldn't find the expected Case")
Ejemplo n.º 3
0
 def test_close(self):
     self.top.driver.recorders = [CSVCaseRecorder(filename=self.filename)]
     self.top.run()
     case = Case(inputs=[('comp2.a_slot', None)])
     assert_raises(self, 'self.top.driver.recorders[0].record(case)',
                   globals(), locals(), RuntimeError,
                   'Attempt to record on closed recorder')
Ejemplo n.º 4
0
    def test_csvbackup(self):

        # Cleanup from any past failures
        parts = self.filename.split('.')
        backups = glob.glob(''.join(parts[:-1]) + '_*')
        for item in backups:
            os.remove(item)

        self.top.recorders = [CSVCaseRecorder(filename=self.filename)]

        # Run twice, two backups.
        self.top.recorders[0].num_backups = 2
        self.top.run()
        # Granularity on timestamp is 1 second.
        time.sleep(1)
        self.top.run()
        backups = glob.glob(''.join(parts[:-1]) + '_*')
        self.assertEqual(len(backups), 2)

        # Set backups to 1 and rerun. Should delete down to 1 backup.
        self.top.recorders[0].num_backups = 1
        self.top.run()
        backups = glob.glob(''.join(parts[:-1]) + '_*')
        self.assertEqual(len(backups), 1)

        for item in backups:
            os.remove(item)
        backups = glob.glob(''.join(parts[:-1]) + '_*')

        self.top.recorders[0].num_backups = 0
Ejemplo n.º 5
0
    def test_inoutCSV(self):
        self.top = set_as_top(TestAssembly())
        self.top.recorders = [CSVCaseRecorder(filename=self.filename)]
        self.top.run()

        # now use the CSV recorder as source of Cases
        cases = [case for case in self.top.recorders[0].get_iterator()]
Ejemplo n.º 6
0
 def test_CSVCaseRecorder_messages(self):
     rec = CSVCaseRecorder(filename=self.filename)
     rec.startup()
     rec.record(
         Case(inputs=[('comp1.x', 2.0), ('comp1.y', 4.3), ('comp2.x',
                                                           1.9)]))
     try:
         rec.record(Case(inputs=[('comp1.x', 2.0), ('comp2.x', 1.9)]))
     except Exception as err:
         self.assertEqual(
             str(err),
             "number of data points doesn't match header size in CSV recorder"
         )
     else:
         self.fail("Exception expected")
     finally:
         rec.close()
Ejemplo n.º 7
0
    def test_inoutCSV_delimiter(self):
        
        #Repeat test above using semicolon delimiter and ' as quote char.
        
        self.top.driver.recorders = [CSVCaseRecorder(filename=self.filename, delimiter=';', \
                                                     quotechar="'")]
        self.top.run()

        attrs = self.top.driver.recorders[0].get_attributes()
        self.assertTrue("Inputs" in attrs.keys())
        self.assertTrue({'name': 'filename',
                         'type': 'str',
                         'connected': '',
                         'value': 'openmdao_test_csv_case_iterator.csv',
                         'desc': 'Name of the CSV file to be output.'} in attrs['Inputs'])
        self.assertTrue({'name': 'append',
                         'type': 'bool',
                         'connected': '',
                         'value': 'False',
                         'desc': 'Set to True to append to the existing CSV file.'} in attrs['Inputs'])
        self.assertTrue({'name': 'delimiter',
                         'type': 'str',
                         'connected': '',
                         'value': ';',
                         'desc': 'CSV delimiter. Default is ",".'} in attrs['Inputs'])
        

        # now use the DB as source of Cases
        self.top.driver.iterator = self.top.driver.recorders[0].get_iterator()
        
        sout = StringIO.StringIO()
        self.top.driver.recorders = [DumpCaseRecorder(sout)]
        self.top.run()
        expected = [
            'Case: case8',
            '   uuid: ad4c1b76-64fb-11e0-95a8-001e8cf75fe',
            '   inputs:',
            '      comp1.x: 8.1',
            '      comp1.x_array[1]: 99.88',
            '      comp1.y: 16.1',
            '   outputs:',
            "      comp1.a_array[2]: 5.5",
            "      comp1.a_string: Hello',;','",
            '      comp1.z: 24.2',
            '      comp2.z: 25.2',
            ]
        lines = sout.getvalue().split('\n')
        for index, line in enumerate(lines):
            if line.startswith('Case: case8'):
                for i in range(len(expected)):
                    if expected[i].startswith('   uuid:'):
                        self.assertTrue(lines[index+i].startswith('   uuid:'))
                    else:
                        self.assertEqual(lines[index+i], expected[i])
                break
        else:
            self.fail("couldn't find the expected Case")
Ejemplo n.º 8
0
    def test_sorting(self):
        # Make sure outputs are sorted

        rec = CSVCaseRecorder(filename=self.filename)
        rec.num_backups = 0
        rec.startup()
        rec.register(self, ['comp1.x', 'comp1.y', 'comp2.x', ], [])
        rec.record(self, [2.0, 4.3, 1.9], [], None, '', '')
        rec.close()

        outfile = open(self.filename, 'r')
        csv_data = outfile.readlines()
        outfile.close()

        line = '"timestamp","/INPUTS","comp1.x","comp1.y","comp2.x",' \
               '"/OUTPUTS","/METADATA","uuid","parent_uuid","msg"\r\n'
        self.assertEqual(csv_data[0], line)
        line = '"",2.0,4.3,1.9,"","","","",""\r\n'
        self.assertTrue(csv_data[1].endswith(line))
Ejemplo n.º 9
0
 def test_save(self):
     # Check that a recorder can be saved to an egg.
     self.top.recorders = [CSVCaseRecorder(filename=self.filename)]
     self.top.recorders[0].num_backups = 0
     self.top.recorders[0].startup()
     try:
         self.top.save_to_egg('top', '1')
     finally:
         for name in glob.glob('top*.egg'):
             os.remove(name)
Ejemplo n.º 10
0
    def test_inoutCSV(self):

        #This test runs some cases, puts them in a CSV file using a
        #CSVCaseRecorder, then runs the model again using the same cases,
        #pulled out of the CSV file by a CSVCaseIterator.  Finally the cases
        #are dumped to a string after being run for the second time.

        self.top.recorders = [CSVCaseRecorder(filename=self.filename)]
        self.top.recorders[0].num_backups = 0
        self.top.run()

        # now use the CSV recorder as source of Cases
        cases = [case for case in self.top.recorders[0].get_iterator()]
Ejemplo n.º 11
0
    def test_sorting(self):
        # Make sure outputs are sorted

        rec = CSVCaseRecorder(filename=self.filename)
        rec.num_backups = 0
        rec.startup()
        rec.record(
            Case(inputs=[('comp1.x', 2.0), ('comp1.y', 4.3), ('comp2.x',
                                                              1.9)]))
        rec.close()

        outfile = open(self.filename, 'r')
        csv_data = outfile.readlines()
        outfile.close()

        line = '"label","/INPUTS","comp1.x","comp1.y","comp2.x","/OUTPUTS","/METADATA","retries","max_retries","parent_uuid","msg"\r\n'
        self.assertEqual(csv_data[0], line)
        line = '"","",2.0,4.3,1.9,"","","","","",""\r\n'
        self.assertEqual(csv_data[1], line)
Ejemplo n.º 12
0
    def test_iterate_twice(self):

        self.top.driver.recorders = [CSVCaseRecorder(filename=self.filename)]
        self.top.run()

        data = self.top.driver.recorders[0].get_iterator()

        for case in data:
            keys1 = case.keys()

        for case in data:
            keys2 = case.keys()

        self.assertEqual(keys1, keys2)
Ejemplo n.º 13
0
    def test_inoutCSV_delimiter(self):

        # Repeat test above using semicolon delimiter and ' as quote char.

        self.top = set_as_top(TestAssembly())
        self.top.recorders = [
            CSVCaseRecorder(filename=self.filename,
                            delimiter=';',
                            quotechar="'")
        ]
        self.top.run()

        # now use the CSV recorder as source of Cases
        cases = [case for case in self.top.recorders[0].get_iterator()]
Ejemplo n.º 14
0
 def test_close(self):
     self.top.recorders = [CSVCaseRecorder(filename=self.filename)]
     self.top.recorders[0].num_backups = 0
     self.top.run()
     outputs = [
         'comp1.z', 'comp2.z', 'comp1.a_string', 'comp1.a_array[2]',
         'driver.workflow.itername'
     ]
     inputs = ['comp1.x', 'comp1.y', 'comp1.x_array[1]', 'comp1.b_bool']
     self.top.recorders[0].register(self, inputs, outputs)
     outputs = [0, 0, 'world', 0, '1']
     inputs = [0.1, 2 + .1, 99.88, True]
     code = "self.top.recorders[0].record(self, inputs, outputs, None, '', '')"
     assert_raises(self, code, globals(), locals(), RuntimeError,
                   'Attempt to record on closed recorder')
Ejemplo n.º 15
0
    def test_sorting(self):
        # Make sure outputs are sorted
            
        rec = CSVCaseRecorder(filename=self.filename)
        rec.num_backups = 0
        rec.startup()
        rec.record(Case(inputs=[('comp1.x',2.0),('comp1.y',4.3),('comp2.x',1.9)]))
        rec.close()
        
        outfile = open(self.filename, 'r')
        csv_data = outfile.readlines()
        outfile.close()

        line = '"label","/INPUTS","comp1.x","comp1.y","comp2.x","/OUTPUTS","/METADATA","retries","max_retries","parent_uuid","msg"\r\n'
        self.assertEqual(csv_data[0], line)
        line = '"","",2.0,4.3,1.9,"","","","","",""\r\n'
        self.assertEqual(csv_data[1], line)
Ejemplo n.º 16
0
    def test_flatten(self):
        # create some Cases

        outputs = ['comp1.a_array', 'comp1.vt']
        inputs = [('comp1.x_array', array([2.0, 2.0, 2.0]))]
        cases = [Case(inputs=inputs, outputs=outputs)]
        self.top.driver.clear_parameters()
        Case.set_vartree_inputs(self.top.driver, cases)
        self.top.driver.clear_responses()
        self.top.driver.add_responses(outputs)
        self.top.recorders = [CSVCaseRecorder(filename=self.filename)]
        self.top.recorders[0].num_backups = 0
        self.top.run()

        # check recorded cases
        cases = [case for case in self.top.recorders[0].get_iterator()]
Ejemplo n.º 17
0
    def test_flatten(self):
        # create some Cases
        outputs = ['comp1.a_array', 'comp1.vt']
        inputs = [('comp1.x_array', array([2.0, 2.0, 2.0]))]
        self.top.driver.iterator = ListCaseIterator(
            [Case(inputs=inputs, outputs=outputs, label='case1')])
        self.top.driver.recorders = [CSVCaseRecorder(filename=self.filename)]
        self.top.driver.recorders[0].num_backups = 0
        self.top.run()

        # now use the CSV recorder as source of Cases
        self.top.driver.iterator = self.top.driver.recorders[0].get_iterator()

        sout = StringIO.StringIO()
        self.top.driver.recorders = [DumpCaseRecorder(sout)]
        self.top.run()
        expected = [
            'Case: case1',
            '   uuid: ad4c1b76-64fb-11e0-95a8-001e8cf75fe',
            '   inputs:',
            '      comp1.x_array[0]: 2.0',
            '      comp1.x_array[1]: 2.0',
            '      comp1.x_array[2]: 2.0',
            '   outputs:',
            "      comp1.a_array[0]: 1.0",
            "      comp1.a_array[1]: 3.0",
            "      comp1.a_array[2]: 5.5",
            "      comp1.vt.v1: 1.0",
            "      comp1.vt.v2: 2.0",
            "      comp1.vt.vt2.vt3.a: 1.0",
            "      comp1.vt.vt2.vt3.b: 12.0",
            "      comp1.vt.vt2.x: -1.0",
            "      comp1.vt.vt2.y: -2.0",
        ]
        lines = sout.getvalue().split('\n')
        for index, line in enumerate(lines):
            if line.startswith('Case: case1'):
                for i in range(len(expected)):
                    if expected[i].startswith('   uuid:'):
                        self.assertTrue(lines[index +
                                              i].startswith('   uuid:'))
                    else:
                        self.assertEqual(lines[index + i], expected[i])
                break
        else:
            self.fail("couldn't find the expected Case")
Ejemplo n.º 18
0
    def configure(self):
        """ Configure a simple DOE to set start points for CONMIN. """
        self.add('gp_fun', GoldsteinPrice())

        conmin = self.add('conmin', CONMINdriver())
        conmin.workflow.add('gp_fun')
        conmin.add_parameter('gp_fun.x1')
        conmin.add_parameter('gp_fun.x2')
        conmin.add_objective('gp_fun.f')

        doe = self.add('driver', DOEdriver())
        doe.workflow.add('conmin')
        doe.add_parameter('gp_fun.x1', low=-1.5, high=1.5, start=1)
        doe.add_parameter('gp_fun.x2', low=-1.5, high=1.5, start=1)
        doe.DOEgenerator = FullFactorial(5)
        doe.add_responses(
            ['gp_fun.f', 'gp_fun.x1', 'gp_fun.x2', 'gp_fun.exec_count'])
        self.recorders = [CSVCaseRecorder(), DumpCaseRecorder()]
Ejemplo n.º 19
0
    def test_inoutCSV(self):

        #This test runs some cases, puts them in a CSV file using a CSVCaseRecorder,
        #then runs the model again using the same cases, pulled out of the CSV file
        #by a CSVCaseIterator.  Finally the cases are dumped to a string after
        #being run for the second time.

        self.top.driver.recorders = [CSVCaseRecorder(filename=self.filename)]
        self.top.driver.recorders[0].num_backups = 0
        self.top.run()

        # now use the CSV recorder as source of Cases
        self.top.driver.iterator = self.top.driver.recorders[0].get_iterator()

        sout = StringIO.StringIO()
        self.top.driver.recorders = [DumpCaseRecorder(sout)]
        self.top.run()
        expected = [
            'Case: case8',
            '   uuid: ad4c1b76-64fb-11e0-95a8-001e8cf75fe',
            '   inputs:',
            '      comp1.b_bool: True',
            '      comp1.x: 8.1',
            '      comp1.x_array[1]: 99.88',
            '      comp1.y: 16.1',
            '   outputs:',
            #"      comp1.a_list: [1, 'one', 1.0]",
            "      comp1.a_array[2]: 5.5",
            "      comp1.a_string: Hello',;','",
            '      comp1.z: 24.2',
            '      comp2.z: 25.2',
        ]
        lines = sout.getvalue().split('\n')
        for index, line in enumerate(lines):
            if line.startswith('Case: case8'):
                for i in range(len(expected)):
                    if expected[i].startswith('   uuid:'):
                        self.assertTrue(lines[index +
                                              i].startswith('   uuid:'))
                    else:
                        self.assertEqual(lines[index + i], expected[i])
                break
        else:
            self.fail("couldn't find the expected Case")
Ejemplo n.º 20
0
    def test_inoutCSV_delimiter(self):

        #Repeat test above using semicolon delimiter and ' as quote char.

        self.top.driver.recorders = [CSVCaseRecorder(filename=self.filename, delimiter=';', \
                                                     quotechar="'")]
        self.top.run()

        # now use the DB as source of Cases
        self.top.driver.iterator = self.top.driver.recorders[0].get_iterator()

        sout = StringIO.StringIO()
        self.top.driver.recorders = [DumpCaseRecorder(sout)]
        self.top.run()
        expected = [
            'Case: case8',
            '   uuid: ad4c1b76-64fb-11e0-95a8-001e8cf75fe',
            '   inputs:',
            '      comp1.x: 8.1',
            '      comp1.x_array[1]: 99.88',
            '      comp1.y: 16.1',
            '   outputs:',
            "      comp1.a_array[2]: 5.5",
            "      comp1.a_string: Hello',;','",
            '      comp1.z: 24.2',
            '      comp2.z: 25.2',
        ]
        lines = sout.getvalue().split('\n')
        for index, line in enumerate(lines):
            if line.startswith('Case: case8'):
                for i in range(len(expected)):
                    if expected[i].startswith('   uuid:'):
                        self.assertTrue(lines[index +
                                              i].startswith('   uuid:'))
                    else:
                        self.assertEqual(lines[index + i], expected[i])
                break
        else:
            self.fail("couldn't find the expected Case")
Ejemplo n.º 21
0
from openmdao.lib.casehandlers.api import CSVCaseRecorder
from CADRE import CADRE_Optimization

print "setting up"
top = CADRE_Optimization(n=1500, m=300)
top.driver.recorders = [CSVCaseRecorder(filename='CADRE.csv')]
printvars = []
for var in ['Data', 'ConCh', 'ConDs', 'ConS0', 'ConS1', 'SOC']:
    printvars += ["pt" + str(i) + ".Data" for i in xrange(6)]
top.driver.printvars = printvars
print "running"
top.run()
Ejemplo n.º 22
0
 def test_CSVCaseRecorder_messages(self):
     rec = CSVCaseRecorder(filename=self.filename)
     rec.startup()
     rec.register(self, ['comp1.x', 'comp1.y', 'comp2.x'], [])
     rec.record(self, [2.0, 4.3, 1.9], [], None, '', '')
     try:
         rec.record(self, [2.0, 1.9], [], None, '', '')
     except Exception as err:
         self.assertEqual(
             str(err), "number of data points (9) doesn't match"
             " header size (10) in CSV recorder")
     else:
         self.fail("Exception expected")
     finally:
         rec.close()
Ejemplo n.º 23
0
    def test_sorting(self):
        # Make sure outputs are sorted

        rec = CSVCaseRecorder(filename=self.filename)
        rec.num_backups = 0
        rec.startup()
        rec.register(self, [
            'comp1.x',
            'comp1.y',
            'comp2.x',
        ], [])
        rec.record(self, [2.0, 4.3, 1.9], [], None, '', '')
        rec.close()

        outfile = open(self.filename, 'r')
        csv_data = outfile.readlines()
        outfile.close()

        line = '"timestamp","/INPUTS","comp1.x","comp1.y","comp2.x",' \
               '"/OUTPUTS","/METADATA","uuid","parent_uuid","msg"\r\n'
        self.assertEqual(csv_data[0], line)
        line = '"",2.0,4.3,1.9,"","","","",""\r\n'
        self.assertTrue(csv_data[1].endswith(line))
Ejemplo n.º 24
0
    # import time

    opt_problem = OptimizationConstrained()

    # -----------------------------
    # Set up our CaseRecorders
    #-----------------------------
    import os

    if os.path.exists('converge.db'):
        os.remove('converge.db')

    from openmdao.lib.casehandlers.api import CSVCaseRecorder, DBCaseRecorder

    opt_problem.driver.recorders = [
        CSVCaseRecorder(filename='converge.csv'),
        DBCaseRecorder(dbfile='converge.db', append=False)
    ]
    opt_problem.driver.printvars = ['*']

    #-----------------------------
    # Run problem
    #-----------------------------

    opt_problem.run()

    #----------------------------------------------------
    # Print out history of our objective for inspection
    #----------------------------------------------------

    for case in opt_problem.driver.recorders[0].get_iterator():
Ejemplo n.º 25
0
    def configure(self):

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

        # Create component instances
        self.add('input_list', Input_List())
        self.add('postprocess', Postprocess_Fuzzy_Outputs())
        self.add('compatibility', checkCompatibility())

        #PHI SYSTEM
        self.add('fuzz_combine_phi', Build_Fuzzy_Input())
        self.add('phi_sys', Fuzzy_System())

        #Lift/Drag SYSTEM
        self.add('fuzz_combine_LD', Build_Fuzzy_Input())
        self.add('LoD_sys', Fuzzy_System())

        #FoM SYSTEM
        self.add('fuzz_combine_FoM', Build_Fuzzy_Input())
        self.add('FoM_sys', DFES())

        #Propulsive Efficiency System
        self.add('fuzz_combine_etaP', Build_Fuzzy_Input())
        self.add('etaP_sys', Fuzzy_System())

        #QUANTIFICATION
        self.add('quantifyPHI', Quantify())
        self.add('quantifySFC', Quantify())

        #RF SYSTEMs
        self.add('fuzz_combine_GWT', Build_Fuzzy_Input())
        self.add('GWT_sys', DFES())
        self.add('fuzz_combine_P', Build_Fuzzy_Input())
        self.add('P_sys', DFES())
        self.add('fuzz_combine_VH', Build_Fuzzy_Input())
        self.add('VH_sys', DFES())

        # Iteration Hierarchy
        self.driver.workflow.add([
            'compatibility', 'input_list', 'fuzz_combine_phi', 'phi_sys',
            'fuzz_combine_LD', 'LoD_sys', 'fuzz_combine_FoM', 'FoM_sys',
            'fuzz_combine_etaP', 'etaP_sys', 'quantifyPHI', 'quantifySFC',
            'GWT_sys', 'P_sys', 'VH_sys', 'postprocess'
        ])

        self.connect('compatibility.option1_out', 'input_list.option1')
        self.connect('compatibility.option2_out', 'input_list.option2')
        self.connect('compatibility.option3_out', 'input_list.option3')
        self.connect('compatibility.option4_out', 'input_list.option4')
        self.connect('compatibility.option5_out', 'input_list.option5')
        self.connect('compatibility.option6_out', 'input_list.option6')
        self.connect('compatibility.option7_out', 'input_list.option7')
        self.connect('compatibility.option8_out', 'input_list.option8')
        self.connect('compatibility.option9_out', 'input_list.option9')
        self.connect('compatibility.compatibility', 'input_list.passthrough')
        self.connect('compatibility.compatibility', 'postprocess.passthrough')
        self.connect('compatibility.incompatCount',
                     'postprocess.incompatCount')

        self.connect('compatibility.compatibility', 'phi_sys.passthrough')
        self.connect('compatibility.compatibility', 'LoD_sys.passthrough')
        self.connect('compatibility.compatibility', 'FoM_sys.passthrough')
        self.connect('compatibility.compatibility', 'etaP_sys.passthrough')
        self.connect('compatibility.compatibility', 'GWT_sys.passthrough')
        self.connect('compatibility.compatibility', 'P_sys.passthrough')
        self.connect('compatibility.compatibility', 'VH_sys.passthrough')

        self.connect('compatibility.compatibility', 'quantifyPHI.passthrough')
        self.connect('compatibility.compatibility', 'quantifySFC.passthrough')

        ## CONNECT phi system
        #connect inputs for phi system
        self.connect("input_list.VL_SYS_TYPE_phi",
                     "fuzz_combine_phi.in_1.input_value")
        self.connect("input_list.VL_SYS_TYPE_w",
                     "fuzz_combine_phi.in_2.input_value")
        self.connect("input_list.VL_SYS_TYPE_f",
                     "fuzz_combine_phi.in_3.input_value")

        self.connect("input_list.VL_SYS_PROP_w",
                     "fuzz_combine_phi.in_4.input_value")
        self.connect("input_list.VL_SYS_PROP_phi",
                     "fuzz_combine_phi.in_5.input_value")

        self.connect("input_list.VL_SYS_TECH_phi",
                     "fuzz_combine_phi.in_6.input_value")
        self.connect("input_list.VL_SYS_TECH_w",
                     "fuzz_combine_phi.in_7.input_value")
        self.connect("input_list.VL_SYS_TECH_f",
                     "fuzz_combine_phi.in_8.input_value")
        self.connect("input_list.VL_SYS_TECH_LD",
                     "fuzz_combine_phi.in_9.input_value")

        self.connect("input_list.FWD_SYS_PROP_eta_p",
                     "fuzz_combine_phi.in_10.input_value")

        self.connect("input_list.FWD_SYS_DRV_eta_d",
                     "fuzz_combine_phi.in_11.input_value")

        self.connect("input_list.FWD_SYS_TYPE_phi",
                     "fuzz_combine_phi.in_12.input_value")
        self.connect("input_list.FWD_SYS_TYPE_TP",
                     "fuzz_combine_phi.in_13.input_value")

        self.connect("input_list.WING_SYS_TYPE_LD",
                     "fuzz_combine_phi.in_14.input_value")
        self.connect("input_list.WING_SYS_TYPE_f",
                     "fuzz_combine_phi.in_15.input_value")

        self.connect("fuzz_combine_phi.system_inputs", "phi_sys.input_list")
        self.connect("fuzz_combine_phi.runFlag_out", "phi_sys.runFlag_in")

        self.postprocess.fuzzSys_in_1.mf_key = 'sys_phi'
        self.connect('phi_sys.outputs_all', 'postprocess.fuzzSys_in_1.mf_dict')

        ## CONNECT LoD System
        self.connect("input_list.SYSTEM_f", "fuzz_combine_LD.in_1.input_value")
        self.connect("input_list.WING_LoD", "fuzz_combine_LD.in_2.input_value")

        self.connect("fuzz_combine_LD.system_inputs", "LoD_sys.input_list")
        self.connect("fuzz_combine_LD.runFlag_out", "LoD_sys.runFlag_in")

        self.postprocess.fuzzSys_in_2.mf_key = 'sys_LoD'
        self.connect('LoD_sys.outputs_all', 'postprocess.fuzzSys_in_2.mf_dict')

        ## CONNECT FoM System
        self.connect("input_list.VL_SYS_e_d",
                     "fuzz_combine_FoM.in_1.input_value")
        self.connect("input_list.VL_SYS_PROP_sigma",
                     "fuzz_combine_FoM.in_2.input_value")
        self.connect("input_list.VL_SYS_w",
                     "fuzz_combine_FoM.in_3.input_value")
        self.connect("input_list.VL_SYS_DRV_eta_d",
                     "fuzz_combine_FoM.in_4.input_value")

        self.connect("fuzz_combine_FoM.system_inputs", "FoM_sys.input_list")
        self.connect("fuzz_combine_FoM.runFlag_out", "FoM_sys.runFlag_in")

        self.postprocess.fuzzSys_in_3.mf_key = 'sys_FoM'
        self.connect('FoM_sys.outputs_all', 'postprocess.fuzzSys_in_3.mf_dict')

        ## CONNECT etaP System
        self.connect("input_list.FWD_SYS_eta_p",
                     "fuzz_combine_etaP.in_1.input_value")
        self.connect("input_list.FWD_DRV_eta_d",
                     "fuzz_combine_etaP.in_2.input_value")

        self.connect("fuzz_combine_etaP.system_inputs", "etaP_sys.input_list")
        self.connect("fuzz_combine_etaP.runFlag_out", "etaP_sys.runFlag_in")

        self.postprocess.fuzzSys_in_4.mf_key = 'sys_etaP'
        self.connect('etaP_sys.outputs_all',
                     'postprocess.fuzzSys_in_4.mf_dict')

        self.postprocess.PLOTMODE = 0

        ## CONNECT RF Systems
        self.connect('phi_sys.outputs_all',
                     'quantifyPHI.inDict')  #key defined below
        self.connect('input_list.ENG_SYS_TYPE_SFC', 'quantifySFC.qualVal')

        #GWT:
        self.connect("quantifyPHI.quantVal",
                     "fuzz_combine_GWT.in_1.input_value")
        self.connect("input_list.VL_SYS_w",
                     "fuzz_combine_GWT.in_2.input_value")
        self.connect("input_list.WING_SYS_TYPE_WS",
                     "fuzz_combine_GWT.in_3.input_value")
        self.connect("etaP_sys.outputs_all",
                     "fuzz_combine_GWT.inDict_1.input_dict")
        self.connect("input_list.VL_SYS_DRV_eta_d",
                     "fuzz_combine_GWT.in_4.input_value")
        self.connect("FoM_sys.outputs_all",
                     "fuzz_combine_GWT.inDict_2.input_dict")
        self.connect("input_list.VL_SYS_e_d",
                     "fuzz_combine_GWT.in_5.input_value")
        self.connect("quantifySFC.quantVal",
                     "fuzz_combine_GWT.in_6.input_value")
        self.connect("input_list.SYS_type",
                     "fuzz_combine_GWT.in_7.input_value")
        #self.connect("input_list.SYS_tech",         "fuzz_combine_GWT.in_8.input_value")

        self.connect("fuzz_combine_GWT.system_inputs", "GWT_sys.input_list")
        self.connect("fuzz_combine_GWT.runFlag_out", "GWT_sys.runFlag_in")

        self.postprocess.fuzzSys_in_5.mf_key = 'sys_GWT'
        self.connect('GWT_sys.outputs_all', 'postprocess.fuzzSys_in_5.mf_dict')

        #Power Installed:
        self.connect("quantifyPHI.quantVal", "fuzz_combine_P.in_1.input_value")
        self.connect("input_list.VL_SYS_w", "fuzz_combine_P.in_2.input_value")
        self.connect("input_list.WING_SYS_TYPE_WS",
                     "fuzz_combine_P.in_3.input_value")
        self.connect("etaP_sys.outputs_all",
                     "fuzz_combine_P.inDict_1.input_dict")
        self.connect("input_list.VL_SYS_DRV_eta_d",
                     "fuzz_combine_P.in_4.input_value")
        self.connect("FoM_sys.outputs_all",
                     "fuzz_combine_P.inDict_2.input_dict")
        self.connect("input_list.VL_SYS_e_d",
                     "fuzz_combine_P.in_5.input_value")
        self.connect("quantifySFC.quantVal", "fuzz_combine_P.in_6.input_value")
        self.connect("input_list.SYS_type", "fuzz_combine_P.in_7.input_value")
        #self.connect("input_list.SYS_tech",         "fuzz_combine_P.in_8.input_value")

        self.connect("fuzz_combine_P.system_inputs", "P_sys.input_list")
        self.connect("fuzz_combine_P.runFlag_out", "P_sys.runFlag_in")

        self.postprocess.fuzzSys_in_6.mf_key = 'sys_P'
        self.connect('P_sys.outputs_all', 'postprocess.fuzzSys_in_6.mf_dict')

        #VH:
        self.connect("quantifyPHI.quantVal",
                     "fuzz_combine_VH.in_1.input_value")
        self.connect("input_list.VL_SYS_w", "fuzz_combine_VH.in_2.input_value")
        self.connect("input_list.WING_SYS_TYPE_WS",
                     "fuzz_combine_VH.in_3.input_value")
        self.connect("etaP_sys.outputs_all",
                     "fuzz_combine_VH.inDict_1.input_dict")
        self.connect("input_list.VL_SYS_DRV_eta_d",
                     "fuzz_combine_VH.in_4.input_value")
        self.connect("FoM_sys.outputs_all",
                     "fuzz_combine_VH.inDict_2.input_dict")
        self.connect("input_list.VL_SYS_e_d",
                     "fuzz_combine_VH.in_5.input_value")
        self.connect("quantifySFC.quantVal",
                     "fuzz_combine_VH.in_6.input_value")
        self.connect("input_list.SYS_type", "fuzz_combine_VH.in_7.input_value")
        #self.connect("input_list.SYS_tech",         "fuzz_combine_VH.in_8.input_value")

        self.connect("fuzz_combine_VH.system_inputs", "VH_sys.input_list")
        self.connect("fuzz_combine_VH.runFlag_out", "VH_sys.runFlag_in")

        self.postprocess.fuzzSys_in_7.mf_key = 'sys_VH'
        self.connect('VH_sys.outputs_all', 'postprocess.fuzzSys_in_7.mf_dict')

        ######
        # Design Variables
        self.input_list.input_file = 'data/morphInputs_13Jun15.csv'

        ## SET VARIABLES phi system
        self.phi_sys.TESTMODE = 0
        self.phi_sys.TESTPLOT = 0
        self.phi_sys.fcl_file = 'FCL_files/FRBS_phi/PHIsys_trained_5-2In9-2Out_gauss250tData_50vData_optInputsBEST_GA.fcl'

        self.fuzz_combine_phi.in_1.input_key = 'VL_SYS_TYPE_phi'
        self.fuzz_combine_phi.in_2.input_key = 'VL_SYS_TYPE_w'
        self.fuzz_combine_phi.in_3.input_key = 'VL_SYS_TYPE_f'
        self.fuzz_combine_phi.in_4.input_key = 'VL_SYS_PROP_w'
        self.fuzz_combine_phi.in_5.input_key = 'VL_SYS_PROP_phi'
        self.fuzz_combine_phi.in_6.input_key = 'VL_SYS_TECH_phi'
        self.fuzz_combine_phi.in_7.input_key = 'VL_SYS_TECH_w'
        self.fuzz_combine_phi.in_8.input_key = 'VL_SYS_TECH_f'
        self.fuzz_combine_phi.in_9.input_key = 'VL_SYS_TECH_LD'
        self.fuzz_combine_phi.in_10.input_key = 'FWD_SYS_PROP_eta_p'
        self.fuzz_combine_phi.in_11.input_key = 'FWD_SYS_DRV_eta_d'
        self.fuzz_combine_phi.in_12.input_key = 'FWD_SYS_TYPE_phi'
        self.fuzz_combine_phi.in_13.input_key = 'FWD_SYS_TYPE_TP'
        self.fuzz_combine_phi.in_14.input_key = 'WING_SYS_TYPE_LD'
        self.fuzz_combine_phi.in_15.input_key = 'WING_SYS_TYPE_f'

        ## SET VARIABLES LoD system
        self.LoD_sys.TESTMODE = 0
        self.LoD_sys.TESTPLOT = 0
        self.LoD_sys.fcl_file = 'FCL_files/LoDsys_simple_13Jun15.fcl'

        self.fuzz_combine_LD.in_1.input_key = 'SYSTEM_f'
        self.fuzz_combine_LD.in_2.input_key = 'WING_LoD'

        ## SET VARIABLES FoM system
        self.FoM_sys.weight_file = 'FCL_files/DFES_FoM/DFES_FOMdata_data(500)_nodes(160_50_50).nwf'
        self.FoM_sys.inRanges = {
            'VL_SYS_e_d': [0.0, 0.3],
            'VL_SYS_PROP_sigma': [0.05, 0.4],
            'VL_SYS_w': [0., 150.],
            'VL_SYS_DRV_eta': [0.5, 1.0],
        }
        self.FoM_sys.inOrder = [
            'VL_SYS_e_d', 'VL_SYS_w', 'VL_SYS_DRV_eta', 'VL_SYS_PROP_sigma'
        ]
        self.FoM_sys.outRanges = {'sys_FoM': [0.4, 1.0]}
        self.FoM_sys.actType = 'sigmoid'
        self.FoM_sys.hidNodes = 160
        self.FoM_sys.inGran = 50
        self.FoM_sys.outGran = 50

        self.FoM_sys.TESTPLOT = 0

        self.fuzz_combine_FoM.in_1.input_key = 'VL_SYS_e_d'
        self.fuzz_combine_FoM.in_2.input_key = 'VL_SYS_PROP_sigma'
        self.fuzz_combine_FoM.in_3.input_key = 'VL_SYS_w'
        self.fuzz_combine_FoM.in_4.input_key = 'VL_SYS_DRV_eta'

        ## SET VARIABLES etaP system
        self.etaP_sys.TESTMODE = 0
        self.etaP_sys.TESTPLOT = 0
        self.etaP_sys.fcl_file = 'FCL_files/etaPsys_simple_14Aug15.fcl'

        self.fuzz_combine_etaP.in_1.input_key = 'FWD_SYS_eta_p'
        self.fuzz_combine_etaP.in_2.input_key = 'FWD_DRV_eta_d'

        ## SET VARIABLES RF systems
        self.quantifyPHI.quantRange = [0.85, 0.50]
        self.quantifyPHI.inKey = 'sys_phi'
        self.quantifySFC.quantRange = [0.75, 0.35]

        ## SET VARIABLES RF:
        #GWT:
        self.GWT_sys.weight_file = 'FCL_files/DFES_RF/BEST/RFdata20Aug_DFES_GWT_30_250_50.nwf'
        self.GWT_sys.inRanges = {
            'SYSTEM_QUANT_PHI': [0.5, 0.85],
            'VL_SYS_w': [1., 150.],
            'WING_SYS_TYPE_WS': [15., 300.],
            'sys_etaP': [0.6, 1.0],
            'VL_SYS_DRV_eta_d': [0.7, 1.0],
            'sys_FoM': [0.3, 1.0],
            'VL_SYS_e_d': [0.0, 0.3],
            'ENG_SYS_TYPE_SFC': [0.35, 0.75],
            'SYS_type': [0.5, 3.5],
        }

        self.GWT_sys.inOrder = [
            'VL_SYS_e_d', 'WING_SYS_TYPE_WS', 'SYSTEM_QUANT_PHI', 'SYS_type',
            'VL_SYS_DRV_eta_d', 'sys_FoM', 'VL_SYS_w', 'sys_etaP',
            'ENG_SYS_TYPE_SFC'
        ]
        #['SYSTEM_QUANT_PHI', 'VL_SYS_w', 'WING_SYS_TYPE_WS', 'sys_etaP',
        #    'VL_SYS_DRV_eta_d', 'sys_FoM','VL_SYS_e_d', 'ENG_SYS_TYPE_SFC', 'SYS_type']
        self.GWT_sys.outRanges = {'sys_GWT': [5000, 50000]}
        self.GWT_sys.actType = 'sigmoid'
        self.GWT_sys.hidNodes = 250
        self.GWT_sys.inGran = 30
        self.GWT_sys.outGran = 50

        self.fuzz_combine_GWT.in_1.input_key = 'SYSTEM_QUANT_PHI'
        self.fuzz_combine_GWT.in_2.input_key = 'VL_SYS_w'
        self.fuzz_combine_GWT.in_3.input_key = 'WING_SYS_TYPE_WS'
        self.fuzz_combine_GWT.inDict_1.input_keys = ['sys_etaP']
        self.fuzz_combine_GWT.in_4.input_key = 'VL_SYS_DRV_eta_d'
        self.fuzz_combine_GWT.inDict_2.input_keys = ['sys_FoM']
        self.fuzz_combine_GWT.in_5.input_key = 'VL_SYS_e_d'
        self.fuzz_combine_GWT.in_6.input_key = 'ENG_SYS_TYPE_SFC'
        self.fuzz_combine_GWT.in_7.input_key = 'SYS_type'
        #self.fuzz_combine_GWT.in_8.input_key ='SYS_tech'

        #P installed:
        self.P_sys.weight_file = 'FCL_files/DFES_RF/BEST/RFdata20Aug_DFES_Pin_30_250_50.nwf'
        self.P_sys.TESTPLOT = 0
        self.P_sys.inRanges = {
            'SYSTEM_QUANT_PHI': [0.5, 0.85],
            'VL_SYS_w': [1., 150.],
            'WING_SYS_TYPE_WS': [15., 300.],
            'sys_etaP': [0.6, 1.0],
            'VL_SYS_DRV_eta_d': [0.7, 1.0],
            'sys_FoM': [0.3, 1.0],
            'VL_SYS_e_d': [0.0, 0.3],
            'ENG_SYS_TYPE_SFC': [0.35, 0.75],
            'SYS_type': [0.5, 3.5],
        }
        self.P_sys.inOrder = [
            'VL_SYS_e_d', 'WING_SYS_TYPE_WS', 'SYSTEM_QUANT_PHI', 'SYS_type',
            'VL_SYS_DRV_eta_d', 'sys_FoM', 'VL_SYS_w', 'sys_etaP',
            'ENG_SYS_TYPE_SFC'
        ]
        #['SYSTEM_QUANT_PHI', 'VL_SYS_w', 'WING_SYS_TYPE_WS', 'sys_etaP',
        # 'VL_SYS_DRV_eta_d', 'sys_FoM','VL_SYS_e_d', 'ENG_SYS_TYPE_SFC', 'SYS_type']
        self.P_sys.outRanges = {'sys_P': [1000, 15000]}
        self.P_sys.actType = 'sigmoid'
        self.P_sys.hidNodes = 250
        self.P_sys.inGran = 30
        self.P_sys.outGran = 50

        self.fuzz_combine_P.in_1.input_key = 'SYSTEM_QUANT_PHI'
        self.fuzz_combine_P.in_2.input_key = 'VL_SYS_w'
        self.fuzz_combine_P.in_3.input_key = 'WING_SYS_TYPE_WS'
        self.fuzz_combine_P.inDict_1.input_keys = ['sys_etaP']
        self.fuzz_combine_P.in_4.input_key = 'VL_SYS_DRV_eta_d'
        self.fuzz_combine_P.inDict_2.input_keys = ['sys_FoM']
        self.fuzz_combine_P.in_5.input_key = 'VL_SYS_e_d'
        self.fuzz_combine_P.in_6.input_key = 'ENG_SYS_TYPE_SFC'
        self.fuzz_combine_P.in_7.input_key = 'SYS_type'
        #self.fuzz_combine_P.in_8.input_key ='SYS_tech'

        #VH:
        self.VH_sys.weight_file = 'FCL_files/DFES_RF/BEST/RFdata20Aug_DFES_VH_40_250_50.nwf'
        self.VH_sys.inRanges = {
            'SYSTEM_QUANT_PHI': [0.5, 0.85],
            'VL_SYS_w': [1., 150.],
            'WING_SYS_TYPE_WS': [15., 300.],
            'sys_etaP': [0.6, 1.0],
            'VL_SYS_DRV_eta_d': [0.7, 1.0],
            'sys_FoM': [0.3, 1.0],
            'VL_SYS_e_d': [0.0, 0.3],
            'ENG_SYS_TYPE_SFC': [0.35, 0.75],
            'SYS_type': [0.5, 3.5],
        }
        self.VH_sys.inOrder = [
            'VL_SYS_e_d', 'WING_SYS_TYPE_WS', 'SYSTEM_QUANT_PHI', 'SYS_type',
            'VL_SYS_DRV_eta_d', 'sys_FoM', 'VL_SYS_w', 'sys_etaP',
            'ENG_SYS_TYPE_SFC'
        ]
        #['SYSTEM_QUANT_PHI', 'VL_SYS_w', 'WING_SYS_TYPE_WS', 'sys_etaP',
        #'VL_SYS_DRV_eta_d', 'sys_FoM','VL_SYS_e_d', 'ENG_SYS_TYPE_SFC', 'SYS_type']
        self.VH_sys.outRanges = {'sys_VH': [200, 500]}
        self.VH_sys.actType = 'sigmoid'
        self.VH_sys.hidNodes = 250
        self.VH_sys.inGran = 40
        self.VH_sys.outGran = 50

        self.fuzz_combine_VH.in_1.input_key = 'SYSTEM_QUANT_PHI'
        self.fuzz_combine_VH.in_2.input_key = 'VL_SYS_w'
        self.fuzz_combine_VH.in_3.input_key = 'WING_SYS_TYPE_WS'
        self.fuzz_combine_VH.inDict_1.input_keys = ['sys_etaP']
        self.fuzz_combine_VH.in_4.input_key = 'VL_SYS_DRV_eta_d'
        self.fuzz_combine_VH.inDict_2.input_keys = ['sys_FoM']
        self.fuzz_combine_VH.in_5.input_key = 'VL_SYS_e_d'
        self.fuzz_combine_VH.in_6.input_key = 'ENG_SYS_TYPE_SFC'
        self.fuzz_combine_VH.in_7.input_key = 'SYS_type'

        # CONFIGURE DRIVER
        self.driver.iprint = 0  # Driver Flags

        self.driver.add_parameter('compatibility.gen_num')
        self.driver.add_parameter(
            'compatibility.option1')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option2')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option3')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option4')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option5')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option6')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option7')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option8')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option9')  #list of options as input

        #self.driver.add_response('driver.gen_num')

        self.driver.add_objective(
            'postprocess.response_1_POS')  #output from system (dict)
        self.driver.add_objective(
            'postprocess.response_2_POS')  #output from system (dict)
        self.driver.add_objective(
            'postprocess.response_3_POS')  #output from system (dict)
        self.driver.add_objective(
            'postprocess.response_4_POS')  #output from system (dict)
        self.driver.add_objective(
            'postprocess.response_6_POS')  #output from system (dict)

        #self.driver.add_response('postprocess.ranges_out') #output from system (dict)
        #self.driver.add_response('postprocess.response_1_r') #output from system (dict)
        #self.driver.add_response('postprocess.response_2_r') #output from system (dict)
        #self.driver.add_response('postprocess.response_3_r') #output from system (dict)
        t = time.strftime("%H-%M-%S")
        self.recorders = [
            CSVCaseRecorder(filename='optCases_POS_' + t + '.csv')
        ]  #  [JSONCaseRecorder(out='opt_record.json')]  #
        self.recording_options.includes = [
            'compatibility.gen_num', 'compatibility.option1',
            'compatibility.option2', 'compatibility.option3',
            'compatibility.option4', 'compatibility.option5',
            'compatibility.option6', 'compatibility.option7',
            'compatibility.option8', 'compatibility.option9',
            "compatibility.compatibility", 'postprocess.response_1',
            'postprocess.response_2', 'postprocess.response_3',
            'postprocess.response_4', 'postprocess.response_5',
            'postprocess.response_6', 'postprocess.response_7',
            'postprocess.response_1_r', 'postprocess.response_2_r',
            'postprocess.response_3_r', 'postprocess.response_4_r',
            'postprocess.response_5_r', 'postprocess.response_6_r',
            'postprocess.response_7_r', 'postprocess.response_1_POS',
            'postprocess.response_2_POS', 'postprocess.response_3_POS',
            'postprocess.response_4_POS', 'postprocess.response_5_POS',
            'postprocess.response_6_POS', 'postprocess.response_7_POS',
            'postprocess.fuzzyPOS'
        ]

        self.driver.print_results = True


#if __name__ == "__main__":
#    None
Ejemplo n.º 26
0
 def test_flatten(self):
     self.top = set_as_top(TestAssembly())
     self.top.recorders = [CSVCaseRecorder(filename=self.filename)]
     self.top.run()
     cases = [case for case in self.top.recorders[0].get_iterator()]
Ejemplo n.º 27
0
 def test_CSVCaseRecorder_messages(self):
     rec = CSVCaseRecorder(filename=self.filename)
     rec.startup()
     rec.register(self, ['comp1.x', 'comp1.y', 'comp2.x'], [])
     rec.record(self, [2.0, 4.3, 1.9], [], None, '', '')
     try:
         rec.record(self, [2.0, 1.9], [], None, '', '')
     except Exception as err:
         self.assertEqual(str(err),
                          "number of data points (9) doesn't match"
                          " header size (10) in CSV recorder")
     else:
         self.fail("Exception expected")
     finally:
         rec.close()
Ejemplo n.º 28
0
    def configure(self):

        #Add Components
        compress = self.add('compress', CompressionSystem())
        mission = self.add('mission', Mission())
        pod = self.add('pod', Pod())
        flow_limit = self.add('flow_limit', TubeLimitFlow())
        tube_wall_temp = self.add('tube_wall_temp', TubeWallTemp())

        #Boundary Input Connections
        #Hyperloop -> Compress
        self.connect('Mach_pod_max', 'compress.Mach_pod_max')
        self.connect('Ps_tube', 'compress.Ps_tube')
        self.connect('Mach_c1_in', 'compress.Mach_c1_in')  #Design Variable
        self.connect('c1_PR_des', 'compress.c1_PR_des')  #Design Variable
        #Hyperloop -> Mission
        self.connect('tube_length', 'mission.tube_length')
        self.connect('pwr_marg', 'mission.pwr_marg')
        #Hyperloop -> Flow Limit
        self.connect('Mach_pod_max', 'flow_limit.Mach_pod')
        self.connect('Ps_tube', 'flow_limit.Ps_tube')
        self.connect('pod.radius_inlet_back_outer', 'flow_limit.radius_inlet')
        self.connect('Mach_bypass', 'flow_limit.Mach_bypass')
        #Hyperloop -> Pod
        self.connect('Ps_tube', 'pod.Ps_tube')
        self.connect('hub_to_tip', 'pod.hub_to_tip')
        self.connect('coef_drag', 'pod.coef_drag')
        self.connect('n_rows', 'pod.n_rows')
        self.connect('length_row', 'pod.length_row')
        #Hyperloop -> TubeWallTemp
        self.connect('solar_heating_factor',
                     'tube_wall_temp.nn_incidence_factor')
        self.connect('tube_length', 'tube_wall_temp.length_tube')

        #Inter-component Connections
        #Compress -> Mission
        self.connect('compress.speed_max', 'mission.speed_max')
        #Compress -> Pod
        self.connect('compress.area_c1_in', 'pod.area_inlet_out')
        self.connect('compress.area_inlet_in', 'pod.area_inlet_in')
        self.connect('compress.rho_air', 'pod.rho_air')
        self.connect('compress.F_net', 'pod.F_net')
        self.connect('compress.speed_max', 'pod.speed_max')
        #Compress -> TubeWallTemp
        self.connect('compress.nozzle_Fl_O', 'tube_wall_temp.nozzle_air')
        self.connect('compress.bearing_Fl_O', 'tube_wall_temp.bearing_air')
        #Mission -> Pod
        self.connect('mission.time', 'pod.time_mission')
        self.connect('mission.energy', 'pod.energy')

        #Add Solver
        solver = self.add('solver', BroydenSolver())
        solver.itmax = 50  #max iterations
        solver.tol = .001
        #Add Parameters and Constraints
        solver.add_parameter('compress.W_in', low=-1e15, high=1e15)
        solver.add_parameter('compress.c2_PR_des', low=-1e15, high=1e15)
        solver.add_parameter([
            'compress.Ts_tube', 'flow_limit.Ts_tube',
            'tube_wall_temp.temp_boundary'
        ],
                             low=-1e-15,
                             high=1e15)
        solver.add_parameter(
            ['flow_limit.radius_tube', 'pod.radius_tube_inner'],
            low=-1e15,
            high=1e15)

        solver.add_constraint('.01*(compress.W_in-flow_limit.W_excess) = 0')
        solver.add_constraint('compress.Ps_bearing_residual=0')
        solver.add_constraint('tube_wall_temp.ss_temp_residual=0')
        solver.add_constraint(
            '.01*(pod.area_compressor_bypass-compress.area_c1_out)=0')

        driver = self.driver
        driver.workflow.add('solver')
        driver.recorders = [CSVCaseRecorder(filename="hyperloop_data.csv")
                            ]  #record only converged
        driver.printvars = [
            'Mach_bypass', 'Mach_pod_max', 'Mach_c1_in', 'c1_PR_des',
            'pod.radius_inlet_back_outer', 'pod.inlet.radius_back_inner',
            'flow_limit.radius_tube', 'compress.W_in', 'compress.c2_PR_des',
            'pod.net_force', 'compress.F_net', 'compress.pwr_req',
            'pod.energy', 'mission.time', 'compress.speed_max',
            'tube_wall_temp.temp_boundary'
        ]

        #Declare Solver Workflow
        solver.workflow.add(
            ['compress', 'mission', 'pod', 'flow_limit', 'tube_wall_temp'])
Ejemplo n.º 29
0
    def configure(self):

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

        # Create component instances
        self.add('input_list', Input_List())
        self.add('postprocess', Postprocess_Fuzzy_Outputs())
        self.add('compatibility', checkCompatibility())

        #PHI SYSTEM
        self.add('fuzz_combine_phi', Build_Fuzzy_Input())
        self.add('phi_sys', Fuzzy_System())

        #Lift/Drag SYSTEM
        self.add('fuzz_combine_LD', Build_Fuzzy_Input())
        self.add('LoD_sys', Fuzzy_System())

        #FoM SYSTEM
        self.add('fuzz_combine_FoM', Build_Fuzzy_Input())
        self.add('FoM_sys', DFES())

        #Propulsive Efficiency System
        self.add('fuzz_combine_etaP', Build_Fuzzy_Input())
        self.add('etaP_sys', Fuzzy_System())

        #QUANTIFICATION
        self.add('quantifyPHI', Quantify())
        self.add('quantifySFC', Quantify())

        #RF SYSTEMs
        self.add('fuzz_combine_GWT', Build_Fuzzy_Input())
        self.add('GWT_sys', DFES())
        self.add('fuzz_combine_P', Build_Fuzzy_Input())
        self.add('P_sys', DFES())
        self.add('fuzz_combine_VH', Build_Fuzzy_Input())
        self.add('VH_sys', DFES())

        # Iteration Hierarchy
        self.driver.workflow.add([
            'compatibility', 'input_list', 'fuzz_combine_phi', 'phi_sys',
            'fuzz_combine_LD', 'LoD_sys', 'fuzz_combine_FoM', 'FoM_sys',
            'fuzz_combine_etaP', 'etaP_sys', 'quantifyPHI', 'quantifySFC',
            'GWT_sys', 'P_sys', 'VH_sys', 'postprocess'
        ])

        self.connect('compatibility.option1_out', 'input_list.option1')
        self.connect('compatibility.option2_out', 'input_list.option2')
        self.connect('compatibility.option3_out', 'input_list.option3')
        self.connect('compatibility.option4_out', 'input_list.option4')
        self.connect('compatibility.option5_out', 'input_list.option5')
        self.connect('compatibility.option6_out', 'input_list.option6')
        self.connect('compatibility.option7_out', 'input_list.option7')
        self.connect('compatibility.option8_out', 'input_list.option8')
        self.connect('compatibility.option9_out', 'input_list.option9')
        self.connect('compatibility.compatibility', 'input_list.passthrough')
        self.connect('compatibility.compatibility', 'postprocess.passthrough')
        self.connect('compatibility.incompatCount',
                     'postprocess.incompatCount')

        self.connect('compatibility.compatibility', 'phi_sys.passthrough')
        self.connect('compatibility.compatibility', 'LoD_sys.passthrough')
        self.connect('compatibility.compatibility', 'FoM_sys.passthrough')
        self.connect('compatibility.compatibility', 'etaP_sys.passthrough')
        self.connect('compatibility.compatibility', 'GWT_sys.passthrough')
        self.connect('compatibility.compatibility', 'P_sys.passthrough')
        self.connect('compatibility.compatibility', 'VH_sys.passthrough')

        self.connect('compatibility.compatibility', 'quantifyPHI.passthrough')
        self.connect('compatibility.compatibility', 'quantifySFC.passthrough')

        ## CONNECT phi system
        #connect inputs for phi system
        self.connect("input_list.VL_SYS_TYPE_phi",
                     "fuzz_combine_phi.in_1.input_value")
        self.connect("input_list.VL_SYS_TYPE_w",
                     "fuzz_combine_phi.in_2.input_value")
        self.connect("input_list.VL_SYS_TYPE_f",
                     "fuzz_combine_phi.in_3.input_value")

        self.connect("input_list.VL_SYS_PROP_w",
                     "fuzz_combine_phi.in_4.input_value")
        self.connect("input_list.VL_SYS_PROP_phi",
                     "fuzz_combine_phi.in_5.input_value")

        self.connect("input_list.VL_SYS_TECH_phi",
                     "fuzz_combine_phi.in_6.input_value")
        self.connect("input_list.VL_SYS_TECH_w",
                     "fuzz_combine_phi.in_7.input_value")
        self.connect("input_list.VL_SYS_TECH_f",
                     "fuzz_combine_phi.in_8.input_value")
        self.connect("input_list.VL_SYS_TECH_LD",
                     "fuzz_combine_phi.in_9.input_value")

        self.connect("input_list.FWD_SYS_PROP_eta_p",
                     "fuzz_combine_phi.in_10.input_value")

        self.connect("input_list.FWD_SYS_DRV_eta_d",
                     "fuzz_combine_phi.in_11.input_value")

        self.connect("input_list.FWD_SYS_TYPE_phi",
                     "fuzz_combine_phi.in_12.input_value")
        self.connect("input_list.FWD_SYS_TYPE_TP",
                     "fuzz_combine_phi.in_13.input_value")

        self.connect("input_list.WING_SYS_TYPE_LD",
                     "fuzz_combine_phi.in_14.input_value")
        self.connect("input_list.WING_SYS_TYPE_f",
                     "fuzz_combine_phi.in_15.input_value")

        self.connect("fuzz_combine_phi.system_inputs", "phi_sys.input_list")
        self.connect("fuzz_combine_phi.runFlag_out", "phi_sys.runFlag_in")

        self.postprocess.fuzzSys_in_1.mf_key = 'sys_phi'
        self.connect('phi_sys.outputs_all', 'postprocess.fuzzSys_in_1.mf_dict')

        ## CONNECT LoD System
        self.connect("input_list.SYSTEM_f", "fuzz_combine_LD.in_1.input_value")
        self.connect("input_list.WING_LoD", "fuzz_combine_LD.in_2.input_value")

        self.connect("fuzz_combine_LD.system_inputs", "LoD_sys.input_list")
        self.connect("fuzz_combine_LD.runFlag_out", "LoD_sys.runFlag_in")

        self.postprocess.fuzzSys_in_2.mf_key = 'sys_LoD'
        self.connect('LoD_sys.outputs_all', 'postprocess.fuzzSys_in_2.mf_dict')

        ## CONNECT FoM System
        self.connect("input_list.VL_SYS_e_d",
                     "fuzz_combine_FoM.in_1.input_value")
        self.connect("input_list.VL_SYS_PROP_sigma",
                     "fuzz_combine_FoM.in_2.input_value")
        self.connect("input_list.VL_SYS_w",
                     "fuzz_combine_FoM.in_3.input_value")
        self.connect("input_list.VL_SYS_DRV_eta_d",
                     "fuzz_combine_FoM.in_4.input_value")

        self.connect("fuzz_combine_FoM.system_inputs", "FoM_sys.input_list")
        self.connect("fuzz_combine_FoM.runFlag_out", "FoM_sys.runFlag_in")

        self.postprocess.fuzzSys_in_3.mf_key = 'sys_FoM'
        self.connect('FoM_sys.outputs_all', 'postprocess.fuzzSys_in_3.mf_dict')

        ## CONNECT etaP System
        self.connect("input_list.FWD_SYS_eta_p",
                     "fuzz_combine_etaP.in_1.input_value")
        self.connect("input_list.FWD_DRV_eta_d",
                     "fuzz_combine_etaP.in_2.input_value")

        self.connect("fuzz_combine_etaP.system_inputs", "etaP_sys.input_list")
        self.connect("fuzz_combine_etaP.runFlag_out", "etaP_sys.runFlag_in")

        self.postprocess.fuzzSys_in_4.mf_key = 'sys_etaP'
        self.connect('etaP_sys.outputs_all',
                     'postprocess.fuzzSys_in_4.mf_dict')

        self.postprocess.PLOTMODE = 0

        ## CONNECT RF Systems
        self.connect('phi_sys.outputs_all',
                     'quantifyPHI.inDict')  #key defined below
        self.connect('input_list.ENG_SYS_TYPE_SFC', 'quantifySFC.qualVal')

        #GWT:
        self.connect("quantifyPHI.quantVal",
                     "fuzz_combine_GWT.in_1.input_value")
        self.connect("input_list.VL_SYS_w",
                     "fuzz_combine_GWT.in_2.input_value")
        self.connect("input_list.WING_SYS_TYPE_WS",
                     "fuzz_combine_GWT.in_3.input_value")
        self.connect("etaP_sys.outputs_all",
                     "fuzz_combine_GWT.inDict_1.input_dict")
        self.connect("input_list.VL_SYS_DRV_eta_d",
                     "fuzz_combine_GWT.in_4.input_value")
        self.connect("FoM_sys.outputs_all",
                     "fuzz_combine_GWT.inDict_2.input_dict")
        self.connect("input_list.VL_SYS_e_d",
                     "fuzz_combine_GWT.in_5.input_value")
        self.connect("quantifySFC.quantVal",
                     "fuzz_combine_GWT.in_6.input_value")
        self.connect("input_list.SYS_type",
                     "fuzz_combine_GWT.in_7.input_value")
        #self.connect("input_list.SYS_tech",         "fuzz_combine_GWT.in_8.input_value")

        self.connect("fuzz_combine_GWT.system_inputs", "GWT_sys.input_list")
        self.connect("fuzz_combine_GWT.runFlag_out", "GWT_sys.runFlag_in")

        self.postprocess.fuzzSys_in_5.mf_key = 'sys_GWT'
        self.connect('GWT_sys.outputs_all', 'postprocess.fuzzSys_in_5.mf_dict')

        #Power Installed:
        self.connect("quantifyPHI.quantVal", "fuzz_combine_P.in_1.input_value")
        self.connect("input_list.VL_SYS_w", "fuzz_combine_P.in_2.input_value")
        self.connect("input_list.WING_SYS_TYPE_WS",
                     "fuzz_combine_P.in_3.input_value")
        self.connect("etaP_sys.outputs_all",
                     "fuzz_combine_P.inDict_1.input_dict")
        self.connect("input_list.VL_SYS_DRV_eta_d",
                     "fuzz_combine_P.in_4.input_value")
        self.connect("FoM_sys.outputs_all",
                     "fuzz_combine_P.inDict_2.input_dict")
        self.connect("input_list.VL_SYS_e_d",
                     "fuzz_combine_P.in_5.input_value")
        self.connect("quantifySFC.quantVal", "fuzz_combine_P.in_6.input_value")
        self.connect("input_list.SYS_type", "fuzz_combine_P.in_7.input_value")
        #self.connect("input_list.SYS_tech",         "fuzz_combine_P.in_8.input_value")

        self.connect("fuzz_combine_P.system_inputs", "P_sys.input_list")
        self.connect("fuzz_combine_P.runFlag_out", "P_sys.runFlag_in")

        self.postprocess.fuzzSys_in_6.mf_key = 'sys_P'
        self.connect('P_sys.outputs_all', 'postprocess.fuzzSys_in_6.mf_dict')

        #VH:
        self.connect("quantifyPHI.quantVal",
                     "fuzz_combine_VH.in_1.input_value")
        self.connect("input_list.VL_SYS_w", "fuzz_combine_VH.in_2.input_value")
        self.connect("input_list.WING_SYS_TYPE_WS",
                     "fuzz_combine_VH.in_3.input_value")
        self.connect("etaP_sys.outputs_all",
                     "fuzz_combine_VH.inDict_1.input_dict")
        self.connect("input_list.VL_SYS_DRV_eta_d",
                     "fuzz_combine_VH.in_4.input_value")
        self.connect("FoM_sys.outputs_all",
                     "fuzz_combine_VH.inDict_2.input_dict")
        self.connect("input_list.VL_SYS_e_d",
                     "fuzz_combine_VH.in_5.input_value")
        self.connect("quantifySFC.quantVal",
                     "fuzz_combine_VH.in_6.input_value")
        self.connect("input_list.SYS_type", "fuzz_combine_VH.in_7.input_value")
        #self.connect("input_list.SYS_tech",         "fuzz_combine_VH.in_8.input_value")

        self.connect("fuzz_combine_VH.system_inputs", "VH_sys.input_list")
        self.connect("fuzz_combine_VH.runFlag_out", "VH_sys.runFlag_in")

        self.postprocess.fuzzSys_in_7.mf_key = 'sys_VH'
        self.connect('VH_sys.outputs_all', 'postprocess.fuzzSys_in_7.mf_dict')

        ######
        # Design Variables
        self.input_list.input_file = 'data/morphInputs_13Jun15.csv'

        ## SET VARIABLES phi system
        self.phi_sys.TESTMODE = 0
        self.phi_sys.TESTPLOT = 0
        self.phi_sys.fcl_file = 'FCL_files/FRBS_phi/PHIsys_trained_5-2In9-2Out_gauss250tData_50vData_optInputsBEST_GA.fcl'

        self.fuzz_combine_phi.in_1.input_key = 'VL_SYS_TYPE_phi'
        self.fuzz_combine_phi.in_2.input_key = 'VL_SYS_TYPE_w'
        self.fuzz_combine_phi.in_3.input_key = 'VL_SYS_TYPE_f'
        self.fuzz_combine_phi.in_4.input_key = 'VL_SYS_PROP_w'
        self.fuzz_combine_phi.in_5.input_key = 'VL_SYS_PROP_phi'
        self.fuzz_combine_phi.in_6.input_key = 'VL_SYS_TECH_phi'
        self.fuzz_combine_phi.in_7.input_key = 'VL_SYS_TECH_w'
        self.fuzz_combine_phi.in_8.input_key = 'VL_SYS_TECH_f'
        self.fuzz_combine_phi.in_9.input_key = 'VL_SYS_TECH_LD'
        self.fuzz_combine_phi.in_10.input_key = 'FWD_SYS_PROP_eta_p'
        self.fuzz_combine_phi.in_11.input_key = 'FWD_SYS_DRV_eta_d'
        self.fuzz_combine_phi.in_12.input_key = 'FWD_SYS_TYPE_phi'
        self.fuzz_combine_phi.in_13.input_key = 'FWD_SYS_TYPE_TP'
        self.fuzz_combine_phi.in_14.input_key = 'WING_SYS_TYPE_LD'
        self.fuzz_combine_phi.in_15.input_key = 'WING_SYS_TYPE_f'

        ## SET VARIABLES LoD system
        self.LoD_sys.TESTMODE = 0
        self.LoD_sys.TESTPLOT = 0
        self.LoD_sys.fcl_file = 'FCL_files/LoDsys_simple_13Jun15.fcl'

        self.fuzz_combine_LD.in_1.input_key = 'SYSTEM_f'
        self.fuzz_combine_LD.in_2.input_key = 'WING_LoD'

        ## SET VARIABLES FoM system
        self.FoM_sys.weight_file = 'FCL_files/DFES_FoM/DFES_FOMdata_data(500)_nodes(160_50_50).nwf'
        self.FoM_sys.inRanges = {
            'VL_SYS_e_d': [0.0, 0.3],
            'VL_SYS_PROP_sigma': [0.05, 0.4],
            'VL_SYS_w': [0., 150.],
            'VL_SYS_DRV_eta': [0.5, 1.0],
        }
        self.FoM_sys.inOrder = [
            'VL_SYS_e_d', 'VL_SYS_w', 'VL_SYS_DRV_eta', 'VL_SYS_PROP_sigma'
        ]
        self.FoM_sys.outRanges = {'sys_FoM': [0.4, 1.0]}
        self.FoM_sys.actType = 'sigmoid'
        self.FoM_sys.hidNodes = 160
        self.FoM_sys.inGran = 50
        self.FoM_sys.outGran = 50

        self.FoM_sys.TESTPLOT = 0

        self.fuzz_combine_FoM.in_1.input_key = 'VL_SYS_e_d'
        self.fuzz_combine_FoM.in_2.input_key = 'VL_SYS_PROP_sigma'
        self.fuzz_combine_FoM.in_3.input_key = 'VL_SYS_w'
        self.fuzz_combine_FoM.in_4.input_key = 'VL_SYS_DRV_eta'

        ## SET VARIABLES etaP system
        self.etaP_sys.TESTMODE = 0
        self.etaP_sys.TESTPLOT = 0
        self.etaP_sys.fcl_file = 'FCL_files/etaPsys_simple_14Aug15.fcl'

        self.fuzz_combine_etaP.in_1.input_key = 'FWD_SYS_eta_p'
        self.fuzz_combine_etaP.in_2.input_key = 'FWD_DRV_eta_d'

        ## SET VARIABLES RF systems
        self.quantifyPHI.quantRange = [0.85, 0.50]
        self.quantifyPHI.inKey = 'sys_phi'
        self.quantifySFC.quantRange = [0.75, 0.35]

        ## SET VARIABLES RF:
        #GWT:
        self.GWT_sys.weight_file = 'FCL_files/DFES_RF/BEST/RFdata20Aug_DFES_GWT_30_250_50.nwf'
        self.GWT_sys.inRanges = {
            'SYSTEM_QUANT_PHI': [0.5, 0.85],
            'VL_SYS_w': [1., 150.],
            'WING_SYS_TYPE_WS': [15., 300.],
            'sys_etaP': [0.6, 1.0],
            'VL_SYS_DRV_eta_d': [0.7, 1.0],
            'sys_FoM': [0.3, 1.0],
            'VL_SYS_e_d': [0.0, 0.3],
            'ENG_SYS_TYPE_SFC': [0.35, 0.75],
            'SYS_type': [0.5, 3.5],
        }

        self.GWT_sys.inOrder = [
            'VL_SYS_e_d', 'WING_SYS_TYPE_WS', 'SYSTEM_QUANT_PHI', 'SYS_type',
            'VL_SYS_DRV_eta_d', 'sys_FoM', 'VL_SYS_w', 'sys_etaP',
            'ENG_SYS_TYPE_SFC'
        ]
        #['SYSTEM_QUANT_PHI', 'VL_SYS_w', 'WING_SYS_TYPE_WS', 'sys_etaP',
        #    'VL_SYS_DRV_eta_d', 'sys_FoM','VL_SYS_e_d', 'ENG_SYS_TYPE_SFC', 'SYS_type']
        self.GWT_sys.outRanges = {'sys_GWT': [5000, 50000]}
        self.GWT_sys.actType = 'sigmoid'
        self.GWT_sys.hidNodes = 250
        self.GWT_sys.inGran = 30
        self.GWT_sys.outGran = 50

        self.fuzz_combine_GWT.in_1.input_key = 'SYSTEM_QUANT_PHI'
        self.fuzz_combine_GWT.in_2.input_key = 'VL_SYS_w'
        self.fuzz_combine_GWT.in_3.input_key = 'WING_SYS_TYPE_WS'
        self.fuzz_combine_GWT.inDict_1.input_keys = ['sys_etaP']
        self.fuzz_combine_GWT.in_4.input_key = 'VL_SYS_DRV_eta_d'
        self.fuzz_combine_GWT.inDict_2.input_keys = ['sys_FoM']
        self.fuzz_combine_GWT.in_5.input_key = 'VL_SYS_e_d'
        self.fuzz_combine_GWT.in_6.input_key = 'ENG_SYS_TYPE_SFC'
        self.fuzz_combine_GWT.in_7.input_key = 'SYS_type'
        #self.fuzz_combine_GWT.in_8.input_key ='SYS_tech'

        #P installed:
        self.P_sys.weight_file = 'FCL_files/DFES_RF/BEST/RFdata20Aug_DFES_Pin_30_250_50.nwf'
        self.P_sys.TESTPLOT = 0
        self.P_sys.inRanges = {
            'SYSTEM_QUANT_PHI': [0.5, 0.85],
            'VL_SYS_w': [1., 150.],
            'WING_SYS_TYPE_WS': [15., 300.],
            'sys_etaP': [0.6, 1.0],
            'VL_SYS_DRV_eta_d': [0.7, 1.0],
            'sys_FoM': [0.3, 1.0],
            'VL_SYS_e_d': [0.0, 0.3],
            'ENG_SYS_TYPE_SFC': [0.35, 0.75],
            'SYS_type': [0.5, 3.5],
        }
        self.P_sys.inOrder = [
            'VL_SYS_e_d', 'WING_SYS_TYPE_WS', 'SYSTEM_QUANT_PHI', 'SYS_type',
            'VL_SYS_DRV_eta_d', 'sys_FoM', 'VL_SYS_w', 'sys_etaP',
            'ENG_SYS_TYPE_SFC'
        ]
        #['SYSTEM_QUANT_PHI', 'VL_SYS_w', 'WING_SYS_TYPE_WS', 'sys_etaP',
        # 'VL_SYS_DRV_eta_d', 'sys_FoM','VL_SYS_e_d', 'ENG_SYS_TYPE_SFC', 'SYS_type']
        self.P_sys.outRanges = {'sys_P': [1000, 15000]}
        self.P_sys.actType = 'sigmoid'
        self.P_sys.hidNodes = 250
        self.P_sys.inGran = 30
        self.P_sys.outGran = 50

        self.fuzz_combine_P.in_1.input_key = 'SYSTEM_QUANT_PHI'
        self.fuzz_combine_P.in_2.input_key = 'VL_SYS_w'
        self.fuzz_combine_P.in_3.input_key = 'WING_SYS_TYPE_WS'
        self.fuzz_combine_P.inDict_1.input_keys = ['sys_etaP']
        self.fuzz_combine_P.in_4.input_key = 'VL_SYS_DRV_eta_d'
        self.fuzz_combine_P.inDict_2.input_keys = ['sys_FoM']
        self.fuzz_combine_P.in_5.input_key = 'VL_SYS_e_d'
        self.fuzz_combine_P.in_6.input_key = 'ENG_SYS_TYPE_SFC'
        self.fuzz_combine_P.in_7.input_key = 'SYS_type'
        #self.fuzz_combine_P.in_8.input_key ='SYS_tech'

        #VH:
        self.VH_sys.weight_file = 'FCL_files/DFES_RF/BEST/RFdata20Aug_DFES_VH_40_250_50.nwf'
        self.VH_sys.inRanges = {
            'SYSTEM_QUANT_PHI': [0.5, 0.85],
            'VL_SYS_w': [1., 150.],
            'WING_SYS_TYPE_WS': [15., 300.],
            'sys_etaP': [0.6, 1.0],
            'VL_SYS_DRV_eta_d': [0.7, 1.0],
            'sys_FoM': [0.3, 1.0],
            'VL_SYS_e_d': [0.0, 0.3],
            'ENG_SYS_TYPE_SFC': [0.35, 0.75],
            'SYS_type': [0.5, 3.5],
        }
        self.VH_sys.inOrder = [
            'VL_SYS_e_d', 'WING_SYS_TYPE_WS', 'SYSTEM_QUANT_PHI', 'SYS_type',
            'VL_SYS_DRV_eta_d', 'sys_FoM', 'VL_SYS_w', 'sys_etaP',
            'ENG_SYS_TYPE_SFC'
        ]
        #['SYSTEM_QUANT_PHI', 'VL_SYS_w', 'WING_SYS_TYPE_WS', 'sys_etaP',
        #'VL_SYS_DRV_eta_d', 'sys_FoM','VL_SYS_e_d', 'ENG_SYS_TYPE_SFC', 'SYS_type']
        self.VH_sys.outRanges = {'sys_VH': [200, 500]}
        self.VH_sys.actType = 'sigmoid'
        self.VH_sys.hidNodes = 250
        self.VH_sys.inGran = 40
        self.VH_sys.outGran = 50

        self.fuzz_combine_VH.in_1.input_key = 'SYSTEM_QUANT_PHI'
        self.fuzz_combine_VH.in_2.input_key = 'VL_SYS_w'
        self.fuzz_combine_VH.in_3.input_key = 'WING_SYS_TYPE_WS'
        self.fuzz_combine_VH.inDict_1.input_keys = ['sys_etaP']
        self.fuzz_combine_VH.in_4.input_key = 'VL_SYS_DRV_eta_d'
        self.fuzz_combine_VH.inDict_2.input_keys = ['sys_FoM']
        self.fuzz_combine_VH.in_5.input_key = 'VL_SYS_e_d'
        self.fuzz_combine_VH.in_6.input_key = 'ENG_SYS_TYPE_SFC'
        self.fuzz_combine_VH.in_7.input_key = 'SYS_type'

        # CONFIGURE DRIVER
        self.driver.iprint = 0  # Driver Flags

        self.driver.add_parameter(
            'compatibility.option1')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option2')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option3')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option4')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option5')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option6')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option7')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option8')  #list of options as input
        self.driver.add_parameter(
            'compatibility.option9')  #list of options as input

        self.driver.add_response(
            'postprocess.ranges_out')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_1')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_1_r')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_2')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_2_r')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_3')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_3_r')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_4')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_4_r')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_5')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_5_r')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_6')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_6_r')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_7')  #output from system (dict)
        self.driver.add_response(
            'postprocess.response_7_r')  #output from system (dict)

        #TEST ALTERNATIVES:
        """
        tests = [   [5, 1, 1, 1, 1, 1, 1, 1, 1],
                    [5, 1, 1, 1, 1, 1, 1, 3, 1],
                    [5, 1, 1, 1, 1, 1, 2, 1, 3],]
        
        self.driver.case_inputs.compatibility.option1 = [t[0] for t in tests]
        self.driver.case_inputs.compatibility.option2 = [t[1] for t in tests]
        self.driver.case_inputs.compatibility.option3 = [t[2] for t in tests]
        self.driver.case_inputs.compatibility.option4 = [t[3] for t in tests]
        self.driver.case_inputs.compatibility.option5 = [t[4] for t in tests]
        self.driver.case_inputs.compatibility.option6 = [t[5] for t in tests]
        self.driver.case_inputs.compatibility.option7 = [t[6] for t in tests]
        self.driver.case_inputs.compatibility.option8 = [t[7] for t in tests]
        self.driver.case_inputs.compatibility.option9 = [t[8] for t in tests]
        """

        #PRE-SELECTED ALTERNATIVES:
        """
        self.driver.case_inputs.compatibility.option1 = [2, 2, 4, 4, 1, 1, 6, 4, 1, 5]
        self.driver.case_inputs.compatibility.option2 = [2, 1, 3, 3, 2, 2, 2, 3, 2, 3]
        self.driver.case_inputs.compatibility.option3 = [1, 1, 3, 1, 2, 1, 1, 1, 2, 1]
        self.driver.case_inputs.compatibility.option4 = [2, 2, 1, 2, 3, 5, 2, 1, 5, 1]
        self.driver.case_inputs.compatibility.option5 = [2, 1, 4, 3, 4, 1, 2, 1, 4, 3]
        self.driver.case_inputs.compatibility.option6 = [1, 1, 3, 1, 3, 1, 1, 1, 3, 1]
        self.driver.case_inputs.compatibility.option7 = [2, 2, 1, 2, 1, 1, 2, 1, 1, 4]
        self.driver.case_inputs.compatibility.option8 = [1, 5, 2, 4, 6, 1, 1, 4, 1, 1]
        self.driver.case_inputs.compatibility.option9 = [1, 1, 2, 1, 3, 1, 1, 1, 3, 4]
        """

        #CREATE RANDOM ALTERNTIVES:
        """
        n = 10000

        self.driver.case_inputs.compatibility.option1 = [random.randrange(1,7) for i in range(n)]
        self.driver.case_inputs.compatibility.option2 = [random.randrange(1,4) for i in range(n)]
        self.driver.case_inputs.compatibility.option3 = [random.randrange(1,4) for i in range(n)]
        self.driver.case_inputs.compatibility.option4 = [random.randrange(1,6) for i in range(n)]
        self.driver.case_inputs.compatibility.option5 = [random.randrange(1,5) for i in range(n)]
        self.driver.case_inputs.compatibility.option6 = [random.randrange(1,4) for i in range(n)]
        self.driver.case_inputs.compatibility.option7 = [random.randrange(1,5) for i in range(n)]
        self.driver.case_inputs.compatibility.option8 = [random.randrange(1,7) for i in range(n)]
        self.driver.case_inputs.compatibility.option9 = [random.randrange(1,5) for i in range(n)]
        """

        #ALL COMPATIBLE COMBOS:
        nMax = None

        o_cases = [[] for i in range(9)]
        with open('compatCombos.csv', 'rb') as csvfile:
            reader = csv.reader(csvfile, delimiter=',')
            for row in reader:
                if int(row[1]) <> 4 and int(row[2]) <> 4:  #remove bad options
                    #print "case:", row
                    for i in range(len(row)):
                        o_cases[i].append(int(row[i]))
                #print "captured:", [o[-1] for o in o_cases]
        print len(o_cases[0]), "compatible combos read. Running cases..."

        #for i in range(len(o_cases)): o_cases[i] = list(reversed(o_cases[i]))[:1000]

        if nMax is None:
            self.driver.case_inputs.compatibility.option1 = o_cases[0]
            self.driver.case_inputs.compatibility.option2 = o_cases[1]
            self.driver.case_inputs.compatibility.option3 = o_cases[2]
            self.driver.case_inputs.compatibility.option4 = o_cases[3]
            self.driver.case_inputs.compatibility.option5 = o_cases[4]
            self.driver.case_inputs.compatibility.option6 = o_cases[5]
            self.driver.case_inputs.compatibility.option7 = o_cases[6]
            self.driver.case_inputs.compatibility.option8 = o_cases[7]
            self.driver.case_inputs.compatibility.option9 = o_cases[8]
        else:
            cnums = random.sample(range(len(o_cases[0])), nMax)
            self.driver.case_inputs.compatibility.option1 = [
                o_cases[0][i] for i in cnums
            ]
            self.driver.case_inputs.compatibility.option2 = [
                o_cases[1][i] for i in cnums
            ]
            self.driver.case_inputs.compatibility.option3 = [
                o_cases[2][i] for i in cnums
            ]
            self.driver.case_inputs.compatibility.option4 = [
                o_cases[3][i] for i in cnums
            ]
            self.driver.case_inputs.compatibility.option5 = [
                o_cases[4][i] for i in cnums
            ]
            self.driver.case_inputs.compatibility.option6 = [
                o_cases[5][i] for i in cnums
            ]
            self.driver.case_inputs.compatibility.option7 = [
                o_cases[6][i] for i in cnums
            ]
            self.driver.case_inputs.compatibility.option8 = [
                o_cases[7][i] for i in cnums
            ]
            self.driver.case_inputs.compatibility.option9 = [
                o_cases[8][i] for i in cnums
            ]

        self.recorders = [CSVCaseRecorder(filename='randomCompatCases.csv')]

        self.recording_options.includes = [
            'compatibility.gen_num', 'compatibility.option1',
            'compatibility.option2', 'compatibility.option3',
            'compatibility.option4', 'compatibility.option5',
            'compatibility.option6', 'compatibility.option7',
            'compatibility.option8', 'compatibility.option9',
            "compatibility.compatibility", 'postprocess.response_1',
            'postprocess.response_2', 'postprocess.response_3',
            'postprocess.response_4', 'postprocess.response_5',
            'postprocess.response_6', 'postprocess.response_7',
            'postprocess.response_1_r', 'postprocess.response_2_r',
            'postprocess.response_3_r', 'postprocess.response_4_r',
            'postprocess.response_5_r', 'postprocess.response_6_r',
            'postprocess.response_7_r', 'postprocess.response_1_POS',
            'postprocess.response_2_POS', 'postprocess.response_3_POS',
            'postprocess.response_4_POS', 'postprocess.response_5_POS',
            'postprocess.response_6_POS', 'postprocess.response_7_POS',
            'postprocess.fuzzyPOS'
        ]


#if __name__ == "__main__":
#    None