Exemple #1
0
def solve_network(n, config, solver_log=None, opts='', **kwargs):
    solver_options = config['solving']['solver'].copy()
    solver_name = solver_options.pop('name')
    cf_solving = config['solving']['options']
    track_iterations = cf_solving.get('track_iterations', False)
    min_iterations = cf_solving.get('min_iterations', 4)
    max_iterations = cf_solving.get('max_iterations', 6)

    # add to network for extra_functionality
    n.config = config
    n.opts = opts

    if cf_solving.get('skip_iterations', False):
        network_lopf(n,
                     solver_name=solver_name,
                     solver_options=solver_options,
                     extra_functionality=None,
                     **kwargs)
    else:
        ilopf(n,
              solver_name=solver_name,
              solver_options=solver_options,
              track_iterations=track_iterations,
              min_iterations=min_iterations,
              max_iterations=max_iterations,
              extra_functionality=None,
              **kwargs)
    return n
Exemple #2
0
def solve_network(n,
                  config,
                  solver_log=None,
                  opts="",
                  extra_functionality=None,
                  **kwargs):
    solver_options = config["solving"]["solver"].copy()
    solver_name = solver_options.pop("name")
    track_iterations = config["solving"]["options"].get(
        "track_iterations", False)
    min_iterations = config["solving"]["options"].get("min_iterations", 4)
    max_iterations = config["solving"]["options"].get("max_iterations", 6)

    # add to network for extra_functionality
    n.config = config
    n.opts = opts

    if config["solving"]["options"].get("skip_iterations", False):
        network_lopf(n,
                     solver_name=solver_name,
                     solver_options=solver_options,
                     extra_functionality=extra_functionality,
                     **kwargs)
    else:
        ilopf(n,
              solver_name=solver_name,
              solver_options=solver_options,
              track_iterations=track_iterations,
              min_iterations=min_iterations,
              max_iterations=max_iterations,
              extra_functionality=extra_functionality,
              **kwargs)
    return n