Beispiel #1
0
def test_TopFarmListRecorder_continue(tf_generator, load_case, n_rec, n_fev):

    D = 80.0
    D2 = 2 * D + 10
    init_pos = np.array([(0, 2 * D), (0, 0), (0, -2 * D)])
    init_pos[:, 0] += [-40, 0, 40]

    pyFuga = test_pyfuga.get_fuga()(init_pos[:, 0],
                                    init_pos[:, 1],
                                    wind_atlas='MyFarm/north_pm45_only.lib')
    boundary = [(-D2, -D2), (D2, D2)]
    plot_comp = XYPlotComp()
    plot_comp = NoPlot()
    tf = TopFarmProblem(
        dict(zip('xy', init_pos.T)),
        cost_comp=pyFuga.get_TopFarm_cost_component(),
        constraints=[
            SpacingConstraint(2 * D),
            XYBoundaryConstraint(boundary, 'square')
        ],
        driver=EasyScipyOptimizeDriver(tol=1e-10, disp=False),
        plot_comp=plot_comp,
        record_id=tfp +
        'recordings/test_TopFarmListRecorder_continue:%s' % load_case,
        expected_cost=25)

    _, _, recorder = tf.optimize()
    # Create test file:
    # 1) delete file "test_files/recordings/test_TopFarmListRecorder_continue"
    # 2) Uncomment line below, run and recomment
    # if load_case=="": recorder.save() # create test file
    npt.assert_equal(recorder.driver_cases.num_cases, n_rec)
    npt.assert_equal(tf.driver.result['nfev'], n_fev)

    tf.plot_comp.show()
Beispiel #2
0
 def __init__(self, cost_comp, turbineTypes, lower, upper, turbineXYZ, boundary_comp, min_spacing=None,
              driver=EasyRandomSearchDriver(random_search_driver.RandomizeTurbineTypeAndPosition()), plot_comp=None, record_id=None, expected_cost=1):
     sys.stderr.write("%s is deprecated. Use TopFarmProblem instead\n" % self.__class__.__name__)
     TopFarmProblem.__init__(self, cost_comp, driver, plot_comp, record_id, expected_cost)
     TurbineTypeOptimizationProblem.initialize(self, turbineTypes, lower, upper)
     TurbineXYZOptimizationProblem.initialize(self, turbineXYZ, boundary_comp, min_spacing)
     self.setup(check=True, mode=self.mode)
Beispiel #3
0
    def __init__(self, cost_comp, turbineXYZ, boundary_comp, min_spacing=None,
                 driver=ScipyOptimizeDriver(), plot_comp=None, record_id=None, expected_cost=1):
        sys.stderr.write("%s is deprecated. Use TopFarmProblem instead\n" % self.__class__.__name__)
        if plot_comp:
            if plot_comp == "default":
                plot_comp = PlotComp()
        turbineXYZ = np.asarray(turbineXYZ)
        design_vars = {xy: v for xy, v in zip([topfarm.x_key, topfarm.y_key], turbineXYZ.T)}
        constraints = []
        if min_spacing:
            constraints.append(SpacingConstraint(min_spacing))

        if isinstance(boundary_comp, PolygonBoundaryComp):
            constraints.append(XYBoundaryConstraint(boundary_comp.xy_boundary, 'polygon'))
        elif len(boundary_comp.xy_boundary):
            constraints.append(XYBoundaryConstraint(boundary_comp.xy_boundary, boundary_comp.boundary_type))

        if turbineXYZ.shape[1] == 3:
            if len(boundary_comp.z_boundary):
                design_vars[topfarm.z_key] = (turbineXYZ[:, 2], boundary_comp.z_boundary[:, 0], boundary_comp.z_boundary[:, 1])
            else:
                design_vars[topfarm.z_key] = turbineXYZ[:, 2]

        TopFarmProblem.__init__(
            self,
            design_vars=design_vars,
            cost_comp=cost_comp,
            driver=driver,
            constraints=constraints,
            plot_comp=plot_comp,
            record_id=record_id,
            expected_cost=expected_cost)
        self.setup()
