Skip to content

Commit

Permalink
start with init
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomino committed Oct 3, 2023
1 parent f4d2f03 commit 3ea68b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -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
)
12 changes: 6 additions & 6 deletions src/linear_solver.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 3ea68b9

Please sign in to comment.