IGJSP 1.1.5__tar.gz → 1.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: IGJSP
3
- Version: 1.1.5
3
+ Version: 1.1.6
4
4
  Summary: Instance generator for JSP
5
5
  Project-URL: Homepage, https://gps.blogs.upv.es/
6
6
  Author-email: GPS-UPV <gps@dsic.upv.es>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "IGJSP"
7
- version = "1.1.5"
7
+ version = "1.1.6"
8
8
  authors = [
9
9
  { name = "GPS-UPV", email = "gps@dsic.upv.es" },
10
10
  ]
@@ -3,6 +3,7 @@ import datetime
3
3
  import json
4
4
  import os
5
5
  import pickle
6
+ import random
6
7
  import re
7
8
  from itertools import combinations
8
9
 
@@ -11,11 +12,11 @@ import numpy as np
11
12
 
12
13
  np.set_printoptions(linewidth=np.inf, threshold=np.inf, formatter={"int": lambda x: f"{x}"})
13
14
 
15
+ from importlib.resources import as_file, files
14
16
  from pprint import pprint
15
17
 
16
18
  from scipy.stats import expon, norm, uniform
17
19
 
18
- from importlib.resources import files, as_file
19
20
 
20
21
  def _read_text_resource(rel_path: str, encoding: str = "utf-8") -> str:
21
22
  p = files("IGJSP").joinpath(rel_path)
@@ -150,17 +151,17 @@ class JSP:
150
151
  np.random.seed(seed)
151
152
  self.rddd = rddd
152
153
  self.speed = speed
153
- #Elimino por que no hace caso del seed. Se tiene que hacer antes de llamar a esta función
154
- # if not tpm or len(tpm) != self.numMchs:
155
- # if distribution == "uniform":
156
- # tpm = np.random.uniform(10, 100, self.numMchs)
157
- # elif distribution == "normal":
158
- # tpm = [max(10, data) for data in np.random.normal(50, 20, self.numMchs)]
159
- # else:
160
- # tpm = expon(loc=10, scale=20).rvs(self.numMchs)
154
+ if not tpm or len(tpm) != self.numMchs:
155
+ if distribution == "uniform":
156
+ tpm = np.random.uniform(10, 100, self.numMchs)
157
+ elif distribution == "normal":
158
+ tpm = [max(10, data) for data in np.random.normal(50, 20, self.numMchs)]
159
+ else:
160
+ tpm = expon(loc=10, scale=20).rvs(self.numMchs)
161
+
161
162
  energyPer, timePer = self._particionate_speed_space(speed)
162
- self._generate_standar_operation_cost(distribution,tpm)
163
-
163
+ self._generate_standar_operation_cost(distribution)
164
+
164
165
  self.ProcessingTime = np.zeros((self.numJobs, self.numMchs, self.speed), dtype=int)
165
166
  self.EnergyConsumption = np.zeros((self.numJobs, self.numMchs, self.speed), dtype=int)
166
167
  self.Orden = np.zeros((self.numJobs, self.numMchs), dtype=int)
@@ -183,19 +184,17 @@ class JSP:
183
184
 
184
185
  def _particionate_speed_space(self, speed):
185
186
  energyPer = np.linspace(0.5, 3, speed) if speed > 1 else [1]
186
- timePer = [t(c) for c in energyPer]
187
+ # timePer = [t(c) for c in energyPer]
188
+ timePer = sorted([random.uniform(0, 100)/100 for _ in range(3)])
187
189
  return energyPer, timePer
188
190
 
189
- def _generate_standar_operation_cost(self, distribution,tpm=[]):
190
- if np.array(tpm).shape != (self.numJobs, self.numMchs):
191
- if distribution == "uniform":
192
- self.operationCost = np.random.uniform(10, 100, (self.numJobs, self.numMchs))
193
- elif distribution == "normal":
194
- self.operationCost = np.array([max(10, x) for x in np.random.normal(50, 20, (self.numJobs, self.numMchs)).reshape(-1)]).reshape(self.numJobs, self.numMchs)
195
- elif distribution == "exponential":
196
- self.operationCost = np.random.exponential(10, (self.numJobs, self.numMchs))
197
- else:
198
- self.operationCost = tpm
191
+ def _generate_standar_operation_cost(self, distribution):
192
+ if distribution == "uniform":
193
+ self.operationCost = np.random.uniform(10, 100, (self.numJobs, self.numMchs))
194
+ elif distribution == "normal":
195
+ self.operationCost = np.array([max(10, x) for x in np.random.normal(50, 20, (self.numJobs, self.numMchs)).reshape(-1)]).reshape(self.numJobs, self.numMchs)
196
+ elif distribution == "exponential":
197
+ self.operationCost = np.random.exponential(10, (self.numJobs, self.numMchs))
199
198
 
200
199
  def _jobToMachine(self, release_date_tasks, timePer, distribution):
201
200
  for job in range(self.numJobs):
@@ -213,16 +212,18 @@ class JSP:
213
212
  self.ReleaseDueDate[job, machine, 1] = releaseDateTask
214
213
  else:
215
214
  releaseDateTask += np.median(self.ProcessingTime[job, machine, :])
215
+
216
216
  if self.rddd == 1:
217
217
  self.ReleaseDueDate[job] = [initial, int(self._release_due(releaseDateTask, distribution))]