Beispiel #4
0
def testAEP_topfarm_optimization_2tb_scale(get_fuga, scale):
    D = 80.0
    B = 2 * D + 10
    init_pos = np.array([(-10, 1 * D), (10, -D)])

    wind_atlas = 'MyFarm/north_pm30_only.lib'
    pyFuga = get_fuga(init_pos[:1, 0], init_pos[:1, 1], wind_atlas=wind_atlas)
    AEP_pr_tb = pyFuga.get_aep()[1]
    pyFuga = get_fuga(init_pos[:, 0], init_pos[:, 1], wind_atlas=wind_atlas)
    boundary = [(-B, B), (B, B), (B, -B), (-B, -B), (-B, B)]

    plot_comp = NoPlot()
    # plot_comp = PlotComp()

    cost_comp = AEPCostModelComponent(
        'xy',
        init_pos.shape[0],
        lambda x, y: scale * pyFuga.get_aep(np.array([x, y]).T)[0],  # only aep
        lambda x, y: scale * pyFuga.get_aep_gradients(np.array([x, y]).T)[:2]
    )  # only dAEPdx and dAEPdy

    tf = TopFarmProblem(
        dict(zip('xy', init_pos.T)),
        cost_comp,
        constraints=[SpacingConstraint(2 * D),
                     XYBoundaryConstraint(boundary)],
        plot_comp=plot_comp,
        driver=EasyScipyOptimizeDriver(tol=1e-8, disp=False),
        expected_cost=AEP_pr_tb * 2 * scale)
    cost, _, rec = tf.optimize()
    tf.plot_comp.show()
    uta.assertAlmostEqual(-cost / scale, AEP_pr_tb * 2, delta=.02)
Beispiel #5
0
    def __init__(self, cost_comp, turbineTypes, lower, upper, **kwargs):
        sys.stderr.write("%s is deprecated. Use TopFarmProblem instead\n" % self.__class__.__name__)

        TopFarmProblem.__init__(self,
                                design_vars={topfarm.type_key: (turbineTypes, lower, upper)},
                                cost_comp=cost_comp,
                                **kwargs)
        self.setup()
def test_TopFarmProblem_with_cirleboundary_constraint():
    optimal = np.array([(0, 0)])
    desvar = dict(zip('xy', optimal.T))

    b = CircleBoundaryConstraint([2, 2], 2)
    tf = TopFarmProblem(desvar, DummyCost(optimal, 'xy'), constraints=[b])
    _, state, _ = tf.optimize()

    npt.assert_array_less((state['x'] - 2)**2 + (state['y'] - 2)**2, 9)
def test_turbineType_optimization():
    optimal = np.array([[1], [0]])
    tf = TopFarmProblem(design_vars={'type': (optimal[:, 0], 0, 1)},
                        cost_comp=DummyCost(optimal_state=optimal,
                                            inputs=['type']),
                        driver=DOEDriver(FullFactorialGenerator(2)))
    cost, state, _ = tf.optimize()
    assert cost == 0
    npt.assert_array_equal(state['type'], [1, 0])
def test_TopFarmProblem_with_cirleboundary_constraint_and_limits():
    optimal = np.array([(0, 0)])
    desvar = {'x': ([0], 1, 4), 'y': [0]}

    b = CircleBoundaryConstraint([2, 2], 2)
    tf = TopFarmProblem(desvar, DummyCost(optimal, 'xy'), constraints=[b])
    _, state, _ = tf.optimize()

    npt.assert_array_less((state['x'] - 2)**2 + (state['y'] - 2)**2, 9)
    npt.assert_array_less(.9999999, state['x'])
Beispiel #9
0
def test_TopFarmListRecorder_continue_wrong_recorder(tf_generator):

    tf = TopFarmProblem({'type': ([0, 0, 0], 0, 1)},
                        cost_comp=DummyCost(np.array([[0, 1, 0]]).T, ['type']),
                        driver=EasyScipyOptimizeDriver(disp=False),
                        record_id=tfp +
                        'recordings/test_TopFarmListRecorder_continue:latest')

    tf.optimize()
    assert 'type' in tf.recorder.keys()
    assert 'x' not in tf.recorder.keys()
def test_TopFarmProblem_with_cirleboundary_gradients():
    optimal = np.array([(0, 0)])
    desvar = dict(zip('xy', optimal.T + 1.5))
    plot_comp = NoPlot()
    b = CircleBoundaryConstraint([1, 2], 3)
    tf = TopFarmProblem(desvar,
                        DummyCost(optimal, 'xy'),
                        constraints=[b],
                        plot_comp=plot_comp,
                        driver=SimpleGADriver())
    tf.check_gradients(True)
