Commit 7697ad7b authored by Jérome Perrin's avatar Jérome Perrin

Revert changes pushed by mistake

Revert "Remove try/except that can hide programming errors"

This reverts commit 2ce01ae4.

Revert "Output queues in results"

This reverts commit 7dc0cc78.

Revert "Raise an error when attempting to use an invalid scheduling rule on a queue"

This reverts commit 7bca22bf.

Revert "display gantt by job & by station"

This reverts commit 1094e881.
parent 2ce01ae4
......@@ -330,13 +330,6 @@
// display demo graph.
$("#graph_zone").show();
// temporary hack
var now = new Date();
now.setHours(0);
now.setMinutes(0);
now.setSeconds(0);
var blockage_data = [],
waiting_data = [],
failure_data = [],
......@@ -356,32 +349,19 @@
"Step No."
]
],
start_date = new Date(now.getTime()),
gantt_data = {
data: [
{
id: "by_job",
text: "By Job",
start_date: start_date,
duration: 0,
project: 1,
open: true
},
{
id: "by_station",
text: "By Station",
start_date: start_date,
duration: 0,
project: 1,
open: true
}
],
data: [],
link: []
};
// temporary hack
var now = new Date();
now.setHours(0);
now.setMinutes(0);
now.setSeconds(0);
$.each(data['success'].elementList, function (idx, obj) {
if (obj.results !== undefined && obj.results.working_ratio !== undefined) {
if (obj.results.working_ratio !== undefined) {
/* when there is only one replication, the ratio is given as a float,
otherwise we have a mapping avg, min max */
if (obj.results.blockage_ratio !== undefined) {
......@@ -412,14 +392,14 @@
if (obj._class === 'Dream.Job') {
var property_dict = obj.extraPropertyDict;
var duration = 0;
var start_date = new Date(now.getTime());
gantt_data.data.push({
id: obj['id'],
text: property_dict['name'],
start_date: start_date,
duration: obj['results'].completionTime,
project: 1,
open: false,
parent: "by_job"
open: true
});
$.each(obj['results']['schedule'], function (i, schedule) {
spreadsheet_data.push([
......@@ -448,25 +428,7 @@
duration: duration,
parent: obj['id']
});
gantt_data.data.push({
id: 'job.' + obj['id'] + '.' + schedule['stepNumber'],
text: obj['id'],
start_date: task_start_date,
duration: duration,
parent: schedule['stationId'],
by_station:1,
});
};
});
} else {
gantt_data.data.push({
id: obj['id'],
text: obj['id'],
start_date: now,
duration: 0,
project: 1,
open: false,
parent: "by_station"
}
});
}
});
......@@ -518,7 +480,6 @@
try {
gantt.clearAll();
} catch (e) {}
var gantt_output_height = 35 * (gantt_data.data.length + 1) + 1;
$('#gantt_output').height(gantt_output_height).show().dhx_gantt({
data: gantt_data,
......
......@@ -101,7 +101,10 @@ class CoreObject(Process):
activeEntity=activeObjectQueue[0]
activeObjectQueue.pop(0) #remove the Entity from the queue
self.timeLastEntityLeft=now()
self.outputTrace(activeEntity.name, "released "+self.objName)
try:
self.outputTrace(activeEntity.name, "released "+self.objName)
except TypeError:
pass
return activeEntity
# ================================== gets an entity from the ====================================
......@@ -130,7 +133,10 @@ class CoreObject(Process):
activeEntity.schedule.append([activeObject,now()])
activeEntity.currentStation=self
self.timeLastEntityEntered=now()
self.outputTrace(activeEntity.name, "got into "+self.objName)
try:
self.outputTrace(activeEntity.name, "got into "+self.objName)
except TypeError:
pass
return activeEntity
# ========================== actions to be taken after the simulation ends ======================
......
......@@ -84,11 +84,14 @@ class Failure(ObjectInterruption):
def run(self):
while 1:
yield hold,self,self.rngTTF.generateNumber() # wait until a failure happens
if(len(self.getVictimQueue())>0): # when a Machine gets failure
self.interrupt(self.victim) # while in process it is interrupted
self.victim.Up=False
self.victim.timeLastFailure=now()
self.outputTrace("is down")
try:
if(len(self.getVictimQueue())>0): # when a Machine gets failure
self.interrupt(self.victim) # while in process it is interrupted
self.victim.Up=False
self.victim.timeLastFailure=now()
self.outputTrace("is down")
except AttributeError:
print "AttributeError1"
# update the failure time
failTime=now()
if(self.repairman!="None"): #if the failure needs a resource to be fixed, the machine waits until the
......@@ -101,13 +104,16 @@ class Failure(ObjectInterruption):
yield hold,self,self.rngTTR.generateNumber() # wait until the repairing process is over
self.victim.totalFailureTime+=now()-failTime
if(len(self.getVictimQueue())>0):
reactivate(self.victim) # since repairing is over, the Machine is reactivated
self.victim.Up=True
self.outputTrace("is up")
if(self.repairman!="None"): #if a resource was used, it is now released
yield release,self,self.repairman.getResource()
self.repairman.totalWorkingTime+=now()-timeOperationStarted
try:
if(len(self.getVictimQueue())>0):
reactivate(self.victim) # since repairing is over, the Machine is reactivated
self.victim.Up=True
self.outputTrace("is up")
if(self.repairman!="None"): #if a resource was used, it is now released
yield release,self,self.repairman.getResource()
self.repairman.totalWorkingTime+=now()-timeOperationStarted
except AttributeError:
print "AttributeError2"
#outputs message to the trace.xls. Format is (Simulation Time | Machine Name | message)
def outputTrace(self, message):
......
......@@ -178,8 +178,10 @@ def createObjects():
name = element.get('name', 'not found') # get the name of the element / default 'not_found'
capacity = int(element.get('capacity', '1')) # get the capacity of the el. / defautl '1'
O = Operator(element_id, name, capacity) # create an operator object
O.coreObjectIds=getSuccessorList(id) # update the list of objects that the operator operates
# calling the getSuccessorList() method on the operator
try:
O.coreObjectIds=getSuccessorList(id) # update the list of objects that the operator operates
except: # calling the getSuccessorList() method on the operator
pass
G.OperatorsList.append(O) # add the repairman to the RepairmanList
elif resourceClass=='Dream.OperatorPool':
id = element.get('id', 'not found') # get the id of the element / default 'not_found'
......@@ -195,8 +197,11 @@ def createObjects():
else:
OP = OperatorPool(element_id, name, capacity,operatorsList) # create a operatorPool object
OP.coreObjectIds=getSuccessorList(id) # update the list of objects that the operators of the operatorPool operate
for operator in operatorsList.values():
operator.coreObjectIds=OP.coreObjectIds # update the list of objects that the operators operate
try:
for operator in operatorsList.values():
operator.coreObjectIds=OP.coreObjectIds # update the list of objects that the operators operate
except:
pass
G.OperatorPoolsList.append(OP) # add the repairman to the RepairmanList
# -----------------------------------------------------------------------
# loop through all the elements
......@@ -629,9 +634,15 @@ def initializeObjects():
# ===========================================================================
def activateObjects():
for element in G.ObjList:
activate(element, element.run())
try:
activate(element, element.run())
except AttributeError:
pass
for ev in G.EventGeneratorList:
activate(ev, ev.run())
try:
activate(ev, ev.run())
except AttributeError:
pass
# ===========================================================================
# reads the WIP of the stations
......@@ -648,7 +659,11 @@ def createWIP():
element['id'] = element_id
wip=element.get('wip', [])
for entity in wip:
entityClass=entity.get('_class', None)
entityClass=None
try:
entityClass=entity.get('_class', None)
except IndexError:
continue
if entityClass=='Dream.Job':
id=entity.get('id', 'not found')
......@@ -784,11 +799,17 @@ def main(argv=[], input_data=None):
#output data to JSON for every object in the topology
for element in G.ObjList:
element.outputResultsJSON()
try:
element.outputResultsJSON()
except AttributeError:
pass
#output data to JSON for every resource in the topology
for model_resource in G.RepairmanList:
model_resource.outputResultsJSON()
try:
model_resource.outputResultsJSON()
except AttributeError:
pass
for job in G.JobList:
job.outputResultsJSON()
......
......@@ -280,7 +280,10 @@ class Machine(CoreObject):
# checks if the machine down or it can dispose the object
# =======================================================================
def ifCanDisposeOrHaveFailure(self):
return self.Up==False or self.getReceiverObject().canAccept(self) or len(self.getActiveObjectQueue())==0
try:
return self.Up==False or self.getReceiverObject().canAccept(self) or len(self.getActiveObjectQueue())==0
except AttributeError:
return False
# =======================================================================
# removes an entity from the Machine
......
......@@ -64,18 +64,11 @@ class Queue(CoreObject):
self.isDummy=dummy #Boolean that shows if it is the dummy first Queue
self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows
self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue
SRlist = [schedulingRule]
if schedulingRule.startswith("MC"): # if the first criterion is MC aka multiple criteria
SRlist = schedulingRule.split("-") # split the string of the criteria (delimiter -)
self.schedulingRule=SRlist.pop(0) # take the first criterion of the list
self.multipleCriterionList=SRlist # hold the criteria list in the property multipleCriterionList
for scheduling_rule in SRlist:
if scheduling_rule not in ("FIFO", "Priority", "EDD", "EOD",
"NumStages", "RPC", "LPT", "SPT", "MS", "WINQ"):
raise ValueError("Unknown scheduling rule %s for %s" %
(scheduling_rule, id))
def initialize(self):
# using the Process __init__ and not the CoreObject __init__
CoreObject.initialize(self)
......@@ -275,12 +268,4 @@ class Queue(CoreObject):
nextObject=obj
entity.nextQueueLength=len(nextObject.getActiveObjectQueue())
activeObjectQ.sort(key=lambda x: x.nextQueueLength)
else:
assert False, "Unknown scheduling criterion %r" % (criterion, )
def outputResultsJSON(self):
from Globals import G
json = {'_class': 'Dream.%s' % self.__class__.__name__,
'id': str(self.id),
'schedulingRule': self.schedulingRule}
G.outputJSON['elementList'].append(json)
\ No newline at end of file
{
"elementList": [
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......@@ -34,11 +29,6 @@
"waiting_ratio": 3.888888888888889
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Repairman",
"id": "W1",
......
{
"elementList": [
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......
{
"elementList": [
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......@@ -34,11 +29,6 @@
"waiting_ratio": 0.0
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Repairman",
"id": "W1",
......
......@@ -37,11 +37,6 @@
"failure_ratio": 19.444444444444443,
"waiting_ratio": 18.368055555555557
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
{
"elementList": [
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......@@ -44,11 +39,6 @@
"waiting_ratio": 18.680555555555557
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Repairman",
"id": "W1",
......
......@@ -38,11 +38,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 1.875
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -48,11 +48,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 0.017361111111111112
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -48,11 +48,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 0.052083333333333336
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
{
"elementList": [
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......@@ -44,11 +39,6 @@
"waiting_ratio": 0.10416666666666667
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Repairman",
"id": "W1",
......
{
"elementList": [
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......@@ -54,11 +49,6 @@
"waiting_ratio": 0.1388888888888889
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Repairman",
"id": "W1",
......
......@@ -9,11 +9,6 @@
"waiting_ratio": 6.887731481480949
}
},
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......
......@@ -9,11 +9,6 @@
"waiting_ratio": 6.601851851851579
}
},
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......
{
"elementList": [
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......@@ -33,11 +28,6 @@
"failure_ratio": 19.444444444444443,
"waiting_ratio": 3.1944444444444446
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -143,21 +143,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 50.0
}
},
{
"_class": "Dream.QueueJobShop",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.QueueJobShop",
"id": "Q2",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.QueueJobShop",
"id": "Q3",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -248,21 +248,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 69.23076923076923
}
},
{
"_class": "Dream.QueueJobShop",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.QueueJobShop",
"id": "Q2",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.QueueJobShop",
"id": "Q3",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -396,21 +396,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 78.26086956521739
}
},
{
"_class": "Dream.QueueJobShop",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.QueueJobShop",
"id": "Q2",
"schedulingRule": "MC"
},
{
"_class": "Dream.QueueJobShop",
"id": "Q3",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -18,11 +18,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 20.03472222222222
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -38,16 +38,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 75.06944444444444
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Queue",
"id": "Q2",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -38,16 +38,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 75.06944444444444
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.LineClearance",
"id": "Q2",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
{
"elementList": [
{
"_class": "Dream.Queue",
"id": "DummyQ",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Exit",
"id": "E1",
......@@ -33,11 +28,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 1.7361111111111112
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -38,21 +38,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 7.566666666666668
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.LineClearance",
"id": "Q2",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Queue",
"id": "Q3",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -263,21 +263,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 32.432432432432435
}
},
{
"_class": "Dream.QueueJobShop",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.QueueJobShop",
"id": "Q2",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.QueueJobShop",
"id": "Q3",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
......@@ -28,16 +28,6 @@
"failure_ratio": 0.0,
"waiting_ratio": 25.125
}
},
{
"_class": "Dream.Queue",
"id": "Q1",
"schedulingRule": "FIFO"
},
{
"_class": "Dream.Queue",
"id": "Q2",
"schedulingRule": "FIFO"
}
],
"_class": "Dream.Simulation",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment