Esempio n. 1
0
def set_parser(subparsers):
    algorithms = list_available_algorithms()
    logger.debug('Available DCOP algorithms %s', algorithms)

    parser = subparsers.add_parser('orchestrator',
                                   help='run a standalone orchestrator')
    parser.set_defaults(func=run_cmd)
    parser.set_defaults(on_timeout=on_timeout)
    parser.set_defaults(on_force_exit=on_force_exit)

    parser.add_argument('dcop_files', type=str, nargs='+', help="dcop file(s)")
    parser.add_argument('-a',
                        '--algo',
                        choices=algorithms,
                        help='algorithm for solving the dcop')
    parser.add_argument('-p',
                        '--algo_params',
                        type=str,
                        nargs='*',
                        help='parameters for the algorithm , given as '
                        'name:value. Several parameter can be given.')

    parser.add_argument('-d',
                        '--distribution',
                        choices=['oneagent', 'adhoc', 'ilp_fgdp'],
                        help='algorithm for distributing the computation '
                        'graph')
Esempio n. 2
0
def set_parser(subparsers):

    algorithms = list_available_algorithms()
    logger.debug('Available DCOP algorithms %s', algorithms)

    parser = subparsers.add_parser('solve',
                                   help='solve static dcop')
    parser.set_defaults(func=run_cmd)
    parser.set_defaults(on_timeout=on_timeout)
    parser.set_defaults(on_force_exit=on_force_exit)

    parser.add_argument('dcop_files', type=str,  nargs='+',
                        help="The DCOP, in one or several yaml file(s)")

    parser.add_argument('-a', '--algo',
                        choices=algorithms, required=True,
                        help='The algorithm for solving the dcop')
    parser.add_argument('-p', '--algo_params',
                        type=str, nargs='*',
                        help='Optional parameters for the algorithm , given as '
                             'name:value. Several parameters can be given.')

    parser.add_argument('-d', '--distribution', type=str,
                        default='oneagent',
                        help='A yaml file with the distribution or algorithm '
                             'for distributing the computation graph, if not '
                             'given the `oneagent` will be used (one '
                             'computation for each agent)')
    parser.add_argument('-m', '--mode',
                        default='thread',
                        choices=['thread', 'process'],
                        help='run agents as threads or processes')

    parser.add_argument('-c', '--collect_on',
                        choices=['value_change', 'cycle_change', 'period'],
                        default='value_change',
                        help='When should a "new" assignment be observed')

    parser.add_argument('--period', type=float,
                        default=None,
                        help='Period for collecting metrics. only available '
                             'when using --collect_on period. Defaults to 1 '
                             'second if not specified')

    parser.add_argument('--run_metrics', type=str,
                        default=None,
                        help="Use this option to regularly store the data "
                             "in a csv file.")

    parser.add_argument('--end_metrics', type=str,
                        default=None,
                        help="Use this option to append the metrics of the "
                             "end of the run to a csv file.")

    parser.add_argument('--infinity', '-i', default=float('inf'),
                        type=float,
                        help='Argument to determine the value used for '
                             'infinity in case of hard constraints, '
                             'for algorithms that do not use symbolic '
                             'infinity. Defaults to 10 000')
Esempio n. 3
0
def set_parser(subparsers):

    algorithms = list_available_algorithms()

    parser = subparsers.add_parser('distribute',
                                   help='distribute a static dcop')
    parser.set_defaults(func=run_cmd)

    parser.add_argument('dcop_files', type=str, nargs='+', metavar='FILE',
                        help="dcop file(s)")

    parser.add_argument('-g', '--graph',
                        required=False,
                        choices=['factor_graph', 'pseudotree',
                                 'constraints_hypergraph'],
                        help='graphical model for dcop computations')

    parser.add_argument('-d', '--dist',
                        choices=['oneagent', 'adhoc', 'ilp_fgdp',
                                 'ilp_compref', 'heur_comhost'],
                        required=True,
                        help='algorithm for distributing the computation '
                             'graph')

    parser.add_argument('-a', '--algo',
                        choices=algorithms,
                        required=False,
                        help='Optional, only needed for '
                              'distribution methods that require '
                              'the memory footprint and '
                              'communication load for computations')
