Example #1
0
def test_constraints(building, parameters):
    """Testing for expected output with certain constraints, also acts as a test for using NSGAII"""

    objectives = ['Electricity:Facility', 'Gas:Facility']
    problem = EPProblem(inputs=parameters,
                        outputs=objectives,
                        constraints=['CO2:Facility'], constraint_bounds=['>=750'])

    evaluator = EvaluatorEP(problem, building)

    results = NSGAII(evaluator, evaluations=10, population_size=2)

    value = results.iloc[0]['CO2:Facility'] + results.iloc[0]['violation']
    assert value >= 750, f'Constraint did not effect output, value should be above 750 but was: {value}'

    #Check to make sure the output changes with different constraints
    problem = EPProblem(inputs=parameters,
                        outputs=objectives,
                        constraints=['CO2:Facility'], constraint_bounds=['<=750'])

    evaluator = EvaluatorEP(problem, building)

    results = NSGAII(evaluator, evaluations=10, population_size=2)

    value = results.iloc[0]['CO2:Facility'] - results.iloc[0]['violation']
    assert value <= 750, f'Constraint did not effect output, value should be below 750 but was: {value}'

    #change this to 0 to see stdout and stderr
    assert 1
Example #2
0
def problem():
    parameters = expand_plist(
    {'Mass NonRes Wall Insulation':
     {'Thickness': (0.01, 0.99)},
     'NonRes Fixed Assembly Window':
     {'U-Factor':(0.1,5),
      'Solar Heat Gain Coefficient':(0.01,0.99)}
    })
    return EPProblem(parameters, ['Electricity:Facility'])
def problem():
    problem = EPProblem([
        Parameter(
            FieldSelector(object_name='Mass NonRes Wall Insulation',
                          field_name='Thickness'),
            RangeParameter(min_val=0.01, max_val=0.99)),
        Parameter(
            FieldSelector(class_name='Construction',
                          object_name='ext-slab',
                          field_name='Outside Layer'),
            CategoryParameter(options=('HW CONCRETE', 'Invalid Material')))
    ])
    return problem
def problem():
    parameters = [
        Parameter(
            FieldSelector(object_name='Mass NonRes Wall Insulation',
                          field_name='Thickness'))
    ]
    objectives = ['Electricity:Facility',
                  'Gas:Facility']  # the default is just 'Electricity:Facility'

    problem = EPProblem(
        parameters,
        objectives)  #EPP Problem automatically converts these to MeterReaders
    return problem
def test_init(building, parameters):
    """Testing the initialization and functionality of an adaptive surrogate model"""

    problem = EPProblem(parameters)
    evaluator = EvaluatorEP(problem, building)

    inputs = sampling.dist_sampler(sampling.seeded_sampler, problem, 10)
    inputs = sampling.add_extremes(inputs, problem)

    #using the custom class for our own model training
    k = KirgingEval(reference=evaluator)
    k.do_infill(inputs)
    k.model.train()
    k.infill(5)

    #change this to 0 to see stdout and stderr
    assert 1
Example #6
0
def test_objectives(building, parameters):
    """Testing custom functions and basic objective creation"""

    def variance(result):
        return result.data['Value'].var()

    objectives = [MeterReader('Electricity:Facility', name='Electricity Usage'),
              MeterReader('Electricity:Facility',func=variance, name='Electricity Variance')]
    problem = EPProblem(inputs=parameters, outputs=objectives)

    evaluator = EvaluatorEP(problem, building)
    samples = sampling.dist_sampler(sampling.seeded_sampler, problem, 10)
    results = evaluator.df_apply(samples, keep_input=True)

    value = results.iloc[0]['Electricity Variance']

    assert np.isclose(value, 829057663033101.1), f'Unexpected value when using custom function:{value}'
    #change this to 0 to see stdout and stderr
    assert 1
def problem(parameters):
    objectives = ['Electricity:Facility']
    problem = EPProblem(parameters, objectives)
    return problem
Example #8
0
def problem(parameters):
    objectives = ['Electricity:Facility', 'Gas:Facility']
    return EPProblem(parameters, objectives)