Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Introduce ddwp module
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlan committed Sep 20, 2023
1 parent f882eb2 commit 751d598
Show file tree
Hide file tree
Showing 28 changed files with 38 additions and 39 deletions.
12 changes: 6 additions & 6 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from tqdm import tqdm
from tqdm.contrib.concurrent import process_map

import utils
from agents import AGENTS, Agent
from Environment import Environment
from sampling import SAMPLING_METHODS
from static_solvers import default_solver
from ddwp.agents import AGENTS, Agent
from ddwp.Environment import Environment
from ddwp.read import read
from ddwp.sampling import SAMPLING_METHODS
from ddwp.static_solvers import default_solver


def parse_args():
Expand Down Expand Up @@ -78,7 +78,7 @@ def solve(
raise ValueError("Strategy time limit >= epoch time limit.")

path = Path(loc)
static_instance = utils.read(path, instance_format)
static_instance = read(path, instance_format)

if environment == "euro_neurips":
env_constructor = Environment.euro_neurips # type: ignore
Expand Down
6 changes: 3 additions & 3 deletions Environment.py → ddwp/Environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

import numpy as np

from sampling import SamplingMethod
from utils.validation import validate_static_solution
from VrpInstance import VrpInstance
from ddwp.sampling import SamplingMethod
from ddwp.validation import validate_static_solution
from ddwp.VrpInstance import VrpInstance

Instance = dict
Action = list[list[int]]
Expand Down
File renamed without changes.
Empty file added ddwp/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion agents/Agent.py → ddwp/agents/Agent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Protocol

from Environment import State, StaticInfo
from ddwp.Environment import State, StaticInfo


class Agent(Protocol):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

import numpy as np

from Environment import State, StaticInfo
from sampling import SamplingMethod
from static_solvers import default_solver, scenario_solver
from VrpInstance import VrpInstance
from ddwp.Environment import State, StaticInfo
from ddwp.sampling import SamplingMethod
from ddwp.static_solvers import default_solver, scenario_solver
from ddwp.VrpInstance import VrpInstance

from .consensus import CONSENSUS, ConsensusFunction
from .sample_scenario import sample_scenario
Expand Down
4 changes: 2 additions & 2 deletions agents/RandomDispatch.py → ddwp/agents/RandomDispatch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from Environment import State, StaticInfo
from static_solvers import default_solver
from ddwp.Environment import State, StaticInfo
from ddwp.static_solvers import default_solver


class _RandomDispatch:
Expand Down
6 changes: 3 additions & 3 deletions agents/RollingHorizon.py → ddwp/agents/RollingHorizon.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np

from Environment import State, StaticInfo
from sampling import SamplingMethod
from static_solvers import default_solver
from ddwp.Environment import State, StaticInfo
from ddwp.sampling import SamplingMethod
from ddwp.static_solvers import default_solver

from .sample_scenario import sample_scenario

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import numpy as np

from Environment import StaticInfo
from VrpInstance import VrpInstance
from ddwp.Environment import StaticInfo
from ddwp.VrpInstance import VrpInstance


class ConsensusFunction(Protocol):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from Environment import StaticInfo
from ddwp.Environment import StaticInfo

from .utils import (
select_dispatch_on_threshold,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from Environment import StaticInfo
from ddwp.Environment import StaticInfo

from .utils import (
get_dispatch_matrix,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from Environment import StaticInfo
from static_solvers import default_solver
from ddwp.Environment import StaticInfo
from ddwp.static_solvers import default_solver

from .utils import get_dispatch_count, verify_action

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions agents/sample_scenario.py → ddwp/agents/sample_scenario.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np

from Environment import State, StaticInfo
from sampling import SamplingMethod
from VrpInstance import VrpInstance
from ddwp.Environment import State, StaticInfo
from ddwp.sampling import SamplingMethod
from ddwp.VrpInstance import VrpInstance


def sample_scenario(
Expand Down
2 changes: 1 addition & 1 deletion utils/read.py → ddwp/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import vrplib

from VrpInstance import VrpInstance
from ddwp.VrpInstance import VrpInstance


def read(path: Path, instance_format: str = "vrplib"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from numpy.random import Generator

from VrpInstance import VrpInstance
from ddwp.VrpInstance import VrpInstance


class SamplingMethod(Protocol):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from numpy.random import Generator

from VrpInstance import VrpInstance
from ddwp.VrpInstance import VrpInstance


def custom_time_windows(
Expand Down
2 changes: 1 addition & 1 deletion sampling/euro_neurips.py → ddwp/sampling/euro_neurips.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from numpy.random import Generator

from VrpInstance import VrpInstance
from ddwp.VrpInstance import VrpInstance


def euro_neurips(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyvrp import Model, Result
from pyvrp.stop import MaxRuntime

from VrpInstance import VrpInstance
from ddwp.VrpInstance import VrpInstance

from .instance2data import instance2data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from pyvrp import Client, ProblemData, VehicleType

from VrpInstance import VrpInstance
from ddwp.VrpInstance import VrpInstance


def instance2data(instance: VrpInstance) -> ProblemData:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)
from pyvrp.stop import MaxRuntime

from VrpInstance import VrpInstance
from ddwp.VrpInstance import VrpInstance

from .instance2data import instance2data

Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "dynamic-dispatch-waves"
name = "ddwp"
version = "0.1.0"
description = "Code for dynamic dispatch waves problem"
authors = [
Expand All @@ -8,7 +8,8 @@ authors = [
"Niels Wouda <n.a.wouda@rug.nl>",
]
license = "MIT"
packages = [{include = "benchmark.py"}]
readme = "README.md"
packages = [{include ="ddwp"}, {include = "benchmark.py"}]


[tool.poetry.dependencies]
Expand Down
2 changes: 0 additions & 2 deletions utils/__init__.py

This file was deleted.

0 comments on commit 751d598

Please sign in to comment.