def main():
    if __name__ == '__main__':
        # ------------------------ INPUTS ------------------------

        # define the conditions for the wind farm
        positions = np.array([[0, 0], [6, 6]])  # initial turbine pos
        optimal_types = np.array([[2], [6]])  # optimal layout

        # ===============================================================================
        # Setup the problem and plotting
        # ===============================================================================

        try:
            import matplotlib.pyplot as plt
            plt.gcf()
            plot_comp = TurbineTypePlotComponent(
                turbine_type_names=["Turbine %d" % i for i in range(5)],
                plot_initial=False,
                delay=0.1,
                legendloc=0)
            plot = True
        except RuntimeError:
            plot_comp = NoPlot()
            plot = False

        # create the wind farm
        tf = TopFarmProblem(
            design_vars={'type': ([0, 0], 0, 4)},
            cost_comp=DummyCost(optimal_types, ['type']),
            plot_comp=plot_comp,
            driver=FullFactorialGenerator(5),
            ext_vars={
                'x': positions[:, 0],
                'y': positions[:, 1]
            },
        )

        # ===============================================================================
        # #  Run the optimization
        # ===============================================================================
        state = {}
        cost, state, recorder = tf.optimize(state)

        # ===============================================================================
        # plot and prin the the final, optimal types
        # ===============================================================================
        print(state['type'])
        tf.evaluate(state)

        # save the figure
        if plot:
            folder, file = os.path.split(__file__)
            plt.savefig(folder + "/figures/" + file.replace('.py', '.png'))
            plt.show()
def test_TopFarmProblem_with_cirleboundary_plot():
    if os.name == 'posix' and "DISPLAY" not in os.environ:
        pytest.xfail("No display")
    optimal = np.array([(0, 0)])
    desvar = dict(zip('xy', optimal.T))
    plot_comp = PlotComp()
    b = CircleBoundaryConstraint([1, 2], 3)
    tf = TopFarmProblem(desvar,
                        DummyCost(optimal, 'xy'),
                        constraints=[b],
                        plot_comp=plot_comp)
    tf.evaluate()
Beispiel #13
0
def test_NOJ_Topfarm(aep_calc):
    init_pos = aep_calc.wake_model.windFarm.pos
    with warnings.catch_warnings(
    ):  # suppress "warning, make sure that this position array is oriented in ndarray([n_wt, 2]) or ndarray([n_wt, 3])"
        warnings.simplefilter("ignore")
        tf = TopFarmProblem(dict(zip('xy', init_pos.T)),
                            aep_calc.get_TopFarm_cost_component(),
                            constraints=[
                                SpacingConstraint(160),
                                XYBoundaryConstraint(init_pos, 'square')
                            ])
        tf.evaluate()
    assert tf.cost == -18.90684500124578
Beispiel #14
0
def main():
    if __name__ == '__main__':
        # define the conditions for the wind farm
        boundary = [(0, 0), (6, 0), (6, -10), (0, -10)]  # turbine boundaries
        initial = np.array([[6, 0], [6, -8], [1, 1], [-1, -8]])  # initial turbine pos
        desired = np.array([[3, -3], [7, -7], [4, -3], [3, -7]])  # desired turbine pos
        optimal = np.array([[2.5, -3], [6, -7], [4.5, -3], [3, -7]])  # optimal layout
        min_spacing = 2  # min distance between turbines

        # ------------------------ OPTIMIZATION ------------------------

        # create the wind farm and run the optimization

        def wt_cost(i, x, y):
            time.sleep(0.01)
            return (desired[i, 0] - x[i])**2 + (desired[i, 1] - y[i])**2

        n_wt = len(initial)
        comps = [CostModelComponent('xy', 4,
                                    cost_function=lambda x, y, i=i:wt_cost(i, x, y),
                                    objective=False,
                                    output_key='cost%d' % i) for i in range(n_wt)]

        def sum_map(**kwargs):

            return np.sum([kwargs['cost%d' % i] for i in range(n_wt)])

        comps.append(CostModelComponent(['cost%d' % i for i in range(n_wt)], 1,
                                        cost_function=sum_map,
                                        objective=True))
        cost_comp = TopFarmParallelGroup(comps)

        tf = TopFarmProblem(
            design_vars={'x': initial[:, 0], 'y': initial[:, 1]},
            cost_comp=cost_comp,
            constraints=[XYBoundaryConstraint(boundary),
                         SpacingConstraint(min_spacing)],
#            plot_comp=DummyCostPlotComp(desired),
            plot_comp=NoPlot(),
            driver=EasyScipyOptimizeDriver()
        )
