Code Monkey home page Code Monkey logo

pydcop's Introduction

Dcop python

Documentation Status Build Status

pyDCOP is a python library for Distributed Constraints Optimization. It contains implementations of several standard DCOP algorithms (MaxSum, DSA, DPOP, MGM, etc.) and allows you to develop your own algorithms.

pyDCOP runs on python >= 3.6.

Documentation is hosted on ReadTheDoc

pydcop's People

Contributors

bbailleux avatar gauthierpicard avatar pierrerust avatar pierrerustorange avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pydcop's Issues

Extending Max-Sum

Hi Pierre, thanks for this project.

I am trying to figure out how can I implement two variants of Max-Sum I am interested in: Max-Sum_ADVP and ICG-Max-Sum. Max-Sum_ADVP defines an order in which the beliefs will propagate (basically, it generates a DAG). ICG-Max-Sum cyclically applies two Max-Sum in sequence through a column generation technique, and defines probabilistic functions in the factor nodes.

I would like to ask you what could be the best way to do it. Should I do everything inside the algorithms, or should I extend computations_graph/factor_graph as well?

More generally, what is the best practice for implementing algorithms that pre-process the computation graph?


Also, in algorithms.maxsum, I understand that the query message from variable to factor (q) is costs_for_factor, the response message from factor node to variable node (r) is factor_costs_for_var, and the marginal function (z) is select_value. Maybe you could add some comments in which you map this terminology to the original one for more clarity.

Wrong handling of unconstrained variables with cost function

When a variable shares no constraint with any other variable, we can pick a value at random from its domain, except when the variable has an integrated cost function (which actually works as an unary constraint), in which case we should pick a value that optimize that cost function.

It seems, this is not correctly implemented in all algorithms. The issue was detected for DPOP (cf #16 ) but other algorithms should be reviewed to make sure they handle this case correctly.

ModuleNotFoundError: No module named 'pulp.solvers'

Hi, I was getting started according to the tutorial and came across this problem:
Traceback (most recent call last): File "/home/chenchun/anaconda3/envs/pydcopenv/bin/dcop_cli.py", line 54, in <module> from pydcop.commands import generate File "/home/chenchun/anaconda3/envs/pydcopenv/lib/python3.6/site-packages/pydcop/commands/generate.py", line 96, in <module> from pydcop.commands.generators.iot import generate_iot File "/home/chenchun/anaconda3/envs/pydcopenv/lib/python3.6/site-packages/pydcop/commands/generators/iot.py", line 49, in <module> from pulp.solvers import GLPK_CMD ModuleNotFoundError: No module named 'pulp.solvers'

I ran help(pulp) and there seemed no submodule named solvers.
`...

PACKAGE CONTENTS
apis (package)
constants
pulp
solverdir (package)
sparse
tests (package)
utilities

SUBMODULES
choco_api
coin_api
const
core
cplex_api
glpk_api
gurobi_api
mipcl_api
mosek_api
scip_api
xpress_api

FUNCTIONS
clock = process_time(...)
process_time() -> float

...`

Can anyone help me on this problem? Thanks a lot in advance!

meeting schedule issue

when I try to resolve meeting schedule problem with PEAV and pop logo. it always ask to Len(agents) and Len(varibales) to be equal. in my case if one agent controls more variables. how to provide that.

agents:
A: {}
B: {}
C: {}
D: {}
E: {}
F: {}
G: {}

hosting_costs:
A:
computations:
x_1A: 0
x_4A: 0
x_6A: 0
x_7A: 0
default: 0
B:
computations:
x_1B: 0
x_4B: 0
x_6B: 0
x_7B: 0
default: 0
C:
computations:
x_1C: 0
x_4C: 0
x_5C: 0
default: 0
D:
computations:
x_1D: 0
x_4D: 0
x_5D: 0
default: 0
E:
computations:
x_2E: 0
x_4E: 0
x_5E: 0
default: 0
F:
computations:
x_2F: 0
x_3F: 0
x_4F: 0
x_7F: 0
default: 0
G:
computations:
x_3G: 0
x_4G: 0
default: 0

yamldcop.py incompatible with YAML library?

After tweaking my issue with the version of PuLP (#37), I tried the test case again, and this time I get an error in yamldcop.py:

$ pydcop solve --algo dpop graph-coloring.yaml
Traceback (most recent call last):
  File "/Users/rpg/.virtualenvs/pydcop/bin/dcop.py", line 181, in <module>
    main()
  File "/Users/rpg/.virtualenvs/pydcop/bin/dcop.py", line 112, in main
    args.func(args)
  File "/Users/rpg/.virtualenvs/pydcop/lib/python3.9/site-packages/pydcop/commands/solve.py", line 254, in run_cmd
    dcop = load_dcop_from_file(args.dcop_files)
  File "/Users/rpg/.virtualenvs/pydcop/lib/python3.9/site-packages/pydcop/dcop/yamldcop.py", line 80, in load_dcop_from_file
    return load_dcop(content)
  File "/Users/rpg/.virtualenvs/pydcop/lib/python3.9/site-packages/pydcop/dcop/yamldcop.py", line 84, in load_dcop
    loaded = yaml.load(dcop_str)
TypeError: load() missing 1 required positional argument: 'Loader'

There's no version specification for pyyaml, so that's likely the problem here. Looking at the pyyaml changelog, we see that the load function was changed to require a Loader with version 6.0

Parsing does better when I downgrade to version 5.4.1, so that's probably a good idea.

Add algorithm documentation

For MaxSUm, AMaxSum, GBDA and MGM.

See documentation for DSA or SynBB for an example documentation (including citation of original papers)

Example does not run with import error from pulp

When I try to run the test case per the documentation

pydcop solve --algo dpop graph_coloring.yaml

I get this error:

Traceback (most recent call last):
  File "/Users/rpg/.virtualenvs/pydcop/bin/dcop.py", line 54, in <module>
    from pydcop.commands import generate
  File "/Users/rpg/.virtualenvs/pydcop/lib/python3.9/site-packages/pydcop/commands/generate.py", line 94, in <module>
    from pydcop.commands.generators.iot import generate_iot
  File "/Users/rpg/.virtualenvs/pydcop/lib/python3.9/site-packages/pydcop/commands/generators/iot.py", line 49, in <module>
    from pulp.solvers import GLPK_CMD
ModuleNotFoundError: No module named 'pulp.solvers'

I looked and indeed there is no solvers module in pulp.

I don't know for sure, but if I had to guess, I would say that probably the pulp library has changed in some way that is not backwards-compatible, and when I looked at the setup file I see there are no version qualifiers on the pulp dependency.

With no version qualifiers, I get pulp version 2.6.0 from pypi.

Looking further, I see that pulp replaced its solvers module with apis in this commit on 5 April 2020.

Looks like rolling back to pulp 2.0 solves that problem, but then it looks like there's version skew with yaml, as well.

If you still have a working copy of pyDcop, it would be great if you would check the versions of all its dependencies and revise setup.py with those versions until you can bring this library up-to-date with the state of pypi. Thanks!

Implementation for nested algorithm

Hi,

I'm trying to implement a DCOP algorithm, heist. Heist runs maxsum at each cycle and then update values appropriately (based on maxsum's answer). Im having trouble running and calling maxsum within heist without running into errors. Do you have any recommendations on how I can implement a nested algorithm (an algorithm that requires the answer of another algorithm for each cycle)? I've attached the paper the algorithm comes from. Heist is based from Algorithm 3 and 4 in the paper.

mab_dcops.pdf

Error with longer constraint function calls

I'm generating a yaml file for my pyDCOP call from an external python file. As a part of this, I'm writing constraints to the file that call functions in the external python file. I have hundreds of variables that I am calling the helper functions with after putting them into a list so that the portion of the yaml file looks like this:

  'constraint1':
    type: intention
    source: ./dcop1.py
    function: source.setConstraint([var1, var 2, ..., var100])

However, I keep getting a syntax error with the source.setConstraint([var1, var 2, ..., var100]) portion that goes away when I only have a few variables in the call. I've even gone as far as to increase the width parameter in my yaml.dump() in the python script, so I'm wondering if there's some other length limit being enforced for these lines in the yaml file?

Is pyDCOP for IoT use cases alone?

Please, I am new to DCOP and I am hoping to use this library to help me in my work on DCOP for multi-agent coordination.
I want to find out if pyDCOP is only useful for IoT case studies. Can it be used for environments with mobile agents who need to coordinate?
Thank you.

Not enough agents for one agent for each computation when run maxim

pydcop solve --algo maxsum simulation/graph_coloring.yaml

Traceback (most recent call last):
File "/anaconda3/bin/dcop_cli.py", line 196, in
main()
File "/anaconda3/bin/dcop_cli.py", line 124, in main
args.func(args)
File "/anaconda3/lib/python3.7/site-packages/pydcop/commands/solve.py", line 488, in run_cmd
communication_load=algo_module.communication_load,
File "/anaconda3/lib/python3.7/site-packages/pydcop/distribution/oneagent.py", line 129, in distribute
.format(len(agents),len(computation_graph.nodes)))
pydcop.distribution.objects.ImpossibleDistributionException: Not enough agents for one agent for each computation : 5 < 8