Esempio n. 4
0
def test_load_algorithm():

    # We test load for all available algorithms
    for a in list_available_algorithms():
        algo = load_algorithm_module(a)

        assert algo.algorithm_name == a
        assert hasattr(algo, "communication_load")
        assert hasattr(algo, "computation_memory")
Esempio n. 5
0
def set_parser(subparsers):

    algorithms = list_available_algorithms()

    parser = subparsers.add_parser("distribute", help="distribute a static dcop")
    parser.set_defaults(func=run_cmd)
    parser.set_defaults(on_timeout=on_timeout)

    parser.add_argument(
        "dcop_files", type=str, nargs="+", metavar="FILE", help="dcop file(s)"
    )

    parser.add_argument(
        "-g",
        "--graph",
        required=False,
        choices=["factor_graph", "pseudotree", "constraints_hypergraph"],
        help="Graphical model for dcop computations.",
    )

    parser.add_argument(
        "-d",
        "--distribution",
        choices=[
            "oneagent",
            "adhoc",
            "ilp_fgdp",
            "ilp_compref",
            "heur_comhost",
            "gh_secp_cgdp",
            "gh_secp_fgdp",
            "oilp_secp_fgdp",
            "oilp_secp_cgdp",
            "oilp_cgdp",
            "gh_cgdp",
        ],
        required=True,
        help="Algorithm for distributing the computation " "graph.",
    )

    parser.add_argument(
        "--cost",
        choices=["ilp_compref", "oilp_secp_fgdp", "oilp_secp_cgdp", "oilp_cgdp"],
        default=None,
        help="algorithm for computing the cost of the " "distribution.",
    )

    parser.add_argument(
        "-a",
        "--algo",
        choices=algorithms,
        required=False,
        help="Optional, only needed for "
        "distribution methods that require "
        "the memory footprint and "
        "communication load for computations",
    )
Esempio n. 6
0
def set_parser(subparsers):

    algorithms = list_available_algorithms()
    logger.debug("Available DCOP algorithms %s", algorithms)

    parser = subparsers.add_parser("replica_dist",
                                   help="distribution replicas ")
    parser.set_defaults(func=run_cmd)
    parser.set_defaults(on_timeout=on_timeout)
    parser.set_defaults(on_force_exit=on_force_exit)

    parser.add_argument("dcop_files", type=str, nargs="+", help="dcop file")

    parser.add_argument("-k",
                        "--ktarget",
                        required=True,
                        type=int,
                        help="Requested resiliency level")
    parser.add_argument(
        "-r",
        "--replication",
        required=True,
        type=str,
        choices=["dist_ucs", "dist_ucs_hostingcosts"],
        help="Replication distribution algorithm",
    )

    # Distribution given as a file
    parser.add_argument(
        "-d",
        "--distribution",
        type=str,
        help="File containing the distribution of computations "
        "on the agents",
    )
    # algo used when running the dcop
    parser.add_argument(
        "-a",
        "--algo",
        choices=algorithms,
        help="Algorithm for solving the dcop, necessary to "
        "know the footprint of computation when "
        "distributing replicas on agents",
    )

    parser.add_argument(
        "-m",
        "--mode",
        default="thread",
        choices=["thread", "process"],
        help="run agents as threads or processes",
    )
