Skip to content

Commit

Permalink
Advanced Gantt chart functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
framinan committed Sep 7, 2022
1 parent 42d353f commit 5ed6712
Show file tree
Hide file tree
Showing 13 changed files with 1,032 additions and 71 deletions.
13 changes: 11 additions & 2 deletions build/lib/scheptk/scheptk.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,9 @@ def random_solution(self):
# implementation of the completion times of each job on each machine for OpenShop
# it has to be a full sequence
def ct(self, sequence):

# job order to be returned
job_order = []

# completion times of jobs and machines
ct_jobs = [self.r[j] for j in range(self.jobs)]
Expand All @@ -865,6 +868,10 @@ def ct(self, sequence):

# obtain decoded_job
decoded_job = job % self.jobs

# if it is a new job, it is appended to the job_order
if len([e for e in job_order if e == decoded_job]) == 0:
job_order.append(decoded_job)

# obtain decoded machine
decoded_machine = int((job - decoded_job) / self.jobs)
Expand All @@ -874,9 +881,11 @@ def ct(self, sequence):
ct_jobs[decoded_job]= curr_completion_time
ct_machines[decoded_machine] = curr_completion_time

ct[decoded_machine][decoded_job] = curr_completion_time
# puts the completion time in the proper position the completion times matrix
order_decoded_job = job_order.index(decoded_job)
ct[decoded_machine][order_decoded_job] = curr_completion_time

return ct, ct_jobs
return ct, job_order



Expand Down
122 changes: 80 additions & 42 deletions build/lib/scheptk/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,57 @@
import operator # for sorted functions
from random import randint # generation of random integer numbers


# utility function to edit the value of a tag in a file
# returns -1 if the tag is not found, the line in the file where the tag is found otherwise
def edit_tag(tag, value, filename):
# obtiene el valor de la etiqueta en formato lista
string_value = ''
if isinstance(value,list):
if isinstance(value[0],list):
# es una matriz
string_value = matrix_to_string(value)
else:
# es una lista
string_value = vector_to_string(value)
else:
string_value = str(value)

found_at = -1
# loading all tags
with open(filename,'r') as file:
list_lines = file.readlines()
# search the specific tag
for x, line in enumerate(list_lines):
if line.find('[' + tag + '=')!= -1:
found_at = x
# if found, changes the line
if found_at != -1:
# gets the part before the [
start = list_lines[found_at].index('=')
#new line
new_line = list_lines[found_at][:start] + '='+ string_value + "]\n"
list_lines[found_at] = new_line
# writes the file with the new value of the tag
with open(filename,'w') as file:
file.writelines(list_lines)
return found_at



# find_index_max() returns the index where the maximum value is found
def find_index_max(list):
tuple = enumerate(list)
sorted_tuple = sorted(tuple, key=operator.itemgetter(1), reverse=True)
return sorted_tuple[0][0]

# find_index_min() returns the index where the minimum value is found
def find_index_min(list):
tuple = enumerate(list)
sorted_tuple = sorted(tuple, key=operator.itemgetter(1), reverse=False)
return sorted_tuple[0][0]


# utility function to get the proper type (int, string, float) of an argument
def get_proper_type(x):
if isinstance(ast.literal_eval(x), int):
Expand All @@ -14,6 +65,20 @@ def get_proper_type(x):
return x


# utility function to map a matrix into a string (mostly to be used internally)
def matrix_to_string(matrix):
cadena = ''
for i in range(len(matrix)-1):
for j in range(len(matrix[i]) - 1):
cadena = cadena + str(matrix[i][j]) + ","
cadena = cadena + str(matrix[i][len(matrix[i])-1]) + ";"
# last row
for j in range(len(matrix[0])-1):
cadena = cadena + str(matrix[len(matrix)-1][j]) + ","
# last col of last row
return cadena + str(matrix[len(matrix)-1][len(matrix[0])-1])


# utility function to print the content of val (escalar, vector, matrix) with a tag
def print_tag(tag, value):
# if it is a list
Expand All @@ -28,28 +93,17 @@ def print_tag(tag, value):
# it is an scalar
print("[" + tag + "=" + str(value) + "]")