#        view_model(tf)
        #print(tf.evaluate({'x': desired[:, 0], 'y': desired[:, 1]}))
        print(tf.evaluate({'x': optimal[:, 0], 'y': optimal[:, 1]}, disp=False))
        #print(tf.evaluate({'x': initial[:, 0], 'y': initial[:, 1]}))
#        tic = time.time()
        cost, state, recorder = tf.optimize()
#        toc = time.time()
#        print('optimized in {:.3f}s '.format(toc-tic))
        tf.plot_comp.show()
def main():
    if __name__ == '__main__':
        n_wt = 16
        site = IEA37Site(n_wt)
        windTurbines = IEA37_WindTurbines()
        windFarmModel = IEA37SimpleBastankhahGaussian(site, windTurbines)
        tf = TopFarmProblem(
            design_vars=dict(zip('xy', site.initial_position.T)),
            cost_comp=PyWakeAEPCostModelComponent(windFarmModel, n_wt),
            driver=EasyRandomSearchDriver(
                randomize_func=RandomizeTurbinePosition_Circle(), max_iter=5),
            constraints=[CircleBoundaryConstraint([0, 0], 1300.1)],
            plot_comp=XYPlotComp())
        tf.optimize()
        tf.plot_comp.show()
Beispiel #16
0
def main():
    if __name__ == '__main__':
        site = IEA37Site(16)
        windTurbines = IEA37_WindTurbines()
        wake_model = IEA37SimpleBastankhahGaussian(windTurbines)
        aep_calc = PyWakeAEP(site, windTurbines, wake_model)
        tf = TopFarmProblem(
            design_vars=dict(zip('xy', site.initial_position.T)),
            cost_comp=aep_calc.get_TopFarm_cost_component(16),
            driver=EasyRandomSearchDriver(
                randomize_func=RandomizeTurbinePosition_Circle(), max_iter=5),
            constraints=[CircleBoundaryConstraint([0, 0], 1300.1)],
            plot_comp=XYPlotComp())
        # tf.evaluate()
        tf.optimize()
        tf.plot_comp.show()
Beispiel #17
0
    def _topfarm_obj(driver,
                     xy_scale=[1, 1],
                     cost_scale=1,
                     cost_offset=0,
                     spacing=2):
        from topfarm.cost_models.dummy import DummyCostPlotComp

        # plot_comp = DummyCostPlotComp(desired[:,:2] * xy_scale, plot_improvements_only=True)
        plot_comp = NoPlot()

        class DummyCostScaled(DummyCost):
            def cost(self, **kwargs):
                opt = self.optimal_state
                return np.sum([(kwargs[n] - opt[:, i])**2
                               for i, n in enumerate(self.input_keys)
                               ]) * cost_scale + cost_offset

            def grad(self, **kwargs):
                opt = self.optimal_state
                return [(2 * cost_scale * (kwargs[n] - opt[:, i]))
                        for i, n in enumerate(self.input_keys)]

        return TopFarmProblem(dict(zip('xy', (initial[:, :2] * xy_scale).T)),
                              DummyCostScaled(desired[:, :2] * xy_scale),
                              constraints=[
                                  SpacingConstraint(spacing * xy_scale[0]),
                                  XYBoundaryConstraint(boundary * xy_scale)
                              ],
                              driver=driver,
                              plot_comp=plot_comp,
                              expected_cost=1.5 * cost_scale)
Beispiel #18
0
    def tf(xy_boundary=[(0, 0), (4, 4)],
           z_boundary=(0, 4),
           xy_boundary_type='square',
           **kwargs):
        optimal = [(0, 2, 4), (4, 2, 1)]
        xyz = np.array([(0, 1, 0), (1, 1, 1)])
        p1 = DummyCost(optimal, 'xyz')
        design_vars = dict(zip('xy', xyz.T))
        design_vars['z'] = (xyz[:, 2], z_boundary[0], z_boundary[1])
        k = {
            'design_vars':
            design_vars,
            'cost_comp':
            p1,
            'driver':
            EasyScipyOptimizeDriver(optimizer='COBYLA', disp=False,
                                    maxiter=10),
        }
        k.update(kwargs)

        return TopFarmProblem(constraints=[
            XYBoundaryConstraint(xy_boundary, xy_boundary_type),
            SpacingConstraint(2)
        ],
                              **k)