Esempio n. 7
0
def set_parser(subparsers):

    algorithms = list_available_algorithms()
    logger.debug('Available DCOP algorithms %s', algorithms)

    parser = subparsers.add_parser('replica_dist',
                                   help='distribution replicas ')
    parser.set_defaults(func=run_cmd)
    parser.set_defaults(on_timeout=on_timeout)
    parser.set_defaults(on_force_exit=on_force_exit)

    parser.add_argument('dcop_files', type=str, nargs='+', help="dcop file")

    parser.add_argument('-k',
                        '--ktarget',
                        required=True,
                        type=int,
                        help='Requested resiliency level')
    parser.add_argument('-r',
                        '--replication',
                        required=True,
                        type=str,
                        choices=['dist_ucs', 'dist_ucs_hostingcosts'],
                        help='Replication distribution algorithm')

    # Distribution given as a file
    parser.add_argument(
        '-d',
        '--distribution',
        type=str,
        help='File containing the distribution of computations '
        'on the agents')
    # algo used when running the dcop
    parser.add_argument('-a',
                        '--algo',
                        choices=algorithms,
                        help='Algorithm for solving the dcop, necessary to '
                        'know the footprint of computation when '
                        'distributing replicas on agents')

    parser.add_argument('-m',
                        '--mode',
                        default='thread',
                        choices=['thread', 'process'],
                        help='run agents as threads or processes')
Esempio n. 8
0
def set_parser(subparsers):
    algorithms = list_available_algorithms()
    logger.debug("Available DCOP algorithms %s", algorithms)

    parser = subparsers.add_parser("orchestrator",
                                   help="run a standalone orchestrator")
    parser.set_defaults(func=run_cmd)
    parser.set_defaults(on_timeout=on_timeout)
    parser.set_defaults(on_force_exit=on_force_exit)

    parser.add_argument("dcop_files", type=str, nargs="+", help="dcop file(s)")
    parser.add_argument("-a",
                        "--algo",
                        choices=algorithms,
                        help="algorithm for solving the dcop")

    parser.add_argument(
        "-p",
        "--algo_params",
        type=str,
        action="append",
        help="Optional parameters for the algorithm, given as "
        "name:value. Use this option several times "
        "to set several parameters.",
    )

    parser.add_argument(
        "-d",
        "--distribution",
        default="oneagent",
        help="A yaml file with the distribution or algorithm "
        "for distributing the computation graph, if not "
        "given the `oneagent` will be used (one "
        "computation for each agent)",
    )

    parser.add_argument(
        "-c",
        "--collect_on",
        choices=["value_change", "cycle_change", "period"],
        default="value_change",
        help='When should a "new" assignment be observed',
    )

    parser.add_argument(
        "--period",
        type=float,
        default=None,
        help="Period for collecting metrics. only available "
        "when using --collect_on period. Defaults to 1 "
        "second if not specified",
    )

    parser.add_argument(
        "--run_metrics",
        type=str,
        default=None,
        help="Use this option to regularly store the data "
        "in a csv file.",
    )

    parser.add_argument(
        "--end_metrics",
        type=str,
        default=None,
        help="Use this option to append the metrics of the "
        "end of the run to a csv file.",
    )

    parser.add_argument(
        "--address",
        type=str,
        default=None,
        help="IP address the orchestrator will listen on. If "
        "not given we try to use the primary IP address.",
    )

    parser.add_argument(
        "--port",
        type=int,
        default=None,
        help="Port the orchestrator will listen on. If "
        "not given we try to use port 9000.",
    )

    parser.add_argument(
        "--uiport",
        type=int,
        default=None,
        help="The port on which the ui-server will be listening"
        ". If not given, no ui-server will "
        "be started for this orchestrator.",
    )

    parser.add_argument(
        "--ktarget",
        type=int,
        default=None,
        help="The target resiliency level. If not given, computations are "
        "not replicated and the system is not resilient.",
    )

    parser.add_argument(
        "-s",
        "--scenario",
        required=False,
        default=None,
        help=
        "scenario file. When using a scenario, replication is automatically activated",
    )
