From 3ea68b9f4f7bdea27dd93b317c2fdb8344df6c94 Mon Sep 17 00:00:00 2001 From: Krzysztof Domino Date: Tue, 3 Oct 2023 14:29:04 +0200 Subject: [PATCH] start with init --- src/__init__.py | 6 ++++++ src/linear_solver.py | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index e69de29..d93217f 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -0,0 +1,6 @@ +from .utils import ( + number_gen, create_stations_list, agv_routes_as_edges, create_agv_list, + create_same_way_dict, create_graph, create_t_iterator, create_y_iterator, + create_z_iterator, create_iterators, see_variables, get_data4plot, + nice_print, create_v_in_out, print_time +) \ No newline at end of file diff --git a/src/linear_solver.py b/src/linear_solver.py index 93c0773..8290352 100644 --- a/src/linear_solver.py +++ b/src/linear_solver.py @@ -1,7 +1,7 @@ from curses import A_LEFT import itertools import numpy as np -from src import utils +from utils import * from typing import Optional from docplex.mp.model import Model from docplex.mp.solution import SolveSolution @@ -15,10 +15,10 @@ def __init__(self, M: int, tracks: list, tracks_len: dict, agv_routes: dict, d_m tau_pass: dict, tau_headway: dict, tau_operation: dict, weights: dict, initial_conditions: Optional[dict] = None): - _graph = utils.create_graph(tracks, agv_routes) - _iterators = utils.create_iterators(_graph, agv_routes) + _graph = create_graph(tracks, agv_routes) + _iterators = create_iterators(_graph, agv_routes) - self.J = utils.create_agv_list(agv_routes) + self.J = create_agv_list(agv_routes) self.t_in_iter = _iterators["t_in"] self.t_out_iter = _iterators["t_out"] @@ -97,13 +97,13 @@ def create_linear_model(self, num_threads: int = None) -> Model: variables = variables | z_variables for index, row in enumerate(self.A_ub): - non_zero = utils.see_non_zero_variables(row, self.x_iter) + non_zero = see_non_zero_variables(row, self.x_iter) # print(f"{sum([variables[var_name] * sign for var_name, sign in non_zero.items()])} <= {b_ub[index]}") model.add_constraint( sum([variables[var_name] * sign for var_name, sign in non_zero.items()]) <= self.b_ub[index]) for index, row in enumerate(self.A_eq): - non_zero = utils.see_non_zero_variables(row, self.x_iter) + non_zero = see_non_zero_variables(row, self.x_iter) # print(f"{sum([variables[var_name] * sign for var_name, sign in non_zero.items()])} == {b_eq[index]}") model.add_constraint( sum([variables[var_name] * sign for var_name, sign in non_zero.items()]) == self.b_eq[index])