multi-process error

we run the command pydcop solve -a dsa -p stop_cycle:20 -m process mygraph5.yaml for the graph coloring problem, the project appears the error as following:
Traceback (most recent call last):
File "/Users/chenchun/anaconda3/envs/pydcopenv/lib/python3.6/site-packages/urllib3/connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/Users/chenchun/anaconda3/envs/pydcopenv/lib/python3.6/site-packages/urllib3/util/connection.py", line 84, in create_connection
raise err
File "/Users/chenchun/anaconda3/envs/pydcopenv/lib/python3.6/site-packages/urllib3/util/connection.py", line 74, in create_connection
sock.connect(sa)
socket.timeout: timed out
The input file is a random graph with 34 nodes
we also test the process mode for fewer variables and find the process mode can work for 18 variables. when we add the variables to 19, the project cannot present the running result and display that "Request agent to run".

DPOP not providing same cost solution for same input file

I seem to be getting different cost values for the attached problem whilst using the DPOP solver. This issue was present with an older version of PyDCOP, not 100% which one, and the current master branch. Whilst it makes sense for DCOP to produce different solutions with the same cost value it does not make sense that it returns different solutions with different cost values (as it is a complete algorithm). Typically I get cost between 25 and 45 however I know from using another solver that the minimum for this problem instance should be lower.

Am I missing something here?

Thanks,

foo.txt

error / any user forum?

Hi
I installed pydcop successfully on windows 10, but when I run dcopy_cli.py --version or the following command from tutorial . I get error

> dcop_cli.py solve --algo dpop graph_coloring.yaml
  File "C:\Users\908682\pydd\pyDcop\pydcop\dcop_cli.py", line 164
    def _configure_logs(level: int, log_conf: str):
                             ^
SyntaxError: invalid syntax

How may I resolve this? Do you have any user forum to ask questions, may be this is not the right place?

Getting an error for graph coloring

Sir,
When I run the very first graph coloring code given in the documentation, I get this error:
File "/home/ubuntu/pyDcop-master/pydcop/algorithms/init.py", line 114
name: str
^
SyntaxError: invalid syntax

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.