Esempio n. 9
0
def set_parser(subparsers):

    algorithms = list_available_algorithms()
    logger.debug("Available DCOP algorithms %s", algorithms)

    parser = subparsers.add_parser("solve", help="solve static dcop")
    parser.set_defaults(func=run_cmd)
    parser.set_defaults(on_timeout=on_timeout)
    parser.set_defaults(on_force_exit=on_force_exit)

    parser.add_argument(
        "dcop_files",
        type=str,
        nargs="+",
        help="The DCOP, in one or several yaml file(s)",
    )

    parser.add_argument(
        "-a",
        "--algo",
        choices=algorithms,
        required=True,
        help="The algorithm for solving the dcop",
    )
    parser.add_argument(
        "-p",
        "--algo_params",
        type=str,
        action="append",
        help="Optional parameters for the algorithm, given as "
        "name:value. Use this option several times "
        "to set several parameters.",
    )

    parser.add_argument(
        "-d",
        "--distribution",
        type=str,
        default="oneagent",
        help="A yaml file with the distribution or algorithm "
        "for distributing the computation graph, if not "
        "given the `oneagent` will be used (one "
        "computation for each agent)",
    )
    parser.add_argument(
        "-m",
        "--mode",
        default="thread",
        choices=["thread", "process"],
        help="run agents as threads or processes",
    )

    parser.add_argument(
        "-c",
        "--collect_on",
        choices=["value_change", "cycle_change", "period"],
        default=None,
        help='When should a "new" assignment be observed',
    )

    parser.add_argument(
        "--period",
        type=float,
        default=None,
        help="Period for collecting metrics. only available "
        "when using --collect_on period. Defaults to 1 "
        "second if not specified",
    )

    parser.add_argument(
        "--run_metrics",
        type=str,
        default=None,
        help="Path to a file or file name. Run-time metrics will "
        "be written to that file (csv format). If the value is a "
        "path, the directory will be created if it does not exist. "
        "Otherwise the file will be created in the current directory.",
    )

    parser.add_argument(
        "--end_metrics",
        type=str,
        default=None,
        help="Path to a file or file name. Result's metrics will "
        "be appended to that file (csv format). If the value is a "
        "path, the directory will be created if it does not exist. "
        "Otherwise the file will be created in the current directory.",
    )

    parser.add_argument(
        "--infinity",
        "-i",
        default=float("inf"),
        type=float,
        help="Argument to determine the value used for "
        "infinity in case of hard constraints, "
        "for algorithms that do not use symbolic "
        "infinity. Defaults to 10 000",
    )

    parser.add_argument(
        "--delay",
        default=None,
        type=float,
        help="an optional delay between message delivery, "
        " in second. This delay only applies to "
        "algorithm's messages and is useful when you "
        "want to observe (for example with the UI) the "
        "behavior of the algorithm at runtime",
    )

    parser.add_argument(
        "--uiport",
        type=int,
        default=None,
        help="The port on which the ui-server will be "
        "listening. This port is used for the orchestrator"
        "and incremented for each following agent. If not "
        "given, no ui-server will be started for any "
        "agent.",
    )
Esempio n. 10
0
def set_parser(subparsers):

    algorithms = list_available_algorithms()
    logger.debug("Available DCOP algorithms %s", algorithms)
    parser = subparsers.add_parser("run", help="run a dcop")

    parser.set_defaults(func=run_cmd)
    parser.set_defaults(on_timeout=on_timeout)
    parser.set_defaults(on_force_exit=on_force_exit)

    parser.add_argument("dcop_files", type=str, nargs="+", help="dcop file")

    parser.add_argument(
        "-a",
        "--algo",
        required=True,
        choices=algorithms,
        help="algorithm for solving the dcop",
    )
    parser.add_argument(
        "-p",
        "--algo_params",
        type=str,
        action="append",
        help="Optional parameters for the algorithm, given as "
        "name:value. Use this option several times "
        "to set several parameters.",
    )

    parser.add_argument(
        "-d",
        "--distribution",
        required=True,
        help="distribution of the computations on agents, "
        "as a yaml file ",
    )

    # FIXME: allow loading replica dist from file and pass it to the
    # orchestrator
    # parser.add_argument('-r', '--replica_dist',
    #                    help='distribution of the computations replicas on '
    #                         'agents, as a yaml file ')

    parser.add_argument(
        "-r",
        "--replication_method",
        default="dist_ucs_hostingcosts",
        help="replication method",
    )
    parser.add_argument("-k",
                        "--ktarget",
                        default=3,
                        type=int,
                        help="Requested resiliency level")

    parser.add_argument("-s",
                        "--scenario",
                        required=True,
                        help="scenario file")

    parser.add_argument(
        "-m",
        "--mode",
        default="thread",
        choices=["thread", "process"],
        help="run agents as threads or processes",
    )

    # Statistics collection arguments:
    parser.add_argument(
        "-c",
        "--collect_on",
        choices=["value_change", "cycle_change", "period"],
        default="value_change",
        help='When should a "new" assignment be observed',
    )
    parser.add_argument(
        "--period",
        type=float,
        default=None,
        help="Period for collecting metrics. only available "
        "when using --collect_on period. Defaults to 1 "
        "second if not specified",
    )
    parser.add_argument(
        "--run_metrics",
        type=str,
        default=None,
        help="Use this option to regularly store the data "
        "in a csv file.",
    )
    parser.add_argument(
        "--end_metrics",
        type=str,
        default=None,
        help="Use this option to append the metrics of the "
        "end of the run to a csv file.",
    )

    # TODO : remove, this should no be at this level
    parser.add_argument(
        "--infinity",
        "-i",
        default=float("inf"),
        type=float,
        help="Argument to determine the value used for "
        "infinity in case of hard constraints, "
        "for algorithms that do not use symbolic "
        "infinity. Defaults to 10 000",
    )
