diff --git a/main.py b/main.py index 5cafa1d..5beb1a6 100644 --- a/main.py +++ b/main.py @@ -122,9 +122,6 @@ def run_experiment(experiment_title, n_agents, capacity, show_plots, debug, resu new_route.append((coordinate[0] + min_x, coordinate[1] + min_y)) temp.append(new_route) open("allocations.json", "w").write(geojson.dumps({"routes": temp})) - # TODO find a way of adding an agent based on id instead of index in a list - # This has some more work to it as this requires the index querying in cbba to be done based on hash indexing - # exp.add_agent(Agent.agent(id=)) # Save the results in a csv file ( @@ -176,13 +173,13 @@ def run_experiment(experiment_title, n_agents, capacity, show_plots, debug, resu ) else: ds = "AC300" - n_agents = 3 - capacity = 15000 + n_agents = 5 + capacity = 1500 main( dataset_name=ds, experiment_title=ds + "_" + str(n_agents) + "agents_" + str(capacity) + "capacity", n_agents=n_agents, capacity=capacity, - show_plots=True, - debug=True, + show_plots=False, + debug=False, ) diff --git a/pyproject.toml b/pyproject.toml index 5d79a61..c971f74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,11 @@ [build-system] -requires = ["setuptools", "wheel"] +requires = ["setuptools", "wheel", "pep517"] build-backend = "setuptools.build_meta" [project] name = "trajallocpy" -version = "0.0.1" +version = "0.0.2" description = "TrajAllocPy is a Python library that provides functionality for trajectory task Allocaition using Consensus based bundle algorithm" readme = "README.md" authors = [ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6d13535 --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +from setuptools import setup + +setup( + name="trajallocpy", + version="0.0.2", + description="TrajAllocPy is a Python library that provides functionality for trajectory task Allocation using Consensus based bundle algorithm", + long_description="", + long_description_content_type="text/markdown", + author="Kasper Rømer Grøntved", + author_email="kaspergrontved@gmail.com", + url="", + classifiers=[ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + ], + packages=[], + python_requires=">=3.10", + install_requires=[], + extras_require={"test": ["pytest"]}, +) diff --git a/trajallocpy/ACBBA.py b/trajallocpy/ACBBA.py index 23eed19..bd1c440 100644 --- a/trajallocpy/ACBBA.py +++ b/trajallocpy/ACBBA.py @@ -77,6 +77,14 @@ def __init__( self.removal_threshold = 5 # TODO find a good value for this when ros is implemented self.message_history = [] + def __repr__(self) -> str: + return f"Agent {self.id} \n path {self.path} \n bundle {self.bundle} \n y(winning bids) {self.y} \n z(winning agents) {self.z} \n t(timestamps) {self.t} \n" + + def add_tasks(self, tasks): + # add the tasks to self.tasks dictionary + for task in tasks: + self.tasks[task.id] = task + def __str__(self) -> str: return f"Agent {self.id} \n path {self.path} \n bundle {self.bundle} \n y(winning bids) {self.y} \n z(winning agents) {self.z} \n t(timestamps) {self.t} \n" diff --git a/trajallocpy/CBBA.py b/trajallocpy/CBBA.py index 90ea4b1..d8dd736 100644 --- a/trajallocpy/CBBA.py +++ b/trajallocpy/CBBA.py @@ -72,6 +72,9 @@ def __init__( self.removal_list = np.zeros(self.task_num, dtype=np.int8) self.removal_threshold = 15 + def add_tasks(self, tasks): + self.tasks.extend(tasks) + def getPathTasks(self) -> List[TrajectoryTask]: return self.tasks[self.path] diff --git a/trajallocpy/Experiment.py b/trajallocpy/Experiment.py index 0ba1cbe..cd26b3e 100644 --- a/trajallocpy/Experiment.py +++ b/trajallocpy/Experiment.py @@ -65,6 +65,13 @@ def evaluateSolution(self): max_path_cost, ) + def add_tasks(self, tasks): + # TODO make sure that the tasks are within the search area + + # TODO make sure that the tasks not already in the list + for robot in self.robot_list: + robot.add_tasks(tasks) + def solve(self, profiling_enabled=False, debug=False): if profiling_enabled: print("Profiling enabled!") diff --git a/trajallocpy/__init__.py b/trajallocpy/__init__.py index 61da375..54782c1 100644 --- a/trajallocpy/__init__.py +++ b/trajallocpy/__init__.py @@ -1,3 +1,3 @@ import trajallocpy.Agent import trajallocpy.Task -from trajallocpy import ACBBA, CBBA, Agent, CoverageProblem, Task +from trajallocpy import ACBBA, CBBA, Agent, CoverageProblem, Experiment, Task