# utility function to map a vector into a string (mostly to be used internally)
def vector_to_string(vector):
cadena = ''
for i in range(len(vector)-1):
cadena = cadena + str(vector[i]) + ","
return cadena + str(vector[len(vector)-1])
# utility function to generate a random sequence of length size
def random_sequence(size):
sequence = []
for i in range(size):
number = randint(0, size-1)
while( sequence.count(number)!= 0):
number = randint(0, size-1)
sequence.append(number)
return sequence


# utility function to map a matrix into a string (mostly to be used internally)
def matrix_to_string(matrix):
cadena = ''
for i in range(len(matrix)-1):
for j in range(len(matrix[i]) - 1):
cadena = cadena + str(matrix[i][j]) + ","
cadena = cadena + str(matrix[i][len(matrix[i])-1]) + ";"
# last row
for j in range(len(matrix[0])-1):
cadena = cadena + str(matrix[len(matrix)-1][j]) + ","
# last col of last row
return cadena + str(matrix[len(matrix)-1][len(matrix[0])-1])


# utility function to read a tag
def read_tag(filename, tag):
Expand Down Expand Up @@ -112,28 +166,12 @@ def sorted_value_asc(list):
def sorted_value_desc(list):
return sorted_value(list, True)

# utility function to generate a random sequence of length size
def random_sequence(size):
sequence = []
for i in range(size):
number = randint(0, size-1)
while( sequence.count(number)!= 0):
number = randint(0, size-1)
sequence.append(number)
return sequence


# find_index_max() returns the index where the maximum value is found
def find_index_max(list):
tuple = enumerate(list)
sorted_tuple = sorted(tuple, key=operator.itemgetter(1), reverse=True)
return sorted_tuple[0][0]

# find_index_min() returns the index where the minimum value is found
def find_index_min(list):
tuple = enumerate(list)
sorted_tuple = sorted(tuple, key=operator.itemgetter(1), reverse=False)
return sorted_tuple[0][0]
# utility function to map a vector into a string (mostly to be used internally)
def vector_to_string(vector):
cadena = ''
for i in range(len(vector)-1):
cadena = cadena + str(vector[i]) + ","
return cadena + str(vector[len(vector)-1])

# utility function to write a tag (scalar, vector, matrix) and its value into a file
def write_tag(tag, value, filename):
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/Tasks_NA_sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/images/assembly_sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 14 additions & 17 deletions scheptk.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
Metadata-Version: 2.1
Name: scheptk
Version: 0.0.5
Version: 0.0.6
Summary: Python scheduling package
Home-page: https://github.com/framinan/scheptk
Author: Jose M Framinan
Author-email: framinan@us.es
License: UNKNOWN
Description: ## `scheptk` - Scheduling Python ToolKit

`scheptk` is a collection of classes and functions to model and solve machine scheduling problems using Python. It is intended basically for teaching purposes, even if the algorithms can be integrated with MOIST, a more advanced scheduling tool.

# How to use it

In order to use `scheptk` you can install it as a Python package using `pip`:

`pip install scheptk`

At this point, the clasess and functions of `scheptk` should be available. You might want to have a look at the [wiki pages](https://github.com/framinan/scheptk/wiki) to get a handle on the documentation.


Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Description-Content-Type: text/markdown
License-File: LICENSE

## `scheptk` - Scheduling Python ToolKit

`scheptk` is a collection of classes and functions to model and solve machine scheduling problems using Python. It is intended basically for teaching purposes, even if the algorithms can be integrated with MOIST, a more advanced scheduling tool.

# How to use it

In order to use `scheptk` you can install it as a Python package using `pip`:

`pip install scheptk`

At this point, the clasess and functions of `scheptk` should be available. You might want to have a look at the [wiki pages](https://github.com/framinan/scheptk/wiki) to get a handle on the documentation.



Binary file added scheptk/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added scheptk/__pycache__/scheptk.cpython-39.pyc
Binary file not shown.
Binary file added scheptk/__pycache__/util.cpython-39.pyc
Binary file not shown.
Loading

0 comments on commit 5ed6712

Please sign in to comment.