Esempio n. 11
0
def set_parser(subparsers):

    algorithms = list_available_algorithms()
    logger.debug('Available DCOP algorithms %s', algorithms)
    parser = subparsers.add_parser('run', help='run a dcop')

    parser.set_defaults(func=run_cmd)
    parser.set_defaults(on_timeout=on_timeout)
    parser.set_defaults(on_force_exit=on_force_exit)

    parser.add_argument('dcop_files', type=str, nargs='+', help="dcop file")

    parser.add_argument('-a',
                        '--algo',
                        required=True,
                        choices=algorithms,
                        help='algorithm for solving the dcop')
    parser.add_argument('-p',
                        '--algo_params',
                        type=str,
                        nargs='*',
                        help='parameters for the algorithm , given as '
                        'name:value. Several parameters can be given.')

    parser.add_argument('-d',
                        '--distribution',
                        required=True,
                        help='distribution of the computations on agents, '
                        'as a yaml file ')

    # FIXME: allow loading replica dist from file and pass it to the
    # orchestrator
    #parser.add_argument('-r', '--replica_dist',
    #                    help='distribution of the computations replicas on '
    #                         'agents, as a yaml file ')

    parser.add_argument('-r',
                        '--replication_method',
                        required=True,
                        help='replication method')
    parser.add_argument('-k',
                        '--ktarget',
                        required=True,
                        type=int,
                        help='Requested resiliency level')

    parser.add_argument('-s',
                        '--scenario',
                        required=True,
                        help='scenario file')

    parser.add_argument('-m',
                        '--mode',
                        default='thread',
                        choices=['thread', 'process'],
                        help='run agents as threads or processes')

    # Statistics collection arguments:
    parser.add_argument('-c',
                        '--collect_on',
                        choices=['value_change', 'cycle_change', 'period'],
                        default='value_change',
                        help='When should a "new" assignment be observed')
    parser.add_argument('--period',
                        type=float,
                        default=None,
                        help='Period for collecting metrics. only available '
                        'when using --collect_on period. Defaults to 1 '
                        'second if not specified')
    parser.add_argument('--run_metrics',
                        type=str,
                        default=None,
                        help="Use this option to regularly store the data "
                        "in a csv file.")
    parser.add_argument('--end_metrics',
                        type=str,
                        default=None,
                        help="Use this option to append the metrics of the "
                        "end of the run to a csv file.")

    # TODO : remove, this should no be at this level
    parser.add_argument('--infinity',
                        '-i',
                        default=float('inf'),
                        type=float,
                        help='Argument to determine the value used for '
                        'infinity in case of hard constraints, '
                        'for algorithms that do not use symbolic '
                        'infinity. Defaults to 10 000')