Commit 3b91572e authored by Georgios Dagkakis's avatar Georgios Dagkakis

Merge branch 'CapacityStationPlugins' into renderjsie_merged

parents a25184c1 621ee478
from copy import copy
import json
import time
import random
import operator
import datetime
from dream.plugins import plugin
class AvailableCapacitySpreadsheet(plugin.InputPreparationPlugin):
""" Input prepration
read capacity data and update the capacity property of the stations.
"""
def preprocess(self, data):
strptime = datetime.datetime.strptime
capacityData=data['input'].get('available_capacity_spreadsheet', None)
node=data['graph']['node']
now = strptime(data['general']['currentDate'], '%Y/%m/%d')
if capacityData:
numberOfStations=len(capacityData[0])-1
numberOfExceptions=len(capacityData)
# loop through stations
for col in range(numberOfStations):
stationId=capacityData[0][col+1]
assert stationId in data['graph']['node'].keys(), 'available capacity spreadsheet has station id that does not exist in production line'
# for every station read the interval capacity (Monday to Sunday)
intervalCapacity=[]
for row in range(7):
intervalCapacity.append(float(capacityData[row+1][col+1]))
node[stationId]['intervalCapacity']=intervalCapacity
# for every station read the interval capacity exceptions
for row in range(8,len(capacityData)):
if not capacityData[row][0]:
break
exeptionDate=strptime(capacityData[row][0], '%Y/%m/%d')
dayDifference=(exeptionDate-now).days
assert dayDifference>=0, 'exception date for past day given'
intervalCapacityExceptions=node[stationId].get('intervalCapacityExceptions',{})
if not intervalCapacityExceptions:
node[stationId]['intervalCapacityExceptions']={}
node[stationId]['intervalCapacityExceptions'][str(float(dayDifference))]=float(capacityData[row][col+1])
# set the interval capacity start
node[stationId]['intervalCapacityStart']=now.weekday()
return data
\ No newline at end of file
from copy import copy
import json
import time
import random
import operator
import datetime
from dream.plugins import plugin
class CapacityProjectSpreadsheet(plugin.InputPreparationPlugin):
""" Input prepration
read the capacity projects from the spreadsheet
"""
def preprocess(self, data):
strptime = datetime.datetime.strptime
projectData=data['input'].get('projects_spreadsheet', None)
data['input']['BOM']={} # Put the projects in BOM. Discuss this!
node=data['graph']['node']
now = strptime(data['general']['currentDate'], '%Y/%m/%d')
if projectData:
for row in range(1, len(projectData)):
if projectData[row][0]:
projectId=projectData[row][0]
orderDate=strptime(projectData[row][1], '%Y/%m/%d')
orderDate=(orderDate-now).days
try:
dueDate=strptime(projectData[row][2], '%Y/%m/%d')
dueDate=(dueDate-now).days
# if no due date is given set it to 180 (about 6 months)
except ValueError:
dueDate=180
assemblySpaceRequirement=float(projectData[row][3])
capacityRequirementDict={}
earliestStartDict={}
# get the number of operations of the project
numberOfOperations=1
i=1
while not projectData[row+i][0]:
# if a completely empty line is found break
if all(v is None for v in projectData[row+i]):
break
numberOfOperations+=1
i+=1
# for every operation get capacityRequirementDict and earliestStartDict
for stationRecord in range(numberOfOperations):
stationId=projectData[row+stationRecord][4]
requiredCapacity=projectData[row+stationRecord][5]
earliestStart=projectData[row+stationRecord][6]
capacityRequirementDict[stationId]=float(requiredCapacity)
if earliestStart:
earliestStart=strptime(earliestStart, '%Y/%m/%d')
earliestStartDict[stationId]=(earliestStart-now).days
# define the order in BOM
data['input']['BOM'][projectId]={
'orderDate':orderDate,
'dueDate':dueDate,
'assemblySpaceRequirement':assemblySpaceRequirement,
'capacityRequirementDict':capacityRequirementDict,
'earliestStartDict':earliestStartDict
}
print data['input']['BOM']
return data
\ No newline at end of file
...@@ -54,11 +54,11 @@ class PluginRegistry(object): ...@@ -54,11 +54,11 @@ class PluginRegistry(object):
def __init__(self, logger, data): def __init__(self, logger, data):
self.input_preparation_list = [] self.input_preparation_list = []
for plugin_data in data['application_configuration']['pre_processing_plugin_list']: for plugin_data in data['application_configuration']['pre_processing']['plugin_list']:
self.input_preparation_list.append(resolve(plugin_data['_class'])(logger, plugin_data)) self.input_preparation_list.append(resolve(plugin_data['_class'])(logger, plugin_data))
self.output_preparation_list = [] self.output_preparation_list = []
for plugin_data in data['application_configuration']['post_processing_plugin_list']: for plugin_data in data['application_configuration']['post_processing']['plugin_list']:
self.output_preparation_list.append(resolve(plugin_data['_class'])(logger, plugin_data)) self.output_preparation_list.append(resolve(plugin_data['_class'])(logger, plugin_data))
plugin_data = data['application_configuration']['processing_plugin'] plugin_data = data['application_configuration']['processing_plugin']
......
...@@ -261,8 +261,13 @@ ...@@ -261,8 +261,13 @@
"type": "object_view" "type": "object_view"
} }
}, },
"post_processing_plugin_list": [], "post_processing": {
"pre_processing_plugin_list": [ "description" : "",
"plugin_list" : []
},
"pre_processing": {
"description" : "",
"plugin_list" : [
{ {
"_class": "dream.plugins.GatherWIPStat.GatherWIPStat", "_class": "dream.plugins.GatherWIPStat.GatherWIPStat",
"input_id": "WIPStat" "input_id": "WIPStat"
...@@ -283,8 +288,10 @@ ...@@ -283,8 +288,10 @@
"_class": "dream.plugins.ReadShiftFromSpreadsheet.ReadShiftFromSpreadsheet", "_class": "dream.plugins.ReadShiftFromSpreadsheet.ReadShiftFromSpreadsheet",
"input_id": "ShiftSpreadsheet" "input_id": "ShiftSpreadsheet"
} }
], ]
},
"processing_plugin": { "processing_plugin": {
"description" : "",
"_class": "dream.plugins.plugin.DefaultExecutionPlugin" "_class": "dream.plugins.plugin.DefaultExecutionPlugin"
} }
}, },
......
{
"class_definition": {
"definitions": {
"distributionTypes": {
"_fixed": {
"description": "Fixed",
"title": "Fixed",
"type": "object",
"properties": {
"mean": {
"type": "number",
"default": 0.75,
"required": true
}
}
},
"_exp": {
"type": "object",
"title": "Exp",
"description": "Exponential",
"properties": {
"mean": {
"type": "number",
"default": 0,
"required": true
}
}
},
"_normal": {
"type": "object",
"title": "Normal",
"description": "Normal",
"properties": {
"mean": {
"type": "number",
"default": 0,
"required": true
},
"stdev": {
"type": "number",
"default": 0,
"required": true
}
}
},
"_lognormal": {
"type": "object",
"title": "Lognormal",
"description": "Lognormal",
"properties": {
"mean": {
"_class": "Dream.Property",
"name": "Mean",
"type": "number",
"default": 0
},
"stdev": {
"_class": "Dream.Property",
"name": "Standard Deviation",
"type": "number",
"default": 0
}
}
},
"_binomial": {
"type": "object",
"title": "Binomial",
"description": "Binomial",
"properties": {
"mean": {
"type": "number",
"default": 0
},
"size": {
"type": "number",
"default": 0
}
}
},
"_poisson": {
"type": "object",
"title": "Poisson",
"description": "Poisson",
"properties": {
"lambda": {
"type": "number",
"default": 0
}
}
},
"_logistic": {
"type": "object",
"title": "Logistic",
"description": "Logistic",
"properties": {
"location": {
"type": "number",
"default": 0,
"required": true
},
"scale": {
"type": "number",
"default": 0,
"required": true
}
}
},
"_cauchy": {
"type": "object",
"title": "Cauchy",
"description": "Cauchy",
"properties": {
"location": {
"type": "number",
"default": 0
},
"scale": {
"type": "number",
"default": 0
}
}
},
"_geometric": {
"type": "object",
"title": "Geometric",
"description": "Geometric",
"properties": {
"probability": {
"type": "number",
"default": 0,
"required": true
}
}
},
"_gama": {
"type": "object",
"title": "Gama",
"description": "Gama",
"properties": {
"shape": {
"type": "number",
"default": 0,
"required": true
},
"rate": {
"type": "number",
"default": 0,
"required": true
}
}
},
"_weibull": {
"type": "object",
"title": "Weibull",
"description": "Weibull",
"properties": {
"shape": {
"type": "number",
"default": 0,
"required": true
},
"scale": {
"type": "number",
"default": 0,
"required": true
}
}
},
"_failure": {
"type": "object",
"title": "Yes",
"description": "Fixed",
"properties": {
"Time to Failure": {
"$ref": "#/definitions/_dist"
},
"Time to Repair": {
"$ref": "#/definitions/_dist"
},
"repairman": {
"description": "Repairman",
"type": "string",
"required": true
}
}
},
"_no": {
"type": "string",
"title": "No",
"description": "None"
}
},
"_failureDist": {
"allOf": [
{
"type": "object",
"properties": {
"failureDistribution": {
"type": "string",
"default": "No",
"enum": [
"No",
"Yes"
]
}
}
},
{
"oneOf": [
{
"$ref": "#/definitions/distributionTypes/_failure"
},
{
"$ref": "#/definitions/distributionTypes/_no"
}
]
}
]
},
"_dist": {
"allOf": [
{
"type": "object",
"properties": {
"distribution": {
"type": "string",
"default": "Fixed",
"enum": [
"Fixed",
"Exp",
"Normal",
"Lognormal",
"Binomial",
"Poisson",
"Logistic",
"Cauchy",
"Geometric",
"Gama",
"Weibull"
]
}
}
},
{
"oneOf": [
{
"$ref": "#/definitions/distributionTypes/_fixed"
},
{
"$ref": "#/definitions/distributionTypes/_exp"
},
{
"$ref": "#/definitions/distributionTypes/_normal"
},
{
"$ref": "#/definitions/distributionTypes/_lognormal"
},
{
"$ref": "#/definitions/distributionTypes/_binomial"
},
{
"$ref": "#/definitions/distributionTypes/_poisson"
},
{
"$ref": "#/definitions/distributionTypes/_logistic"
},
{
"$ref": "#/definitions/distributionTypes/_cauchy"
},
{
"$ref": "#/definitions/distributionTypes/_geometric"
},
{
"$ref": "#/definitions/distributionTypes/_gama"
},
{
"$ref": "#/definitions/distributionTypes/_weibull"
}
]
}
]
},
"_schedulingRule": {
"description": "Scheduling Rule, one of FIFO Priority EDD EOD NumStages RPC LPT SPT MS WINQ",
"type": "string",
"default": "FIFO",
"enum": [
"FIFO",
"Priority",
"EDD",
"EOD",
"NumStages",
"RPC",
"LPT",
"SPT",
"MS",
"WINQ",
"WT"
]
},
"_capacity": {
"description": "capacity of the queue. -1 means infinite",
"type": "number",
"default": 1,
"oneOf": [
{
"enum": [
-1
]
},
{
"multipleOf": 1
}
]
},
"_operationType": {
"description": "the type of operations that are performed manually in the machine",
"default": "Automatic",
"type": "string",
"enum": [
"Automatic",
"Manual"
]
}
},
"edge": {
"description": "Base definition for edge",
"properties": {
"_class": {
"type": "string"
},
"source": {
"type": "string"
},
"destination": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"_class",
"source",
"destination"
],
"type": "object"
},
"node": {
"description": "Base definition for node",
"properties": {
"_class": {
"type": "string"
},
"coordinate": {
"properties": {
"left": "number",
"top": "number"
},
"type": "object"
},
"name": {
"type": "string"
}
},
"required": [
"name",
"_class"
],
"type": "object"
},
"Dream.Edge": {
"_class": "edge",
"allOf": [
{
"$ref": "#/class_defintion/edge"
}
],
"description": "Connect stations together"
},
"Dream.Dream.AbstractCapacityStation": {
"name": "Machine",
"description": "A station processing items for some time given by a distribution",
"_class": "node",
"css": {
"border": "1px solid #cbc",
"backgroundColor": "#fef",
"backgroundImage": "linear-gradient(to bottom, #fef 0%, #ede 100%)"
},
"allOf": [
{
"$ref": "#/node"
},
{
"type": "object",
"properties": {
"name": {
"type": "string",
"default": "Machine"
},
"id": {
"type": "string",
"default": "M",
"required": true
},
"Is an assembly station?": {
"_default": 0,
"description": "Is this station an assembly ? Yes: 1, No: 0",
"type": "number",
"required": true
}
}
}
]
}
},
"application_configuration": {
"input": {
"view": {
"title": "ProductionLine",
"type": "object_view",
"gadget": "Input_viewProductionLine"
},
"view_management": {
"gadget": "Input_viewDocumentManagement",
"type": "object_view",
"title": "Manage document"
},
"view_available_capacity_spreadsheet": {
"gadget": "Input_viewSpreadsheet",
"type": "object_view",
"title": "Available Capacity Spreadsheet",
"configuration": {
"extend": [
"x",
"y"
],
"columns": [
{
"name": "Day",
"type": "string",
"format": "date-time"
},
{
"name": "Station 1 (Rename)",
"type": "string"
},
{
"name": "Station 2 (Rename)",
"type": "string"
}
]
}
},
"view_projects_spreadsheet": {
"gadget": "Input_viewSpreadsheet",
"type": "object_view",
"title": "Projects Spreadsheet",
"configuration": {
"extend": [
"y"
],
"columns": [
{
"name": "Project ID",
"type": "string"
},
{
"name": "Order Date",
"type": "string",
"format": "date"
},
{
"name": "Due Date",
"type": "string",
"format": "date"
},
{
"name": "Assembly Space",
"type": "number"
},
{
"name": "Operation",
"type": "string"
},
{
"name": "Capacity Requirement",
"type": "number"
},
{
"name": "Earliest Start Date",
"type": "string",
"format": "date"
}
]
}
},
"view_wip_spreadsheet": {
"gadget": "Input_viewSpreadsheet",
"type": "object_view",
"title": "Work in Progress Spreadsheet",
"configuration": {
"extend": [
"x",
"y"
],
"columns": [
{
"name": "Operation",
"type": "string"
},
{
"name": "Project1 (Rename)",
"type": "string"
},
{
"name": "Project2 (Rename)",
"type": "string"
}
]
}
},
"view_run_simulation": {
"title": "Run Simulation",
"type": "object_view",
"gadget": "Input_viewSimulation"
},
"view_result": {
"gadget": "Input_viewResultList",
"type": "object_view",
"title": "Results"
}
},
"output": {
"view_mean_capacity_utilization": {
"title": "Average Capacity Utilization",
"type": "object_view",
"gadget": "Output_viewBarGraph",
"configuration": {
"family": "capacityStation",
"plot": "bar",
"group": [],
"data": {
"utilization": [
"meanUtilization"
]
}
}
},
"view_capacity_utilization": {
"title": "Capacity Utilization",
"type": "object_view",
"gadget": "Output_viewLineGraph",
"configuration": {
"family": "capacityStation",
"plot": "lines",
"group": [
"id"
],
"data": {
"Capacity": [
"capacity_level"
],
"Utilization": [
"utilization_level"
]
}
}
},
"view_expencted_delivery_date": {
"title": "Expected Delivery Date",
"type": "object_view",
"gadget": "Input_viewSpreadSheet",
"configuration": {
"type": "output",
"extend": [],
"columns": [
{
"name": "Project ID",
"type": "string"
},
{
"name": "Delivery Date",
"type": "string",
"format": "date"
}
]
}
},
"view_job_gantt": {
"title": "Job Gantt",
"type": "object_view",
"gadget": "Output_viewGantt",
"configuration": {
"family": "??"
}
},
"view_job_schedule": {
"title": "Job Schedule",
"type": "object_view",
"gadget": "Input_viewSpreadSheet",
"configuration": {
"type": "output",
"extend": [],
"columns": [
{
"name": "Project ID",
"type": "string"
},
{
"name": "Due Date",
"type": "string",
"format": "date"
},
{
"name": "Assembly Space",
"type": "number"
},
{
"name": "Operation",
"type": "string"
},
{
"name": "Capacity Requirement",
"type": "number"
},
{
"name": "Earliest Start Date",
"type": "string",
"format": "date"
}
]
}
},
"view_debug_json": {
"title": "DebugJson",
"type": "object_view",
"gadget": "Output_viewDebugJson"
}
},
"pre_processing": {
"plugin_list": [
{
"_class": "dream.plugins.AvailableCapacitySpreadsheet.AvailableCapacitySpreadsheet",
"input_id": "availableCapacity"
},
{
"_class": "dream.plugins.CapacityProjectSpreadsheet.CapacityProjectSpreadsheet",
"input_id": "capacityProject"
}
]
},
"processing_plugin": {
"_class": "dream.plugins.plugin.DefaultExecutionPlugin",
"input_id": "Simulation"
},
"post_processing": {
"plugin_list": []
},
"general": {
"properties": {
"numberOfReplications": {
"title": "Number of replications",
"type": "integer",
"description": "Number of replications to run",
"default": 10
},
"maxSimTime": {
"title": "Length of Experiment",
"description": "Length of the simulation run",
"type": "number",
"default": 100
},
"confidenceLevel": {
"title": "Confidence level",
"type": "number",
"default": 0.95,
"description": "Confidence level for statistical analysis of stochastic experiments"
},
"processTimeout": {
"title": "ProcessTimeout",
"type": "number",
"default": 10,
"description": "Number of seconds before the calculation process is interrupted"
},
"currentDate": {
"default": "2014/10/01",
"description": "The day the experiment starts, in YYYY/MM/DD format",
"title": "SimulationStartTime",
"type": "string"
},
"timeUnitPerDay": {
"default": 24,
"description": "Used for input and reporting widgets. For example, 24 means that simulation clock time unit is one hour.",
"title": "Number of time units per day",
"type": "number"
},
"trace": {
"default": "No",
"enum": [
"No",
"Yes"
],
"description": "Create an excel trace file (Yes or No)",
"title": "OutputTrace",
"type": "string"
},
"seed": {
"default": "1",
"description": "When using the same seed, the random number generator produce the same sequence of numbers",
"title": "Seed for random number generator",
"type": "number"
},
"ke_url": {
"default": "http: //git.erp5.org/gitweb/dream.git/blob_plain/HEAD: /dream/KnowledgeExtraction/Mockup_Processingtimes.xls",
"description": "The URL for knowledge extraction to access its data for example http: //git.erp5.org/gitweb/dream.git/blob_plain/HEAD: /dream/KnowledgeExtraction/Mockup_Processingtimes.xls",
"title": "URL for Knowledge Extraction Spreadsheet",
"type": "string"
}
}
}
},
"general": {},
"graph": {
"node": {},
"edge": {}
},
"input": {},
"result": {
"result_list": []
},
"constraints": {}
}
\ No newline at end of file
...@@ -314,25 +314,14 @@ ...@@ -314,25 +314,14 @@
] ]
}, },
"_operationType": { "_operationType": {
"_class": "Dream.PropertyList",
"name": "Operation type",
"id": "operationType",
"description": "the type of operations that are performed manually in the machine", "description": "the type of operations that are performed manually in the machine",
"properties": { "default": "Automatic",
"operationType": {
"type": "string", "type": "string",
"enum": [ "enum" : [
"Load", "Automatic",
"Setup", "Manual"
"Processing",
"MT-Load",
"MT-Load-Setup",
"MT-Load-Setup-Processing",
"MT-Setup-Processing"
] ]
} }
}
}
}, },
"edge": { "edge": {
"description": "Base definition for edge", "description": "Base definition for edge",
...@@ -479,6 +468,34 @@ ...@@ -479,6 +468,34 @@
"default": "M", "default": "M",
"required": true "required": true
}, },
"operationType": {
"description": "Type Of Operation",
"name" : "Operation Type",
"type": "object",
"properties" : {
"load": {
"description": "Operation type for loading",
"$ref": "#/definitions/_operationType"
},
"setup": {
"description": "Operation type for setup",
"$ref": "#/definitions/_operationType",
},
"processing": {
"description": "Operation type for processing",
"$ref": "#/definitions/_operationType",
}
}
"required" : ["load", "setup", "processing"]
},
"loadTime": {
"$ref": "#/definitions/_dist",
"required": true
},
"setupTime": {
"$ref": "#/definitions/_dist",
"required": true
},
"processingTime": { "processingTime": {
"$ref": "#/definitions/_dist", "$ref": "#/definitions/_dist",
"required": true "required": true
...@@ -772,27 +789,26 @@ ...@@ -772,27 +789,26 @@
} }
} }
}, },
"preprocessing": { "pre_processing": {
"description" : "",
"plugin_list": [ "plugin_list": [
{ {
"plugin": "GatherWIPStat.GatherWIPStat", "_class": "dream.plugins.GatherWIPStat.GatherWIPStat",
"input_id": "WIPStat" "input_id": "WIPStat"
}, },
{ {
"plugin": "WIPSpreadsheet.WIPSpreadsheet", "_class": "dream.plugins.WIPSpreadsheet.WIPSpreadsheet",
"input_id": "WIPdata" "input_id": "WIPdata"
} }
] ]
}, },
"processing": { "processing_plugin": {
"plugin_list": [ "description" : "",
{ "_class": "dream.plugins.plugin.DefaultExecutionPlugin",
"plugin": "plugin.DefaultExecutionPlugin",
"input_id": "Simulation" "input_id": "Simulation"
}
]
}, },
"postprocessing": { "post_processing": {
"description" : "",
"plugin_list": [] "plugin_list": []
}, },
"general": { "general": {
......
...@@ -838,25 +838,32 @@ ...@@ -838,25 +838,32 @@
} }
} }
}, },
"preprocessing" : { "pre_processing" : {
"description" : "",
"plugin_list" : [{ "plugin_list" : [{
"plugin" : "PartJobShop", "_class" : "dream.plugins.PartJobShop.PartJobShop",
"input_id" : "Simulation" "input_id" : "Simulation"
}, { }, {
"plugin" : "ReadShiftFromSpreadsheet", "_class" : "dream.plugins.ReadShiftFromSpreadsheet.ReadShiftFromSpreadsheet",
"input_id" : "ShiftSpreadsheet" "input_id" : "ShiftSpreadsheet"
}, { }, {
"plugin" : "ReadWipFromSpreadsheet", "_class" : "dream.plugins.ReadWipFromSpreadsheet.ReadWipFromSpreadsheet",
"input_id" : "WipSpreadsheet" "input_id" : "WipSpreadsheet"
}, { }, {
"plugin" : "ReadRouteFromSpreadsheet", "_class" : "dream.plugins.ReadRouteFromSpreadsheet.ReadRouteFromSpreadsheet",
"input_id" : "RouteSpreadsheet" "input_id" : "RouteSpreadsheet"
} }
] ]
}, },
"postprocessing" : { "processing_plugin" : {
"description" : "",
"_class" : "",
"input_id" : ""
}
"post_processing" : {
"description" : "",
"plugin_list" : [{ "plugin_list" : [{
"plugin" : "CalculateConfidenceIntervals" "_class" : "dream.plugins.CalculateConfidenceIntervals.CalculateConfidenceIntervals"
}] }]
}, },
"general" : { "general" : {
......
...@@ -810,7 +810,9 @@ ...@@ -810,7 +810,9 @@
} }
} }
}, },
"pre_processing_plugin_list": [ "pre_processing": {
"description" : "",
"_plugin_list": [
{ {
"_class": "dream.plugins.Debug.Debug", "_class": "dream.plugins.Debug.Debug",
"argument": "Argument Value" "argument": "Argument Value"
...@@ -819,11 +821,16 @@ ...@@ -819,11 +821,16 @@
"_class": "dream.plugins.OldStylePartJobShopWIP.OldStylePartJobShopWIP", "_class": "dream.plugins.OldStylePartJobShopWIP.OldStylePartJobShopWIP",
"input_id": "old_style_part_jobshop_spreadsheet" "input_id": "old_style_part_jobshop_spreadsheet"
} }
], ]
},
"processing_plugin": { "processing_plugin": {
"description": "",
"_class": "dream.plugins.ACO.ACO" "_class": "dream.plugins.ACO.ACO"
}, },
"post_processing_plugin_list": [], "post_processing": {
"description": "",
"plugin_list": []
},
"general": { "general": {
"properties": { "properties": {
"numberOfReplications": { "numberOfReplications": {
......
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