Beispiel #19
0
def get_InitialXYZOptimizationProblem(driver):
    optimal = [(1, 0, 4),
               (0, 1, 3)]
    return TopFarmProblem(
        design_vars={'x': [0, 2], 'y': [0, 2], 'z': ([0, 2], 3, 4)},
        cost_comp=DummyCost(optimal, ['x', 'y', 'z']),
        constraints=[XYBoundaryConstraint([(10, 6), (11, 8)], 'rectangle')],
        driver=driver)
Beispiel #20
0
def get_tf(init_pos, pyFuga, boundary, boundary_type='convex_hull'):
    return TopFarmProblem(dict(zip('xy', init_pos.T)),
                          pyFuga.get_TopFarm_cost_component(),
                          constraints=[
                              SpacingConstraint(160),
                              XYBoundaryConstraint(boundary, boundary_type)
                          ],
                          driver=EasyScipyOptimizeDriver(disp=False))
Beispiel #21
0
 def get_tf(wake_model):
     return TopFarmProblem(
         design_vars=dict(zip('xy', init_pos.T)),
         cost_comp=AEPCalculator(wind_res, wake_model,
                                 wdir=np.arange(0, 360, 12)
                                 ).get_TopFarm_cost_component(),
         constraints=[SpacingConstraint(min_spacing),
                      XYBoundaryConstraint(boundary)],
         driver=EasyScipyOptimizeDriver())
Beispiel #22
0
def get_tf(**kwargs):
    k = {'cost_comp': DummyCost(desired[:, :2], [topfarm.x_key, topfarm.y_key]),
         'design_vars': {topfarm.x_key: initial[:, 0], topfarm.y_key: initial[:, 1]},
         'driver': EasyScipyOptimizeDriver(disp=False),
         'plot_comp': NoPlot(),
         'constraints': [SpacingConstraint(2), XYBoundaryConstraint(boundary)]}

    k.update(kwargs)
    return TopFarmProblem(**k)
def test_z_boundary():
    optimal = np.array([(0, 0, 0)]).T
    tf = TopFarmProblem({'z': (optimal, 70, 90)},
                        DummyCost(optimal, 'z'),
                        driver=SimpleGADriver())

    desvars = tf.driver._designvars
    np.testing.assert_array_equal(desvars['indeps.z']['lower'], [70, 70])
    np.testing.assert_array_equal(desvars['indeps.z']['upper'], [90, 90])
def get_tf(initial, optimal, boundary, plot_comp=NoPlot()):
    initial, optimal = map(np.array, [initial, optimal])
    return TopFarmProblem(
        {
            'x': initial[:, 0],
            'y': initial[:, 1]
        },
        DummyCost(optimal),
        constraints=[XYBoundaryConstraint(boundary, 'polygon')],
        driver=EasyScipyOptimizeDriver(tol=1e-8, disp=False),
        plot_comp=plot_comp)
Beispiel #25
0
def test_NestedTopFarmListRecorder(tf_generator):
    optimal = [(0, 2, 4, 1), (4, 2, 1, 0)]
    type_lst = [[0, 0], [1, 0], [0, 1]]
    p1 = DummyCost(optimal_state=optimal, inputs=['x', 'y', 'z', 'type'])
    p2 = tf_generator(cost_comp=p1, driver=EasyScipyOptimizeDriver(disp=False))

    tf = TopFarmProblem({'type': ([0, 0], 0, 1)},
                        cost_comp=p2,
                        driver=DOEDriver(
                            ListGenerator([[('type', t)] for t in type_lst])))

    cost, _, recorder = tf.optimize()
    npt.assert_almost_equal(cost, 0)
    npt.assert_array_almost_equal(recorder.get('type'), type_lst)
    npt.assert_array_almost_equal(recorder.get('cost'), [1, 0, 2])

    for sub_rec in recorder.get('recorder'):
        npt.assert_array_almost_equal(
            np.array([sub_rec[k][-1] for k in ['x', 'y', 'z']]).T,
            np.array(optimal)[:, :3])
