Beispiel #1
0
def _generate_solar_cells(already_added_cells:MutableSequence[EnergyGenerationPart],
                          power_requirements:float, possible_cell_list:Iterable[EnergyGenerationPart],
                          first_order_check:TPredFunc, distance:float, solar_cell:EnergyGenerationPart=None,
                          *args, **kwargs):
    if solar_cell is not None:
        already_added_cells = copy.copy(already_added_cells)
        power_requirements -= _add_solar_cells(already_added_cells, solar_cell, power_requirements,
                                               distance) * solar_cell.getChargeRate(distance)

    if power_requirements > 0:
        sats = []
        if solar_cell is not None:
            oldRate = solar_cell.getChargeRate(distance)
            possible_cell_list = [cell for cell in possible_cell_list if cell.getChargeRate(distance) >= oldRate]
        if first_order_check is None:
            useful_cells = possible_cell_list
        else:
            useful_cells = _test_func2(possible_cell_list, first_order_check,
                                      distance, power_requirements, *args, **kwargs)
        for cell in useful_cells:
            newlist = _generate_solar_cells(already_added_cells, power_requirements, possible_cell_list,
                                           first_order_check, distance, solar_cell=cell)
            sats.extend(newlist)
        return sats
    else:
        return [already_added_cells]
Beispiel #2
0
def _add_solar_cells(cell_list:MutableSequence[EnergyGenerationPart], solar_cell:EnergyGenerationPart,
                     power_requirements:float, distance:float) -> int:
    n = max(1, math.floor(power_requirements / solar_cell.getChargeRate(distance)))
    for i in range(n):
        cell_list.append(solar_cell)
    return n