コード例 #1
0
ファイル: model.py プロジェクト: FraSanvit/calliope
def load_results(backend_model, results, opt):
    """Load results into model instance for access via model variables."""
    termination = results.solver.termination_condition

    if termination == pe.TerminationCondition.optimal:
        try:
            opt.load_vars()
            this_result = True
        except AttributeError:
            this_result = backend_model.solutions.load_from(results)

    if termination != pe.TerminationCondition.optimal or this_result is False:
        logger.critical("Problem status:")
        for l in str(results.Problem).split("\n"):
            logger.critical(l)
        logger.critical("Solver status:")
        for l in str(results.Solver).split("\n"):
            logger.critical(l)

        if termination != pe.TerminationCondition.optimal:
            message = "Model solution was non-optimal."
        else:
            message = "Could not load results into model instance."

        exceptions.BackendWarning(message)

    return str(termination)
コード例 #2
0
def load_results(backend_model, results):
    """Load results into model instance for access via model variables."""
    not_optimal = results["Solver"][0]["Termination condition"].key != "optimal"
    this_result = backend_model.solutions.load_from(results)

    if this_result is False or not_optimal:
        logger.critical("Problem status:")
        for l in str(results.Problem).split("\n"):
            logger.critical(l)
        logger.critical("Solver status:")
        for l in str(results.Solver).split("\n"):
            logger.critical(l)

        if not_optimal:
            message = "Model solution was non-optimal."
        else:
            message = "Could not load results into model instance."

        exceptions.BackendWarning(message)

    return results["Solver"][0]["Termination condition"].key
コード例 #3
0
ファイル: model.py プロジェクト: JoKoo619/calliope
def load_results(backend_model, results):
    """Load results into model instance for access via model variables."""
    not_optimal = (results['Solver'][0]['Termination condition'].key !=
                   'optimal')
    this_result = backend_model.solutions.load_from(results)

    if this_result is False or not_optimal:
        logger.critical('Problem status:')
        for l in str(results.Problem).split('\n'):
            logger.critical(l)
        logger.critical('Solver status:')
        for l in str(results.Solver).split('\n'):
            logger.critical(l)

        if not_optimal:
            message = 'Model solution was non-optimal.'
        else:
            message = 'Could not load results into model instance.'

        exceptions.BackendWarning(message)

    return results['Solver'][0]['Termination condition'].key