Beispiel #26
0
 def __init__(self, turbines, cost_comp, min_spacing, boundary,
              boundary_type='convex_hull', plot_comp=None,
              driver=ScipyOptimizeDriver(),
              record_id="Opt_%s" % time.strftime("%Y%m%d_%H%M%S"),
              expected_cost=1):
     sys.stderr.write("%s is deprecated. Use TopFarmProblem instead\n" % self.__class__.__name__)
     constraints = []
     if min_spacing and len(turbines) > 1:
         constraints.append(SpacingConstraint(min_spacing))
     if boundary is not None:
         constraints.append(XYBoundaryConstraint(boundary, boundary_type))
     TopFarmProblem.__init__(
         self,
         design_vars={k: v for k, v in zip([topfarm.x_key, topfarm.y_key, topfarm.z_key], np.asarray(turbines).T)},
         cost_comp=cost_comp,
         driver=driver,
         constraints=constraints,
         plot_comp=plot_comp,
         record_id=record_id,
         expected_cost=expected_cost)
     self.setup()
def test_turbineXYZ_optimization():
    optimal = np.array([(5, 4, 3), (3, 2, 1)])
    turbineXYZ = np.array([[0, 0, 0], [2, 2, 2]])
    design_vars = {k: v for k, v in zip('xy', turbineXYZ.T)}
    design_vars['z'] = (turbineXYZ[:, 2], 1, 4)

    xy_boundary = [(0, 0), (5, 5)]
    tf = TopFarmProblem(
        design_vars=design_vars,
        cost_comp=DummyCost(optimal, 'xyz'),
        driver=EasyScipyOptimizeDriver(disp=False),
        constraints=[XYBoundaryConstraint(xy_boundary, 'square')])

    cost, state = tf.evaluate()
    assert cost == 52
    np.testing.assert_array_equal(state['x'], [0, 2])

    cost = tf.optimize()[0]
    assert cost < 1e6
    np.testing.assert_array_almost_equal(tf.turbine_positions, optimal[:, :2],
                                         3)
Beispiel #28
0
def test_random_search_driver_randomize_all_uniform():
    np.random.seed(1)

    class Cost():
        i = 0

        def __call__(self, *args, **kwargs):
            self.i += 1
            return self.i

    cost_comp = CostModelComponent(input_keys=['x', 'y', 'type'],
                                   n_wt=2,
                                   cost_function=Cost(),
                                   income_model=True)

    tf = TopFarmProblem(
        {
            'x': ([1, 6], [0, 1], [5, 6]),
            'y': ([-1., 0], -6, 0),
            'type': ([3, 3], 3, 8)
        },
        cost_comp=cost_comp,
        constraints=[],
        driver=EasyRandomSearchDriver(randomize_func=RandomizeAllUniform(
            ['x', 'type']),
                                      max_iter=600,
                                      disp=False),
    )
    _, state, recorder = tf.optimize()

    # check that integer design variables are somewhat evenly distributed
    x, y, t = recorder['x'], recorder['y'], recorder['type']
    for arr, l, u in [(x[:, 0], 0, 5), (x[:, 1], 1, 6), (t[:, 0], 3, 8)]:
        count = [(arr == i).sum() for i in range(l, u + 1)]
        npt.assert_equal(601, sum(count))
        npt.assert_array_less(600 / len(count) * .70, count)

    count, _ = np.histogram(y[:, 0], np.arange(-6, 1))
    npt.assert_equal(y.shape[0], sum(count))
    npt.assert_array_less(600 / len(count) * .70, count)
Beispiel #29
0
 def get_tf(windFarmModel):
     return TopFarmProblem(design_vars=dict(zip('xy', init_pos.T)),
                           cost_comp=PyWakeAEPCostModelComponent(
                               windFarmModel,
                               n_wt=3,
                               ws=10,
                               wd=np.arange(0, 360, 12)),
                           constraints=[
                               SpacingConstraint(min_spacing),
                               XYBoundaryConstraint(boundary)
                           ],
                           driver=EasyScipyOptimizeDriver(),
                           plot_comp=plot_comp())
Beispiel #30
0
    def _topfarm_obj(driver, spacing=2, keys='xy'):
        # from topfarm.cost_models.dummy import DummyCostPlotComp
        # plot_comp = DummyCostPlotComp(desired[:,:len(keys)], plot_improvements_only=True)
        plot_comp = NoPlot()

        return TopFarmProblem(dict(zip(keys, initial.T[:len(keys)])),
                              DummyCost(desired[:, :len(keys)], keys),
                              constraints=[
                                  SpacingConstraint(spacing),
                                  XYBoundaryConstraint(boundary)
                              ],
                              plot_comp=plot_comp,
                              driver=driver,
                              expected_cost=1.5)