Skip to content

Commit

Permalink
Added zone statuses and description to the input files (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
StannisMod authored Nov 21, 2023
1 parent 3fdb00b commit baca68b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sampo"
version = "0.1.1.249"
version = "0.1.1.251"
description = "Open-source framework for adaptive manufacturing processes scheduling"
authors = ["iAirLab <iairlab@yandex.ru>"]
license = "BSD-3-Clause"
Expand Down
2 changes: 1 addition & 1 deletion sampo/pipeline/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InputPipeline(ABC):

@abstractmethod
def wg(self, wg: WorkGraph | pd.DataFrame | str,
full_connection: bool = False,
is_wg_has_full_info_about_connections: bool = False,
change_base_on_history: bool = False) -> 'InputPipeline':
...

Expand Down
5 changes: 4 additions & 1 deletion sampo/schemas/works.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self,
material_reqs: list[MaterialReq] = None,
object_reqs: list[ConstructionObjectReq] = None,
zone_reqs: list[ZoneReq] = None,
description: str = '',
group: str = 'default',
is_service_unit: bool = False,
volume: float = 0,
Expand All @@ -32,6 +33,7 @@ def __init__(self,
:param material_reqs: list of required materials (e.g. logs, stones, gravel etc.)
:param object_reqs: list of required objects (e.g. electricity, pipelines, roads)
:param zone_reqs: list of required zone statuses (e.g. opened/closed doors, attached equipment, etc.)
:param description: the description. It is useful, for example, to show it on visualization
:param group: union block of works
:param is_service_unit: service units are additional vertexes
:param volume: scope of work
Expand All @@ -54,6 +56,7 @@ def __init__(self,
self.object_reqs = object_reqs
self.material_reqs = material_reqs
self.zone_reqs = zone_reqs
self.description = description
self.group = group
self.is_service_unit = is_service_unit
self.volume = volume
Expand All @@ -62,7 +65,7 @@ def __init__(self,
self.workground_size = workground_size

def __del__(self):
for name, attr in self.__dict__.items():
for attr in self.__dict__.values():
del attr

def need_materials(self) -> list[Material]:
Expand Down
9 changes: 7 additions & 2 deletions sampo/userinput/parser/csv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ def read_graph_info(project_info: str,
predecessor_ids: list[str] - Ids of predecessors of the current task,
connection_types: list[str] - Types of links between the current task and its predecessors,
lags: float - Time lags,
min_req: dict[str: float] - A dictionary containing the minimum amount of each resource that is required to perform the current task
max_req: dict[str: float] - A dictionary containing the maximum amount of each resource that is required to perform the current task
min_req: dict[str: float] - A dictionary containing the minimum amount of each resource
that is required to perform the current task
max_req: dict[str: float] - A dictionary containing the maximum amount of each resource
that is required to perform the current task
description: str - A task description
required_status: dict[str: float] - A dictionary containing the zone statuses required
to perform the current task
Schema of history .csv file (optional data):
mandatory fields:
Expand Down
14 changes: 10 additions & 4 deletions sampo/userinput/parser/general_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sampo.generator.pipeline.project import get_start_stage, get_finish_stage
from sampo.schemas.contractor import Contractor
from sampo.schemas.graph import GraphNode, WorkGraph, EdgeType
from sampo.schemas.requirements import WorkerReq
from sampo.schemas.requirements import WorkerReq, ZoneReq
from sampo.schemas.resources import Worker
from sampo.schemas.works import WorkUnit

Expand All @@ -21,7 +21,7 @@ class Graph:
def __init__(self):
self.graph = defaultdict(list)

def add_edge(self, u, v, weight = None):
def add_edge(self, u, v, weight=None):
self.graph[u].append((v, weight))

def dfs_cycle(self, u, visited):
Expand Down Expand Up @@ -233,9 +233,15 @@ def build_work_graph(frame: pd.DataFrame, resource_names: list[str]) -> WorkGrap
for res_name in resource_names
if row[res_name] > 0]
is_service_unit = len(reqs) == 0

zone_reqs = [ZoneReq(*v) for v in eval(row['required_statuses']).items()] \
if 'required_statuses' in frame.columns else []

description = row['description'] if 'description' in frame.columns else ''

work_unit = WorkUnit(row['activity_id'], row['granular_name'], reqs, group=row['activity_name'],
volume=row['volume'], volume_type=row['measurement'], is_service_unit=is_service_unit,
display_name=row['activity_name'])
description=description, volume=row['volume'], volume_type=row['measurement'],
is_service_unit=is_service_unit, display_name=row['activity_name'], zone_reqs=zone_reqs)
has_succ |= set(row['edges'][0])
parents = [(id_to_node[p_id], lag, conn_type) for p_id, conn_type, lag in row.edges]
node = GraphNode(work_unit, parents)
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/csv_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_work_graph_csv_parser():
except Exception as e:
raise WorkGraphBuildingException(f'There is no way to build work graph, {e}')


os.remove(os.path.join(sys.path[0], 'tests/parser/repaired.csv'))

0 comments on commit baca68b

Please sign in to comment.