Skip to content

Commit

Permalink
Added description and zone status columns to the input CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
StannisMod committed Nov 20, 2023
1 parent 2be4965 commit fb8a38b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 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 <[email protected]>"]
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
4 changes: 3 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 Down Expand Up @@ -54,6 +55,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 +64,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
10 changes: 7 additions & 3 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,13 @@ 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 []

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'])
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

0 comments on commit fb8a38b

Please sign in to comment.