Core¶
The core package contains the most essential files in our ManPy extension.
manpy.simulation.core.Feature.py¶
- class manpy.simulation.core.Feature.Feature(id='', name='', victim=None, distribution={}, distribution_state_controller=None, reset_distributions=True, no_negative=False, contribute=None, start_time=0, end_time=0, start_value=None, random_walk=False, dependent=None)[source]¶
Bases:
ObjectPropertyThe Feature ObjectProperty generates Features for a Machine and stores them in Entities
- Parameters:
id – The id of the Feature
name – The name of the Feature
victim – The machine to which the feature belongs
distribution – The statistical distribution of the value of the Feature
distribution_state_controller – StateController that can contain different distributions.
reset_distributions – Active with deteriorationType working; Resets distribution_state_controller when the victim is interrupted (=repaired)
no_negative – If this value is true, returns 0 for values below 0 of the feature value
contribute – Needs Failures in a list as an input to contribute the Feature value to conditions
start_time – The starting time for the feature. If >0, the feature generation is started if start_time is reached
end_time – The end time for the feature. If >0 and > start_time, the feature generation is ended if end_time is reached
start_value – The starting value of the Feature
random_walk – If this is True, the Feature will continuously take the previous feature_value into account
dependent – A dictionary containing a Function and the corresponding variables, to determine dependencies between features
kw – The keyword arguments
manpy.simulation.core.Timeseries.py¶
- class manpy.simulation.core.Timeseries.Timeseries(id='', name='', victim=None, distribution={}, no_negative=False, contribute=None, start_value=0, random_walk=False, step_time=None)[source]¶
Bases:
ObjectPropertyThe TimeSeries ObjectProperty generates TimeSeries for a Machine and stores them in Entities
- Parameters:
id – The id of the Feature
name – The name of the Feature
victim – The machine to which the feature belongs
distribution – The statistical distribution of the value of the Datapoints
no_negative – If this value is true, returns 0 for values below 0 of the feature value
contribute – Needs Failures in a list as an input to contribute the TimeSeries value to conditions
start_value – The starting value of the TimeSeries
random_walk – If this is True, the TimeSeries will continuously take the previous Datapoint value into account
step_time – The time between each Datapoint for a TimeSeries
manpy.simulation.core.StateController.py¶
- class manpy.simulation.core.StateController.ContinuousNormalDistribution(mean_change_per_step, initial_mean, std, wear_per_step=0, break_point=None, defect_mean=None, defect_std=None)[source]¶
Bases:
StateControllerNormal Distribution that changes its mean value with each step. Optionally, a defect can occur after a defined period. Provides label.
- Parameters:
wear_per_step – How much wear happens per step
break_point – When this value of wear is reached, a defect happens. Will be ignored if None
mean_change_per_step – Value that is added to the mean of the normal distribution in each step
initial_mean – Initial mean value of the normal distribution
std – STD of the normal distribution, does not change
defect_mean – Mean value in the defect state
defect_std – STD in the defect state
- class manpy.simulation.core.StateController.RandomDefectStateController(failure_probability, ok_controller: StateController, defect_controllers: list)[source]¶
Bases:
StateControllerOrchestrates multiple StateControllers. Using a Bernoulli-Distribution, it chooses either the ok or the defect distribution.
- Parameters:
failure_probability – Probability of failure for the Bernoulli-Distribution.
ok_controller
defect_controllers – list of StateControllers. If a random failure occurs, one of them is drawn with uniform distribution. Example: in case of defect, a value can be either too high or too low
- class manpy.simulation.core.StateController.SimpleStateController(states: list, boundaries: dict, wear_per_step, labels=None, initial_state_index=0, reset_amount=None)[source]¶
Bases:
StateControllerSimple version of a StateController that sets states according to a certain amount of wear.
- Parameters:
(list) (states) – A list containing the actual states
(dict) (boundaries) – A dict defining the boundaries for each state. Must contain pairs of (interval, state_index). Intervals are defined as a tuple: (lower, upper). The lower bound is included, upper bound is not included. 0 must be included. Example: states = [state0, state1, state2] boundaries = {(0, 150): 0, (150, 300): 1, (300, None): 2}
wear_per_step – A number that defines how much wear is added per step. The account starts at 0.
reset_amount – When the account value reaches this amount, the StateController gets reset.
- class manpy.simulation.core.StateController.StateController[source]¶
Bases:
ABCAbstract base class for all StateControllers. A StateController must provide a get_and_update() and reset() method.
manpy.simulation.core.Machine.py¶
Created on 8 Nov 2012
@author: George
- class manpy.simulation.core.Machine.Machine(id, name, capacity=1, processingTime=None, repairman='None', operatorPool='None', operationType='None', setupTime=None, loadTime=None, preemption={}, canDeliverOnInterruption=False, technology=None, priority=0, control=None, cost=0, **kw)[source]¶
Bases:
CoreObjectModels a machine that can also have failures
- canAccept(callerObject=None)[source]¶
checks if the Machine can accept an entity. it checks also who called it and returns TRUE only to the predecessor that will give the entity.
- canAcceptAndIsRequested(callerObject=None)[source]¶
checks if the Machine can accept an entity and there is an entity in some possible giver waiting for it. also updates the giver to the one that is to be taken
- checkOperator(callerObject=None)[source]¶
to be called by canAcceptAndIsRequested and check for the operator
- haveToDispose(callerObject=None)[source]¶
checks if the Machine can dispose an entity to the following object
manpy.simulation.core.Assembly.py¶
Created on 18 Feb 2013
@author: George
- class manpy.simulation.core.Assembly.Assembly(id='', name='', cost=0, processingTime=None, entity='manpy.Part', inputsDict=None, **kw)[source]¶
Bases:
CoreObjectModels an assembly object it gathers frames and parts which are loaded to the frames
- appendEntity(entity=None)[source]¶
appends entity to the receiver object. to be called by the removeEntity of the giver. this method is created to be overridden by the Assembly class in its getEntity where Frames are loaded
- canAcceptAndIsRequested(callerObject=None)[source]¶
checks if the Assembly can accept a part or a Frame
manpy.simulation.core.Failure.py¶
Created on 9 Nov 2012
@author: George
- class manpy.simulation.core.Failure.Failure(id='', name='', victim=None, distribution={}, index=0, repairman=None, offshift=False, deteriorationType='constant', waitOnTie=False, conditional=None, entity=False, remove=False, cost=0, **kw)[source]¶
Bases:
ObjectInterruptionModels failures of machines.
- Parameters:
id – Internal ID of the failure.
name – Name of the failure.
victim – Victim (i.e. the machine that should fail) for the Failure
distribution – dictionary containing the individual distributions, e.g. TTF and TTR
index – Internal index, only used if name is empty.
repairman – Repairman with constrained resources that’s assigned to this failure. Optional.
offshift – flag used to identify if the time between failures should be counted while the victim is off-shift
deteriorationType – shows how the time to failure is measured; ‘constant’ means it counts not matter the state of the victim; ‘onShift’ counts only if the victim is onShift; ‘working’ counts only working time
waitOnTie – flag to show if the failure will wait on tie with other events before interrupting the victim
conditional – function that evaluates a condition. If return value true, the failure will be triggered. Is used instead of passing a TTF in distribution.
entity – With the parameter entity=True, the Time-to-Failure (TTF) is calculated based on the processing time of the entity within the machine
remove – Should the entities on which the failure occured be removed from the production line (=destroyed)?
kw
manpy.simulation.core.Source.py¶
Created on 8 Nov 2012
@author: George
- class manpy.simulation.core.Source.EntityGenerator(victim=None)[source]¶
Bases:
objectmodels the source object that generates the entities
- class manpy.simulation.core.Source.Source(id, name, cost=0, interArrivalTime=None, entity='manpy.Part', capacity=1, **kw)[source]¶
Bases:
CoreObjectSpawns new entities for the simulations.
- Parameters:
id – Internal ID
name – Name of the Source
interArrivalTime – Time until the next Entity is spawned
entity – Type of Entity that’s generated. One of “manpy.{Part, Batch, Frame, Job, CapacityEntity, CapacityProject}”.
capacity – Capacity of the generated Entities, Only relevant for entity=”manpy.Frame”
manpy.simulation.core.Queue.py¶
Created on 8 Nov 2012
@author: George
- class manpy.simulation.core.Queue.Queue(id='', name='', capacity=5, isDummy=False, schedulingRule='FIFO', level=None, gatherWipStat=False, cost=0, **kw)[source]¶
Bases:
CoreObjectModels a FIFO queue where entities can wait in order to get into a server
- activeQSorter(criterion=None)[source]¶
sorts the Entities of the Queue according to the scheduling rule
- canAccept(callerObject=None)[source]¶
checks if the Queue can accept an entity it checks also who called it and returns TRUE only to the predecessor that will give the entity.
- canAcceptAndIsRequested(callerObject=None)[source]¶
checks if the Queue can accept an entity and there is an entity in some predecessor waiting for it also updates the predecessorIndex to the one that is to be taken
- family = 'Buffer'¶
manpy.simulation.core.Exit.py¶
Created on 6 Feb 2013
@author: George
- class manpy.simulation.core.Exit.Exit(id, name, cost=0, cancelCondition={}, **kw)[source]¶
Bases:
CoreObjectmodels the exit of the model
- canAcceptAndIsRequested(callerObject=None)[source]¶
checks if the Exit can accept an entity and there is an entity waiting for it
- defineNext(successorList=[])[source]¶
Safeguarding for mistakenly trying to set the next element on an Exit object
- family = 'Exit'¶
manpy.simulation.core.Database.py¶
- class manpy.simulation.core.Database.ManPyKafkaConnection(producer, topics, bootstrap_server_address)[source]¶
Bases:
ManPyDatabase
- class manpy.simulation.core.Database.ManPyQuestDBDatabase(host='localhost', port=9009)[source]¶
Bases:
ManPyDatabase
manpy.simulation.core.Globals.py¶
Created on 8 Nov 2012
@author: George
- manpy.simulation.core.Globals.ExcelPrinter(df, filename)[source]¶
Prints a dataframe to excel
- Parameters:
df – The dataframe to export
filename – Filename for export
- class manpy.simulation.core.Globals.G[source]¶
Bases:
objectDefines global properties for the whole simulation
- static get_simulation_entities_history() DataFrame[source]¶
Iterates through all entities that passed through the simulation and collects their history, i.e. all the objects they passed through and when they entered/left them.
:returns History containing all
- static get_simulation_results_dataframe() DataFrame[source]¶
Collects the logs from the traces in the simulation into a pandas dataframe. This dataframe contains the columns: - Simulation time - Entity (aka Resource) name - Entity ID - Station (aka Machine) ID - Station name - Trace message
:returns Dataframe containing the described columns
- exception manpy.simulation.core.Globals.SetWipTypeError(setWipError)[source]¶
Bases:
ExceptionError in the setting up of the WIP
- manpy.simulation.core.Globals.getClassFromName(dotted_name)[source]¶
Import a class from a dotted name used in json.
- manpy.simulation.core.Globals.getFeatureData(objectList=[], time=False, price=False) DataFrame[source]¶
getFeatureData returns feature data of specific machines as dataframes
- Parameters:
objectList – a list of machines that will be included in the dataframe
time – boolean, should timestamps be included or not
- Returns:
dataframe
- manpy.simulation.core.Globals.getMethodFromName(dotted_name)[source]¶
returns a method by its name. name should be given as manpy.ClassName.MethodName
- manpy.simulation.core.Globals.getTimeSeriesData(ts) DataFrame[source]¶
getTimeSeriesData returns timeseries data
- Parameters:
ts – the timeseries you want the data of
- Returns:
dataframe with entity-ID|time|value as columns
- manpy.simulation.core.Globals.get_feature_labels_by_id(entity, feature_ids)[source]¶
Returns a list of the entity’s feature labels of the specified ids
- Parameters:
entity – The entity of which the feature labels should be retrieved.
feature_ids – List containing the IDs of the features (as string) that should be retrieved.
- manpy.simulation.core.Globals.get_feature_values_by_id(entity, feature_ids)[source]¶
Returns a list of the entity’s feature values of the specified ids
- Parameters:
entity – The entity of which the feature values should be retrieved.
feature_ids – List containing the IDs of the features (as string) that should be retrieved.
- manpy.simulation.core.Globals.moveExcess(consumption=1, safetyStock=70, giverId=None, receiverId=None)[source]¶
method to move entities exceeding a certain safety stock
- manpy.simulation.core.Globals.runSimulation(objectList=[], maxSimTime=100, numberOfReplications=1, trace=False, snapshots=False, seed=1, env=None, data='No', db: ManPyDatabase | None = None)[source]¶
Starts the simulation
- Parameters:
objectList – Objects for the simulation
maxSimTime – Timespan that’s simulated
numberOfReplications – TODO
trace – TODO
snapshots – TODO
seed – TODO
env – TODO
data – TODO
db – Database object. Optional. If passed, the results are saved to the database
- manpy.simulation.core.Globals.setWIP(entityList)[source]¶
method to set-up the entities in the current stations as Work In Progress in this case the current station must be defined! otherwise there is no current station but a list of possible stations although the entity cannot be in more than one stations
manpy.simulation.core.Entity.py¶
Created on 18 Aug 2013
@author: George
- class manpy.simulation.core.Entity.Entity(id=None, name=None, priority=0, dueDate=0, orderDate=0, isCritical=False, remainingProcessingTime=0, remainingSetupTime=0, currentStation=None, status='Good', **kw)[source]¶
Bases:
ManPyObjectThe entity object.
- responsibleForCurrentStep()[source]¶
return the responsible operator for the current step, not implemented for entities
- set_timeseries(timeseries, label, time, indexing)[source]¶
sets internal timeseries values to passed values
- type = 'Entity'¶
manpy.simulation.core.CoreObject.py¶
- class manpy.simulation.core.CoreObject.CoreObject(id, name, cost=0, **kw)[source]¶
Bases:
ManPyObjectCreated on 12 Jul 2012
@author: George Class that acts as an abstract. It should have no instances. All the core-objects should inherit from it
- Parameters:
id – Internal Id
name – Name of the CoreObject
- activeQueueIsEmpty()[source]¶
filter that returns True if the activeObject Queue is empty false if object holds entities in its queue
- appendEntity(entity=None)[source]¶
appends entity to the receiver object. to be called by the removeEntity of the giver this method is created to be overridden by the Assembly class in its getEntity where Frames are loaded
- calculateTime(type='Processing')[source]¶
calculates time (running through a dictionary) according to the type of processing given as argument
- canAcceptAndIsRequested(callerObject=None)[source]¶
checks if the Object can accept an entity and there is an entity in some possible giver waiting for it
- class_name = 'manpy.CoreObject'¶
- defineNext(successorList=[])[source]¶
sets the next element for the object and automatically registers itself as previous object of all objects in successorList. :param successorList: :return: None
- defineRouting(predecessorList=[], successorList=[])[source]¶
sets the routing in and out elements for the Object
- Parameters:
predecessorList – List containing the predecessor Objects
successorList – List containing the successor Objects
- Returns:
None
- getRoutingTarget()[source]¶
Returns the object. This method is used for dynamic routing in order to handle CoreObjects and ProductionLineModules differently
- haveToDispose(callerObject=None)[source]¶
checks if the Object can dispose an entity to the following object
- identifyEntityToGet()[source]¶
called be getEntity it identifies the Entity to be obtained so that getEntity gives it to removeEntity as argument
- initialSignalReceiver()[source]¶
checks if there is anything set as WIP at the begging of the simulation and sends an event to initialize the simulation
- interruptionActions()[source]¶
actions to be carried whenever the object is interrupted (failure, break, preemption, etc)
- isInRouteOf(callerObject=None)[source]¶
method used to check whether the station is a successor of the caller
- postInterruptionActions()[source]¶
actions to be carried whenever the object recovers control after an interruption (failure, break, preemption, etc)
- preemptReceiver()[source]¶
check whether there is a critical entity to be disposed and if preemption is required
- removeEntity(entity=None, resetFlags=True, addBlockage=True)[source]¶
removes an Entity from the Object the Entity to be removed is passed as argument by getEntity of the receiver
- Parameters:
entity
resetFlags
addBlockage
- Returns:
- run()[source]¶
the main process of the core object, this is dummy, every object must have its own implementation
- Returns:
None
manpy.simulation.core.ObjectInterruption.py¶
Created on 18 Aug 2013
@author: George
- class manpy.simulation.core.ObjectInterruption.ObjectInterruption(id='', name='', victim=None, remove=False, cost=0, **kw)[source]¶
Bases:
ManPyObjectClass that acts as an abstract. It should have no instances. All object interruptions (eg failures, breaks) should inherit from it
- printTrace(entityName, message)[source]¶
print message in the console. Format is (Simulation Time | Entity or Frame Name | message)
manpy.simulation.core.ObjectProperty.py¶
Created on 18 Aug 2013
@author: LodesL
- class manpy.simulation.core.ObjectProperty.ObjectProperty(id='', name='', victim=None, distribution={}, distribution_state_controller=None, reset_distributions=True, no_negative=False, contribute=None, start_time=0, end_time=0, start_value=None, random_walk=False, dependent=None, **kw)[source]¶
Bases:
ManPyObjectAbstract class for all kinds of object properties that are generated in somehow regular interval. Example: Features
- outputTrace(entity_name: str, entity_id: str, message: str)[source]¶
Overwrites the ouputTrace function to better suite Features
- Parameters:
entity_name – The Name of the target Machine
entity_id – The ID of the target Machine
message – The value of the Feature
- Returns:
None
- printTrace(entityName, message)[source]¶
print message in the console. Format is (Simulation Time | Entity or Frame Name | message)
manpy.simulation.core.ObjectResource.py¶
Created on 18 Aug 2013
@author: George
manpy.simulation.core.utils.py¶
- manpy.simulation.core.utils.check_config_dict(config_dict: dict, keys: list, object_name: str)[source]¶
Function to check if config dictionaries contain a mistake. I.e., it checks if certain keys are contained in the dict and warns the user if some are missing. Is used to prevent accidental misconfigurations.
- Parameters:
config_dict – The config dict to be checked
keys – A list with the keys in config_dict that should be checked
object_name – The name of the object in which the check is done. Is used for the print statement