218
-
219
218
 
220
219
  def _genProcEnergy(self, job, machine, timePer):
221
- ans = []
222
- for tper in timePer:
223
- time = max(1, self.operationCost[job, machine] * tper)
224
- ans.append((time, max(1, f(time))))
225
- return ans
220
+ # ans = []
221
+ # for tper in timePer:
222
+ # time = max(1, self.operationCost[job, machine] * tper)
223
+ # ans.append((time, max(1, f(time))))
224
+ # ans.append((time, max(1, f(time))))
225
+ timePer = sorted([random.uniform(0, 100)/100 for _ in range(3)])
226
+ return [(round(i*100),round((1-i)*100)) for i in timePer]
226
227
 
227
228
  def _release_due(self, duration, distribution):
228
229
  if distribution == "uniform":
@@ -666,19 +667,17 @@ class JSP:
666
667
  }
667
668
 
668
669
  if t == 1:
669
- replace_data["releaseDate"] = str(data.ReleaseDueDate[:, 0].flatten()).replace(" ",", ")
670
- # replace_data["releaseDate"] = ", ".join(list(map(str,data.ReleaseDueDate[:, 0])))
671
- replace_data["dueDate"] = str(data.ReleaseDueDate[:, 1].flatten()).replace(" ",", ")
672
-
670
+ replace_data["releaseDate"] = str([int(data.ReleaseDueDate[job, 0]) for job in range(data.numJobs)]).replace(", ", " ")
671
+ replace_data["dueDate"] = str([int(data.ReleaseDueDate[job, 1]) for job in range(data.numJobs)]).replace(", ", " ")
673
672
  elif t == 2:
674
- replace_data["releaseDate"] = str(data.ReleaseDueDate[:,:, 0].flatten()).replace(" ",", ")
675
- replace_data["dueDate"] = str(data.ReleaseDueDate[:, :, 1].flatten()).replace(" ",", ")
673
+ replace_data["releaseDate"] = str(data.ReleaseDueDate[:, :, 0].flatten()).replace(", ", " ")
674
+ replace_data["dueDate"] = str(data.ReleaseDueDate[:, :, 1].flatten()).replace(", ", " ")
676
675
 
677
676
  for job in range(data.numJobs):
678
677
  for i, prioridad in enumerate(range(data.numMchs)):
679
678
  precedence[job, data.Orden[job, prioridad]] = i
680
679
 
681
- replace_data["precedence"] = str(precedence.flatten()).replace(" ", ", ")
680
+ replace_data["precedence"] = str(precedence.flatten()).replace(" ", ",")
682
681
  filedata = _read_text_resource(f"Minizinc/Types/RD/JSP/type{t}.dzn")
683
682
  # with open(f"./Minizinc/Types/RD/JSP/type{t}.dzn", "r", encoding="utf-8") as file:
684
683
  # filedata = file.read()
@@ -1131,27 +1130,11 @@ class Generator:
1131
1130
  jsp_instance = JSP(jobs = jobs, machines = machines)
1132
1131
  case "FJSP":
1133
1132
  jsp_instance = FJSP(jobs = jobs, machines = machines)
1134
-
1135
- tpm_aux=[]
1136
- orden_aux=[]
1137
- for index in range(1, size + 1):
1138
- if len(tpm) != machines:
1139
- if distribution == "uniform":
1140
- aux = np.random.uniform(10, 100, (jobs, machines))
1141
- elif distribution == "normal":
1142
- aux = np.array([max(10, x) for x in np.random.normal(50, 20, (jobs, machines)).reshape(-1)]).reshape(jobs, machines)
1143
- elif distribution == "exponential":
1144
- aux = np.random.exponential(10, (jobs, machines))
1145
- tpm_aux.append(aux)
1146
-
1147
- orden_aux.append([np.random.choice(range(machines), machines, replace=False) for job in range(jobs)])
1148
-
1149
- orden_aux = np.array(orden_aux)
1150
-
1133
+ instances = []
1151
1134
  for index in range(1, size + 1):
1135
+
1136
+ jsp_instance.fill_random_values(speed = speed, rddd = ReleaseDateDueDate, distribution = distribution, seed = seed,tpm = tpm)
1152
1137
 
1153
- jsp_instance.fill_random_values(speed = speed, rddd = ReleaseDateDueDate, distribution = distribution, seed = seed,tpm = tpm_aux[index-1])
1154
- jsp_instance.Orden = orden_aux[index-1]
1155
1138
  # Determinar el nombre de salida basado en `outputName` y los parámetros actuales
1156
1139
  problem_path = self.savepath.format(size = size, jobs =jobs, machines = machines, release_due_date = ReleaseDateDueDate, speed_scaling = speed, distribution = distribution, seed=seed)
1157
1140
 
@@ -1183,5 +1166,5 @@ class Generator:
1183
1166
  os.remove(pkl_path)
1184
1167
  if self.taillard:
1185
1168
  jsp_instance.saveTaillardStandardFile(f"{problem_path}/TAILLARD/" + jm_path.split("/")[0] + f"_{j}x{m}_{i}.txt")
1186
-
1187
- return jsp_instance
1169
+ instances.append(jsp_instance)
1170
+ return instances if len(instances) >1 else instances[0]
File without changes
File without changes
File without changes
File without changes