Commit eabdc79d authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

lineGenerationCMSD.py was added. This is a main script that reads from the...

lineGenerationCMSD.py was added. This is a main script that reads from the CMSD like xml files made by panos. Tested in topologies 01, 03,04 and 06. To test in more Topologies we have to find how CMSD models parallel stations
parent 071661ca
<CMSDDocument xmlns="urn:cmsd:main"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:cmsd:main main.xsd">
<!--<CMSDDocument>-->
<DataSection>
<ResourceClass>
<Identifier>Source</Identifier>
<Description>This element describes a class of entrance</Description>
<ResourceType>other</ResourceType>
<Name>RawMaterial</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Machine</Identifier>
<Description>This element describes a class of machines</Description>
<ResourceType>machine</ResourceType>
<Name>Machine</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Queue</Identifier>
<Description>This element describes a class of queues</Description>
<ResourceType>other</ResourceType>
<Name>Queue</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Repairman</Identifier>
<Description>This element describes a class of employees</Description>
<ResourceType>employee</ResourceType>
<Name>W1</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Exit</Identifier>
<Description>This element describes a class of exit</Description>
<ResourceType>other</ResourceType>
<Name>Stock</Name>
</ResourceClass>
<PartType>
<Identifier>Part</Identifier>
</PartType>
<PartType>
<Identifier>UnfinishedPart1</Identifier>
</PartType>
************************************************Resource S1*****************************************
<Resource>
<Identifier>S1</Identifier>
<Description>The source of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Source</ResourceClassIdentifier>
</ResourceClass>
<Name>RawMaterial</Name>
<Property>
<Name>interarrivalTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>partType</Name>
<Value>Part</Value>
</Property>
</Resource>
********************************Resource M1******************************************************
<Resource>
<Identifier>M1</Identifier>
<Description>The lathe of the topology</Description>
<ResourceType>machine</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Machine</ResourceClassIdentifier>
</ResourceClass>
<Name>Machine1</Name>
<Property>
<Name>ProcessTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.25</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>60</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>5</Value>
</DistributionParameter>
</Distribution>
<Property>
<Name>RepairmanRequired</Name>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Resource>
************************************Resource Q1***********************************************
<Resource>
<Identifier>Q1</Identifier>
<Description>The queue of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Queue</ResourceClassIdentifier>
</ResourceClass>
<Name>Q1</Name>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Resource>
**********************************Resource M2***************************************************
<Resource>
<Identifier>M2</Identifier>
<Description>The moulding machine of the topology</Description>
<ResourceType>machine</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Machine</ResourceClassIdentifier>
</ResourceClass>
<Name>Machine2</Name>
<Property>
<Name>ProcessTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>1.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>40</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>10</Value>
</DistributionParameter>
</Distribution>
<Property>
<ResourcesRequired>
<Name>RepairmanRequired</Name>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Resource>
****************************************Resource Exit ****************************************
<Resource>
<Identifier>E1</Identifier>
<Description>The exit of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Exit</ResourceClassIdentifier>
</ResourceClass>
<Name>Stock</Name>
</Resource>
****************************************Resource Repairman**************************************
<Resource>
<Identifier>W1</Identifier>
<ResourceType>employee</ResourceType>
<Name>Bob</Name>
<ResourceClass>
<ResourceClassIdentifier>Repairman</ResourceClassIdentifier>
</ResourceClass>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Resource>
********************************Process Plan*****************************************************
<ProcessPlan>
<Identifier>ProcessPlan:Part1</Identifier>
<PartsProduced>
<Description>The part produced the process</Description>
<PartType>
<PartTypeIdentifier>Part1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part(s) consumed the process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<FirstProcess>
<ProcessIdentifier>MainProcessSequence</ProcessIdentifier>
</FirstProcess>
<Process>
<Identifier>MainProcessSequence</Identifier>
<RepetitionCount>1</RepetitionCount>
<SubProcessGroup>
<Type>sequence</Type>
<Process>
<ProcessIdentifier>A010</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A020</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A030</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A040</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A050</ProcessIdentifier>
</Process>
</SubProcessGroup>
</Process>
***********************************************Process************************************************
<Process>
<Identifier>A010</Identifier>
<Description>Process 1</Description>
<PartsProduced>
<Description>The part produced the process. Production resources have
transformed the part in some way, but it is not yet finished. If it is not
important to track unfinished part forms between processes, the
PartsProduced and PartsProduced information can be left out.</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part that is an input to this process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<ResourcesRequired>
<Description>Source.</Description>
<Resource>
<ResourceIdentifier>S1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A020</Identifier>
<Description>Process 2</Description>
<ResourcesRequired>
<Description>Machine1.</Description>
<Resource>
<ResourceIdentifier>M1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A030</Identifier>
<Description>Process 3</Description>
<ResourcesRequired>
<Description>Queue1.</Description>
<Resource>
<ResourceIdentifier>Q1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A040</Identifier>
<Description>Process 4</Description>
<ResourcesRequired>
<Description>Machine2.</Description>
<Resource>
<ResourceIdentifier>M2</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A050</Identifier>
<Description>Process 5</Description>
<ResourcesRequired>
<Description>Exit.</Description>
<Resource>
<ResourceIdentifier>E1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
</ProcessPlan>
</DataSection>
</CMSDDocument>
\ No newline at end of file
<CMSDDocument xmlns="urn:cmsd:main"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:cmsd:main main.xsd">
<!--<CMSDDocument>-->
<DataSection>
<ResourceClass>
<Identifier>Source</Identifier>
<Description>This element describes a class of entrance</Description>
<ResourceType>other</ResourceType>
<Name>RawMaterial</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Machine</Identifier>
<Description>This element describes a class of machines</Description>
<ResourceType>machine</ResourceType>
<Name>Machine</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Queue</Identifier>
<Description>This element describes a class of queues</Description>
<ResourceType>other</ResourceType>
<Name>Queue</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Repairman</Identifier>
<Description>This element describes a class of employees</Description>
<ResourceType>employee</ResourceType>
<Name>W1</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Exit</Identifier>
<Description>This element describes a class of exit</Description>
<ResourceType>other</ResourceType>
<Name>Stock</Name>
</ResourceClass>
<PartType>
<Identifier>Part</Identifier>
</PartType>
<PartType>
<Identifier>UnfinishedPart1</Identifier>
</PartType>
************************************************Resource S1*****************************************
<Resource>
<Identifier>S1</Identifier>
<Description>The source of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Source</ResourceClassIdentifier>
</ResourceClass>
<Name>RawMaterial</Name>
<Property>
<Name>interarrivalTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>partType</Name>
<Value>Part</Value>
</Property>
</Resource>
********************************Resource M1******************************************************
<Resource>
<Identifier>M1</Identifier>
<Description>The lathe of the topology</Description>
<ResourceType>machine</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Machine</ResourceClassIdentifier>
</ResourceClass>
<Name>Machine1</Name>
<Property>
<Name>ProcessTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.25</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>60</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>5</Value>
</DistributionParameter>
</Distribution>
<Property>
<Name>RepairmanRequired</Name>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Resource>
************************************Resource Q1***********************************************
<Resource>
<Identifier>Q1</Identifier>
<Description>The queue of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Queue</ResourceClassIdentifier>
</ResourceClass>
<Name>Q1</Name>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Resource>
**********************************Resource M2***************************************************
<Resource>
<Identifier>M2</Identifier>
<Description>The moulding machine of the topology</Description>
<ResourceType>machine</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Machine</ResourceClassIdentifier>
</ResourceClass>
<Name>Machine2</Name>
<Property>
<Name>ProcessTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>1.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>40</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>10</Value>
</DistributionParameter>
</Distribution>
<Property>
<ResourcesRequired>
<Name>RepairmanRequired</Name>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Resource>
****************************************Resource Exit ****************************************
<Resource>
<Identifier>E1</Identifier>
<Description>The exit of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Exit</ResourceClassIdentifier>
</ResourceClass>
<Name>Stock</Name>
</Resource>
****************************************Resource Repairman**************************************
<Resource>
<Identifier>W1</Identifier>
<ResourceType>employee</ResourceType>
<Name>Bob</Name>
<ResourceClass>
<ResourceClassIdentifier>Repairman</ResourceClassIdentifier>
</ResourceClass>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Resource>
********************************Process Plan*****************************************************
<ProcessPlan>
<Identifier>ProcessPlan:Part1</Identifier>
<PartsProduced>
<Description>The part produced the process</Description>
<PartType>
<PartTypeIdentifier>Part1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part(s) consumed the process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<FirstProcess>
<ProcessIdentifier>MainProcessSequence</ProcessIdentifier>
</FirstProcess>
<Process>
<Identifier>MainProcessSequence</Identifier>
<RepetitionCount>1</RepetitionCount>
<SubProcessGroup>
<Type>sequence</Type>
<Process>
<ProcessIdentifier>A010</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A020</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A040</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A050</ProcessIdentifier>
</Process>
</SubProcessGroup>
</Process>
***********************************************Process************************************************
<Process>
<Identifier>A010</Identifier>
<Description>Process 1</Description>
<PartsProduced>
<Description>The part produced the process. Production resources have
transformed the part in some way, but it is not yet finished. If it is not
important to track unfinished part forms between processes, the
PartsProduced and PartsProduced information can be left out.</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part that is an input to this process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<ResourcesRequired>
<Description>Source.</Description>
<Resource>
<ResourceIdentifier>S1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A020</Identifier>
<Description>Process 2</Description>
<ResourcesRequired>
<Description>Machine1.</Description>
<Resource>
<ResourceIdentifier>M1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A030</Identifier>
<Description>Process 3</Description>
<ResourcesRequired>
<Description>Queue1.</Description>
<Resource>
<ResourceIdentifier>Q1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A040</Identifier>
<Description>Process 4</Description>
<ResourcesRequired>
<Description>Machine2.</Description>
<Resource>
<ResourceIdentifier>M2</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A050</Identifier>
<Description>Process 5</Description>
<ResourcesRequired>
<Description>Exit.</Description>
<Resource>
<ResourceIdentifier>E1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
</ProcessPlan>
</DataSection>
</CMSDDocument>
\ No newline at end of file
<CMSDDocument xmlns="urn:cmsd:main"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:cmsd:main main.xsd">
<!--<CMSDDocument>-->
<DataSection>
<ResourceClass>
<Identifier>Source</Identifier>
<Description>This element describes a class of entrance</Description>
<ResourceType>other</ResourceType>
<Name>RawMaterial</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Machine</Identifier>
<Description>This element describes a class of machines</Description>
<ResourceType>machine</ResourceType>
<Name>Machine</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Queue</Identifier>
<Description>This element describes a class of queues</Description>
<ResourceType>other</ResourceType>
<Name>Queue</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Repairman</Identifier>
<Description>This element describes a class of employees</Description>
<ResourceType>employee</ResourceType>
<Name>W1</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Exit</Identifier>
<Description>This element describes a class of exit</Description>
<ResourceType>other</ResourceType>
<Name>Stock</Name>
</ResourceClass>
<PartType>
<Identifier>Part</Identifier>
</PartType>
<PartType>
<Identifier>UnfinishedPart1</Identifier>
</PartType>
************************************************Resource S1*****************************************
<Resource>
<Identifier>S1</Identifier>
<Description>The source of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Source</ResourceClassIdentifier>
</ResourceClass>
<Name>RawMaterial</Name>
<Property>
<Name>interarrivalTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>partType</Name>
<Value>Part</Value>
</Property>
</Resource>
********************************Resource M1******************************************************
<Resource>
<Identifier>M1</Identifier>
<Description>The lathe of the topology</Description>
<ResourceType>machine</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Machine</ResourceClassIdentifier>
</ResourceClass>
<Name>Machine1</Name>
<Property>
<Name>ProcessTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.25</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>60</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>5</Value>
</DistributionParameter>
</Distribution>
<Property>
<Name>RepairmanRequired</Name>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Resource>
************************************Resource Q1***********************************************
<Resource>
<Identifier>Q1</Identifier>
<Description>The queue of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Queue</ResourceClassIdentifier>
</ResourceClass>
<Name>Q1</Name>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Resource>
**********************************Resource M2***************************************************
<Resource>
<Identifier>M2</Identifier>
<Description>The moulding machine of the topology</Description>
<ResourceType>machine</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Machine</ResourceClassIdentifier>
</ResourceClass>
<Name>Machine2</Name>
<Property>
<Name>ProcessTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>1.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>40</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>10</Value>
</DistributionParameter>
</Distribution>
<Property>
<ResourcesRequired>
<Name>RepairmanRequired</Name>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Resource>
****************************************Resource Exit ****************************************
<Resource>
<Identifier>E1</Identifier>
<Description>The exit of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Exit</ResourceClassIdentifier>
</ResourceClass>
<Name>Stock</Name>
</Resource>
****************************************Resource Repairman**************************************
<Resource>
<Identifier>W1</Identifier>
<ResourceType>employee</ResourceType>
<Name>Bob</Name>
<ResourceClass>
<ResourceClassIdentifier>Repairman</ResourceClassIdentifier>
</ResourceClass>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Resource>
********************************Process Plan*****************************************************
<ProcessPlan>
<Identifier>ProcessPlan:Part1</Identifier>
<PartsProduced>
<Description>The part produced the process</Description>
<PartType>
<PartTypeIdentifier>Part1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part(s) consumed the process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<FirstProcess>
<ProcessIdentifier>MainProcessSequence</ProcessIdentifier>
</FirstProcess>
<Process>
<Identifier>MainProcessSequence</Identifier>
<RepetitionCount>1</RepetitionCount>
<SubProcessGroup>
<Type>sequence</Type>
<Process>
<ProcessIdentifier>A010</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A040</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A030</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A020</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A050</ProcessIdentifier>
</Process>
</SubProcessGroup>
</Process>
***********************************************Process************************************************
<Process>
<Identifier>A010</Identifier>
<Description>Process 1</Description>
<PartsProduced>
<Description>The part produced the process. Production resources have
transformed the part in some way, but it is not yet finished. If it is not
important to track unfinished part forms between processes, the
PartsProduced and PartsProduced information can be left out.</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part that is an input to this process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<ResourcesRequired>
<Description>Source.</Description>
<Resource>
<ResourceIdentifier>S1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A020</Identifier>
<Description>Process 2</Description>
<ResourcesRequired>
<Description>Machine1.</Description>
<Resource>
<ResourceIdentifier>M1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A030</Identifier>
<Description>Process 3</Description>
<ResourcesRequired>
<Description>Queue1.</Description>
<Resource>
<ResourceIdentifier>Q1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A040</Identifier>
<Description>Process 4</Description>
<ResourcesRequired>
<Description>Machine2.</Description>
<Resource>
<ResourceIdentifier>M2</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A050</Identifier>
<Description>Process 5</Description>
<ResourcesRequired>
<Description>Exit.</Description>
<Resource>
<ResourceIdentifier>E1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
</ProcessPlan>
</DataSection>
</CMSDDocument>
\ No newline at end of file
<CMSDDocument xmlns="urn:cmsd:main"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:cmsd:main main.xsd">
<!--<CMSDDocument>-->
<DataSection>
<ResourceClass>
<Identifier>Source</Identifier>
<Description>This element describes a class of entrance</Description>
<ResourceType>other</ResourceType>
<Name>RawMaterial</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Machine</Identifier>
<Description>This element describes a class of machines</Description>
<ResourceType>machine</ResourceType>
<Name>Machine</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Queue</Identifier>
<Description>This element describes a class of queues</Description>
<ResourceType>other</ResourceType>
<Name>Queue</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Repairman</Identifier>
<Description>This element describes a class of employees</Description>
<ResourceType>employee</ResourceType>
<Name>W1</Name>
</ResourceClass>
<ResourceClass>
<Identifier>Exit</Identifier>
<Description>This element describes a class of exit</Description>
<ResourceType>other</ResourceType>
<Name>Stock</Name>
</ResourceClass>
<PartType>
<Identifier>Part</Identifier>
</PartType>
<PartType>
<Identifier>UnfinishedPart1</Identifier>
</PartType>
************************************************Resource S1*****************************************
<Resource>
<Identifier>S1</Identifier>
<Description>The source of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Source</ResourceClassIdentifier>
</ResourceClass>
<Name>RawMaterial</Name>
<Property>
<Name>interarrivalTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>partType</Name>
<Value>Part</Value>
</Property>
</Resource>
********************************Resource M1******************************************************
<Resource>
<Identifier>M1</Identifier>
<Description>The lathe of the topology</Description>
<ResourceType>machine</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Machine</ResourceClassIdentifier>
</ResourceClass>
<Name>Machine1</Name>
<Property>
<Name>ProcessTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.25</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>60</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>5</Value>
</DistributionParameter>
</Distribution>
<Property>
<Name>RepairmanRequired</Name>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Resource>
************************************Resource Q1***********************************************
<Resource>
<Identifier>Q1</Identifier>
<Description>The queue of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Queue</ResourceClassIdentifier>
</ResourceClass>
<Name>Q1</Name>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Resource>
**********************************Resource M2***************************************************
<Resource>
<Identifier>M2</Identifier>
<Description>The moulding machine of the topology</Description>
<ResourceType>machine</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Machine</ResourceClassIdentifier>
</ResourceClass>
<Name>Machine2</Name>
<Property>
<Name>ProcessTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>1.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>40</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>10</Value>
</DistributionParameter>
</Distribution>
<Property>
<ResourcesRequired>
<Name>RepairmanRequired</Name>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Resource>
**********************************Resource M3***************************************************
<Resource>
<Identifier>M3</Identifier>
<Description>The moulding machine of the topology</Description>
<ResourceType>machine</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Machine</ResourceClassIdentifier>
</ResourceClass>
<Name>Machine3</Name>
<Property>
<Name>ProcessTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>3</Value>
</DistributionParameter>
</Distribution>
</Property>
</Resource>
****************************************Resource Exit ****************************************
<Resource>
<Identifier>E1</Identifier>
<Description>The exit of the topology</Description>
<ResourceType>other</ResourceType>
<ResourceClass>
<ResourceClassIdentifier>Exit</ResourceClassIdentifier>
</ResourceClass>
<Name>Stock</Name>
</Resource>
****************************************Resource Repairman**************************************
<Resource>
<Identifier>W1</Identifier>
<ResourceType>employee</ResourceType>
<Name>Bob</Name>
<ResourceClass>
<ResourceClassIdentifier>Repairman</ResourceClassIdentifier>
</ResourceClass>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Resource>
********************************Process Plan*****************************************************
<ProcessPlan>
<Identifier>ProcessPlan:Part1</Identifier>
<PartsProduced>
<Description>The part produced the process</Description>
<PartType>
<PartTypeIdentifier>Part1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part(s) consumed the process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<FirstProcess>
<ProcessIdentifier>MainProcessSequence</ProcessIdentifier>
</FirstProcess>
<Process>
<Identifier>MainProcessSequence</Identifier>
<RepetitionCount>1</RepetitionCount>
<SubProcessGroup>
<Type>sequence</Type>
<Process>
<ProcessIdentifier>A010</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A020</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A030</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A040</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A050</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A060</ProcessIdentifier>
</Process>
</SubProcessGroup>
</Process>
***********************************************Process************************************************
<Process>
<Identifier>A010</Identifier>
<Description>Process 1</Description>
<PartsProduced>
<Description>The part produced the process. Production resources have
transformed the part in some way, but it is not yet finished. If it is not
important to track unfinished part forms between processes, the
PartsProduced and PartsProduced information can be left out.</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part that is an input to this process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<ResourcesRequired>
<Description>Source.</Description>
<Resource>
<ResourceIdentifier>S1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A020</Identifier>
<Description>Process 2</Description>
<ResourcesRequired>
<Description>Machine1.</Description>
<Resource>
<ResourceIdentifier>M1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A030</Identifier>
<Description>Process 3</Description>
<ResourcesRequired>
<Description>Queue1.</Description>
<Resource>
<ResourceIdentifier>Q1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A040</Identifier>
<Description>Process 4</Description>
<ResourcesRequired>
<Description>Machine2.</Description>
<Resource>
<ResourceIdentifier>M2</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A060</Identifier>
<Description>Process 6</Description>
<ResourcesRequired>
<Description>Exit.</Description>
<Resource>
<ResourceIdentifier>E1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
<Process>
<Identifier>A050</Identifier>
<Description>Process 5</Description>
<ResourcesRequired>
<Description>Machine3.</Description>
<Resource>
<ResourceIdentifier>M3</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
</ProcessPlan>
</DataSection>
</CMSDDocument>
\ No newline at end of file
...@@ -7,7 +7,6 @@ Created on 23 May 2013 ...@@ -7,7 +7,6 @@ Created on 23 May 2013
Models a conveyer object Models a conveyer object
it gathers entities and transfers them with a certain speed it gathers entities and transfers them with a certain speed
''' '''
from SimPy.Simulation import * from SimPy.Simulation import *
import xlwt import xlwt
import scipy.stats as stat import scipy.stats as stat
...@@ -63,6 +62,9 @@ class Conveyer(Process): ...@@ -63,6 +62,9 @@ class Conveyer(Process):
self.timeLastMoveHappened=0 #holds the last time that the move was performed (in reality it is self.timeLastMoveHappened=0 #holds the last time that the move was performed (in reality it is
#continues, in simulation we have to handle it as discrete) #continues, in simulation we have to handle it as discrete)
self.justDisposed=False self.justDisposed=False
self.timeToReachEnd=-1
self.justReachedEnd=False
def run(self): def run(self):
#these are just for the first Entity #these are just for the first Entity
...@@ -70,15 +72,19 @@ class Conveyer(Process): ...@@ -70,15 +72,19 @@ class Conveyer(Process):
self.getEntity() #get the entity self.getEntity() #get the entity
self.timeLastMoveHappened=now() self.timeLastMoveHappened=now()
while 1: while 1:
if(len(self.position)>0 and (not self.length==self.position[0])):
self.timeToReachEnd=now()*60.0+self.speed/(self.length-self.position[0])
print now(), "timeToReachEnd=",self.timeToReachEnd/60.0
activate(self,self.reachedEnd())
yield waituntil, self, self.somethingHappened #wait for an important event in order to move the items yield waituntil, self, self.somethingHappened #wait for an important event in order to move the items
#print now()
self.moveEntities() self.moveEntities()
if self.canAcceptAndIsRequested(): if self.canAcceptAndIsRequested():
print now(), ":canAcceptAndIsRequested"
self.getEntity() self.getEntity()
if self.waitToDispose: if self.waitToDispose:
#yield waituntil, self, self.entityJustDisposed print now(), ":waitToDispose"
#self.justDisposed=False continue
pass
''' '''
now we have to wait until something happens. The things that are important are (may be not a full list) now we have to wait until something happens. The things that are important are (may be not a full list)
one item reaches the end one item reaches the end
...@@ -188,8 +194,20 @@ class Conveyer(Process): ...@@ -188,8 +194,20 @@ class Conveyer(Process):
return False return False
''' '''
def reachedEnd(self):
print "-"*50
yield waituntil, self, self.somethingHappened #wait for an important event in order to move the items
def somethingHappened(self): def somethingHappened(self):
return self.canAcceptAndIsRequested() or self.entityJustReachedEnd() print now()
if(len(self.position)>0):
if(self.timeToReachEnd==now() and (not self.position[0]==self.length)):
self.waitToDispose==True
return True
else:
return self.canAcceptAndIsRequested()
else:
return self.canAcceptAndIsRequested()
#checks if the Conveyer is requested by the predecessor #checks if the Conveyer is requested by the predecessor
def isRequested(self): def isRequested(self):
......
...@@ -139,7 +139,7 @@ class Exit(Process): ...@@ -139,7 +139,7 @@ class Exit(Process):
except ZeroDivisionError: except ZeroDivisionError:
G.outputSheet.write(G.outputIndex,1,0) G.outputSheet.write(G.outputIndex,1,0)
G.outputIndex+=1 G.outputIndex+=1
G.outputSheet.write(G.outputIndex,0, "The average tatk time in "+ self.objName +" is:") G.outputSheet.write(G.outputIndex,0, "The average takt time in "+ self.objName +" is:")
try: try:
G.outputSheet.write(G.outputIndex,1,((self.totalTaktTime)/self.numOfExits)/G.Base) G.outputSheet.write(G.outputIndex,1,((self.totalTaktTime)/self.numOfExits)/G.Base)
except ZeroDivisionError: except ZeroDivisionError:
......
...@@ -55,15 +55,12 @@ class Failure(Process): ...@@ -55,15 +55,12 @@ class Failure(Process):
def run(self): def run(self):
while 1: while 1:
#yield hold,self,self.calcTimeToFailure()
yield hold,self,self.rngTTF.generateNumber() #wait until a failure happens yield hold,self,self.rngTTF.generateNumber() #wait until a failure happens
try: try:
#print self.name
if(len(self.victim.Res.activeQ)>0): if(len(self.victim.Res.activeQ)>0):
self.interrupt(self.victim) #when a Machine gets failure while in process it is interrupted self.interrupt(self.victim) #when a Machine gets failure while in process it is interrupted
self.victim.Up=False self.victim.Up=False
self.victim.timeLastFailure=now() self.victim.timeLastFailure=now()
#print str(now())+":M"+str(self.victim.id)+" is down"
self.outputTrace("is down") self.outputTrace("is down")
except AttributeError: except AttributeError:
...@@ -77,8 +74,6 @@ class Failure(Process): ...@@ -77,8 +74,6 @@ class Failure(Process):
timeRepairStarted=now() timeRepairStarted=now()
self.repairman.timeLastRepairStarted=now() self.repairman.timeLastRepairStarted=now()
#yield hold,self,self.calcTimeToRepair() #wait until the repairing process is over
yield hold,self,self.rngTTR.generateNumber() #wait until the repairing process is over yield hold,self,self.rngTTR.generateNumber() #wait until the repairing process is over
self.victim.totalFailureTime+=now()-failTime self.victim.totalFailureTime+=now()-failTime
...@@ -86,38 +81,13 @@ class Failure(Process): ...@@ -86,38 +81,13 @@ class Failure(Process):
if(len(self.victim.Res.activeQ)>0): if(len(self.victim.Res.activeQ)>0):
reactivate(self.victim) #since repairing is over, the Machine is reactivated reactivate(self.victim) #since repairing is over, the Machine is reactivated
self.victim.Up=True self.victim.Up=True
#print str(now())+":M"+str(self.victim.id)+" is up"
self.outputTrace("is up") self.outputTrace("is up")
if(self.repairman!="None"): #if a resource was used, it is now released if(self.repairman!="None"): #if a resource was used, it is now released
yield release,self,self.repairman.Res yield release,self,self.repairman.Res
self.repairman.totalWorkingTime+=now()-timeRepairStarted self.repairman.totalWorkingTime+=now()-timeRepairStarted
#print "reactivating "+str(self.victim.currentEntity)
except AttributeError: except AttributeError:
print "AttributeError2" print "AttributeError2"
'''
#calculates the time until the next failure
def calcTimeToFailure(self):
from Globals import G
if self.distType=="Fixed": #in a fixed distribution every TTF should be equal to MTTF
TTF=self.MTTF
elif self.distType=="Availability": #if we have availability defined, TTF should follow the exponential distribution
TTF=G.Rnd.expovariate(float(1)/self.AvailabilityMTTF)
#print self.name+" TTF="+str(TTF)
return TTF
#calculates the time that it is needed for the repair
def calcTimeToRepair(self):
from Globals import G
if self.distType=="Fixed": #in a fixed distribution every TTR should be equal to MTTR
TTR=self.MTTR
elif self.distType=="Availability": #if we have availability defined, TTR should follow the Erlang distribution
TTR=G.Rnd.gammavariate(self.alpha,self.beta)
#print self.name+" TTR="+str(TTR)
return TTR
'''
#outputs message to the trace.xls. Format is (Simulation Time | Machine Name | message) #outputs message to the trace.xls. Format is (Simulation Time | Machine Name | message)
def outputTrace(self, message): def outputTrace(self, message):
from Globals import G from Globals import G
...@@ -134,7 +104,6 @@ class Failure(Process): ...@@ -134,7 +104,6 @@ class Failure(Process):
G.sheetIndex+=1 G.sheetIndex+=1
G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True) G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True)
#outputs data to "output.xls" #outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime): def outputResultsXL(self, MaxSimtime):
pass pass
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"general": { "general": {
"_class": "Dream.Configuration", "_class": "Dream.Configuration",
"numberOfReplications": "1", "numberOfReplications": "1",
"maxSimTime": "60", "maxSimTime": "5",
"trace": "Yes", "trace": "Yes",
"confidenceLevel": "0.95" "confidenceLevel": "0.95"
}, },
......
'''
Created on 27 May 2013
@author: George
'''
'''
main script. Reads data from the CMSD xml files that Panos creates,
generates and runs the simulation and prints the results to excel
'''
from SimPy.Simulation import *
from Source import Source
from Globals import G
from Machine import Machine
from Exit import Exit
from Queue import Queue
from QueueLIFO import QueueLIFO
from Repairman import Repairman
from Part import Part
from Frame import Frame
from Assembly import Assembly
from Dismantle import Dismantle
from Conveyer import Conveyer
import xlwt
import xlrd
import time
import numpy as np
import json
from random import Random
import sys
from xml.dom.minidom import parseString
from xml.dom.minidom import parse
#reads general simulation inputs
#CMSD does not have to do with such inputs (and it should not as they do not have to do with the system but with the simulation experiment)
#so these are hard coded for now
def readGeneralInput():
G.numberOfReplications=1
G.maxSimTime=1440
G.trace="Yes"
G.confidenceLevel=0.95
#Reads the resources of the CMSD file and creates the objects
def readResources():
G.SourceList=[]
G.MachineList=[]
G.ExitList=[]
G.QueueList=[]
G.RepairmanList=[]
G.AssemblyList=[]
G.DismantleList=[]
G.ConveyerList=[]
resource=(G.CMSDData.getElementsByTagName('Resource'))
#this loop will search in all the objects for repairmen and create them.
#repairmen have to be created first since they may be used in the creation of the other objects
for i in range(len(resource)):
#get the class
try:
resourceClass=resource[i].getElementsByTagName('ResourceClassIdentifier')
resourceClass=resourceClass[0].toxml().replace('<ResourceClassIdentifier>','').replace('</ResourceClassIdentifier>','')
except IndexError:
continue
if resourceClass=='Repairman':
id=resource[i].getElementsByTagName('Identifier')
id=id[0].toxml().replace('<Identifier>','').replace('</Identifier>','')
name=resource[i].getElementsByTagName('Name')
name=name[0].toxml().replace('<Name>','').replace('</Name>','')
property=resource[i].getElementsByTagName('Property')
for j in range(len(property)):
propertyName=property[j].getElementsByTagName('Name')
propertyName=propertyName[0].toxml().replace('<Name>','').replace('</Name>','')
if propertyName=='capacity':
capacity=property[j].getElementsByTagName('Value')
capacity=int(capacity[0].toxml().replace('<Value>','').replace('</Value>',''))
R=Repairman(id, name, capacity)
G.RepairmanList.append(R)
for i in range(len(resource)):
#get the class
try:
resourceClass=resource[i].getElementsByTagName('ResourceClassIdentifier')
resourceClass=resourceClass[0].toxml().replace('<ResourceClassIdentifier>','').replace('</ResourceClassIdentifier>','')
except IndexError:
continue
if resourceClass=='Source':
id=resource[i].getElementsByTagName('Identifier')
id=id[0].toxml().replace('<Identifier>','').replace('</Identifier>','')
name=resource[i].getElementsByTagName('Name')
name=name[0].toxml().replace('<Name>','').replace('</Name>','')
property=resource[i].getElementsByTagName('Property')
for j in range(len(property)):
propertyName=property[j].getElementsByTagName('Name')
propertyName=propertyName[0].toxml().replace('<Name>','').replace('</Name>','')
if propertyName=='partType':
partType=property[j].getElementsByTagName('Value')
partType=(partType[0].toxml().replace('<Value>','').replace('</Value>',''))
entity=str_to_class(partType)
elif propertyName=='interarrivalTime':
unit=property[j].getElementsByTagName('Unit')
unit=unit[0].toxml().replace('<Unit>','').replace('</Unit>','')
distribution=property[j].getElementsByTagName('Distribution')
distributionType=distribution[0].getElementsByTagName('Name')
distributionType=distributionType[0].toxml().replace('<Name>','').replace('</Name>','')
distributionParameter=distribution[0].getElementsByTagName('DistributionParameter')
distributionParameterName=distributionParameter[0].getElementsByTagName('Name')
distributionParameterName=distributionParameterName[0].toxml().replace('<Name>','').replace('</Name>','')
mean=distributionParameter[0].getElementsByTagName('Value')
mean=float(mean[0].toxml().replace('<Value>','').replace('</Value>',''))
S=Source(id, name, distributionType, mean, entity)
G.SourceList.append(S)
G.ObjList.append(S)
elif resourceClass=='Machine':
id=resource[i].getElementsByTagName('Identifier')
id=id[0].toxml().replace('<Identifier>','').replace('</Identifier>','')
name=resource[i].getElementsByTagName('Name')
name=name[0].toxml().replace('<Name>','').replace('</Name>','')
property=resource[i].getElementsByTagName('Property')
for j in range(len(property)):
propertyName=property[j].getElementsByTagName('Name')
propertyName=propertyName[0].toxml().replace('<Name>','').replace('</Name>','')
if propertyName=='ProcessTime':
unit=property[j].getElementsByTagName('Unit')
unit=unit[0].toxml().replace('<Unit>','').replace('</Unit>','')
distribution=property[j].getElementsByTagName('Distribution')
distributionType=distribution[0].getElementsByTagName('Name')
distributionType=distributionType[0].toxml().replace('<Name>','').replace('</Name>','')
distributionParameter=distribution[0].getElementsByTagName('DistributionParameter')
mean=0
stdev=0
min=0
max=0
availability=0
failureDistribution=None
for k in range(len(distributionParameter)):
distributionParameterName=distributionParameter[0].getElementsByTagName('Name')
distributionParameterName=distributionParameterName[0].toxml().replace('<Name>','').replace('</Name>','')
if distributionParameterName=='mean':
mean=distributionParameter[0].getElementsByTagName('Value')
mean=float(mean[0].toxml().replace('<Value>','').replace('</Value>',''))
elif distributionParameterName=='stdev':
stdev=distributionParameter[0].getElementsByTagName('Value')
stdev=float(stdev[0].toxml().replace('<Value>','').replace('</Value>',''))
elif distributionParameterName=='min':
min=distributionParameter[0].getElementsByTagName('Value')
min=float(mean[0].toxml().replace('<Value>','').replace('</Value>',''))
elif distributionParameterName=='max':
max=distributionParameter[0].getElementsByTagName('Value')
max=float(mean[0].toxml().replace('<Value>','').replace('</Value>',''))
elif propertyName=='MeanTimeToFailure':
unit=property[j].getElementsByTagName('Unit')
unit=unit[0].toxml().replace('<Unit>','').replace('</Unit>','')
distribution=property[j].getElementsByTagName('Distribution')
failureDistribution=distribution[0].getElementsByTagName('Name')
failureDistribution=failureDistribution[0].toxml().replace('<Name>','').replace('</Name>','')
distributionParameter=distribution[0].getElementsByTagName('DistributionParameter')
for k in range(len(distributionParameter)):
distributionParameterName=distributionParameter[0].getElementsByTagName('Name')
distributionParameterName=distributionParameterName[0].toxml().replace('<Name>','').replace('</Name>','')
if distributionParameterName=='mean':
MTTF=distributionParameter[0].getElementsByTagName('Value')
MTTF=float(MTTF[0].toxml().replace('<Value>','').replace('</Value>',''))
elif distributionParameterName=='availability':
availability=distributionParameter[0].getElementsByTagName('Value')
availability=(availability[0].toxml().replace('<Value>','').replace('</Value>',''))
elif propertyName=='MeanTimeToRepair':
unit=property[j].getElementsByTagName('Unit')
unit=unit[0].toxml().replace('<Unit>','').replace('</Unit>','')
distribution=property[j].getElementsByTagName('Distribution')
failureDistribution=distribution[0].getElementsByTagName('Name')
failureDistribution=failureDistribution[0].toxml().replace('<Name>','').replace('</Name>','')
distributionParameter=distribution[0].getElementsByTagName('DistributionParameter')
for k in range(len(distributionParameter)):
distributionParameterName=distributionParameter[0].getElementsByTagName('Name')
distributionParameterName=distributionParameterName[0].toxml().replace('<Name>','').replace('</Name>','')
if distributionParameterName=='mean':
MTTR=distributionParameter[0].getElementsByTagName('Value')
MTTR=float(MTTR[0].toxml().replace('<Value>','').replace('</Value>',''))
elif distributionParameterName=='availability':
availability=distributionParameter[0].getElementsByTagName('Value')
availability=(availability[0].toxml().replace('<Value>','').replace('</Value>',''))
elif propertyName=='RepairmanRequired':
repairmanID=property[j].getElementsByTagName('ResourceIdentifier')
repairmanID=(repairmanID[0].toxml().replace('<ResourceIdentifier>','').replace('</ResourceIdentifier>',''))
if repairmanID=='None':
repairman=repairmanID
else:
for j in range(len(G.RepairmanList)):
if(G.RepairmanList[j].id==repairmanID):
repairman=G.RepairmanList[j]
M=Machine(id, name, 1, distributionType, [mean,stdev,min,max], failureDistribution,
MTTF, MTTR, availability, repairman)
G.MachineList.append(M)
G.ObjList.append(M)
elif resourceClass=='Queue':
id=resource[i].getElementsByTagName('Identifier')
id=id[0].toxml().replace('<Identifier>','').replace('</Identifier>','')
name=resource[i].getElementsByTagName('Name')
name=name[0].toxml().replace('<Name>','').replace('</Name>','')
property=resource[i].getElementsByTagName('Property')
isDummy=0
capacity=2
for j in range(len(property)):
propertyName=property[j].getElementsByTagName('Name')
propertyName=propertyName[0].toxml().replace('<Name>','').replace('</Name>','')
if propertyName=='capacity':
capacity=property[j].getElementsByTagName('Value')
capacity=int(capacity[0].toxml().replace('<Value>','').replace('</Value>',''))
if propertyName=='isDummy':
capacity=property[j].getElementsByTagName('Value')
capacity=int(capacity[0].toxml().replace('<Value>','').replace('</Value>',''))
Q=Queue(id, name, capacity, isDummy)
G.QueueList.append(Q)
G.ObjList.append(Q)
elif resourceClass=='Exit':
id=resource[i].getElementsByTagName('Identifier')
id=id[0].toxml().replace('<Identifier>','').replace('</Identifier>','')
name=resource[i].getElementsByTagName('Name')
name=name[0].toxml().replace('<Name>','').replace('</Name>','')
E=Exit(id, name)
G.ExitList.append(E)
G.ObjList.append(E)
#reads the sequences process identifiers from the CMSD file
def readProcessIdentifiersSequence():
processPlan=G.CMSDData.getElementsByTagName('ProcessPlan')
process=processPlan[0].getElementsByTagName('Process')
G.processIdentifiers=[]
for i in range(len(process)):
try:
processIdentifier=process[i].getElementsByTagName('Identifier')
processIdentifierValue=processIdentifier[0].toxml().replace('<Identifier>','').replace('</Identifier>','')
except IndexError:
continue
if processIdentifierValue=='MainProcessSequence':
processNode=process[i].getElementsByTagName('Process')
for j in range(len(processNode)):
processNodeIdentifier=processNode[j].getElementsByTagName('ProcessIdentifier')
processNodeIdentifier=processNodeIdentifier[0].toxml().replace('<ProcessIdentifier>','').replace('</ProcessIdentifier>','')
G.processIdentifiers.append(processNodeIdentifier)
def readProcesses():
process=G.CMSDData.getElementsByTagName('Process')
G.TopologyList=[]
for i in range(len(G.processIdentifiers)):
G.TopologyList.append(None)
for i in range(len(process)):
index=0
try:
processIdentifier=process[i].getElementsByTagName('Identifier')
processIdentifierValue=processIdentifier[0].toxml().replace('<Identifier>','').replace('</Identifier>','')
Description=process[i].getElementsByTagName('Description')
Description=Description[0].toxml().replace('<Description>','').replace('</Description>','')
except IndexError:
continue
if processIdentifierValue in G.processIdentifiers:
resourceIdentifier=process[i].getElementsByTagName('ResourceIdentifier')
resourceIdentifier=resourceIdentifier[0].toxml().replace('<ResourceIdentifier>','').replace('</ResourceIdentifier>','')
G.TopologyList[G.processIdentifiers.index(processIdentifierValue)]=resourceIdentifier
def setPredecessorIDs():
for i in range(1,len(G.TopologyList)):
for j in range(len(G.ObjList)):
if G.ObjList[j].id==G.TopologyList[i]:
G.ObjList[j].previousIds.append(G.TopologyList[i-1])
def setSuccessorIDs():
for i in range(0,len(G.TopologyList)-1):
for j in range(len(G.ObjList)):
if G.ObjList[j].id==G.TopologyList[i]:
G.ObjList[j].nextIds.append(G.TopologyList[i+1])
#defines the topology (predecessors and successors for all the objects)
def setTopology():
#loop through all the objects
for i in range(len(G.ObjList)):
next=[]
previous=[]
for j in range(len(G.ObjList[i].previousIds)):
for q in range(len(G.ObjList)):
if G.ObjList[q].id==G.ObjList[i].previousIds[j]:
previous.append(G.ObjList[q])
for j in range(len(G.ObjList[i].nextIds)):
for q in range(len(G.ObjList)):
if G.ObjList[q].id==G.ObjList[i].nextIds[j]:
next.append(G.ObjList[q])
if G.ObjList[i].type=="Source":
G.ObjList[i].defineRouting(next)
elif G.ObjList[i].type=="Exit":
G.ObjList[i].defineRouting(previous)
#Assembly should be changed to identify what the entity that it receives is.
#previousPart and previousFrame will become problematic
elif G.ObjList[i].type=="Assembly":
previousPart=[]
previousFrame=[]
for j in range(len(G.ObjList[i].previousPartIds)):
for q in range(len(G.ObjList)):
if G.ObjList[q].id==G.ObjList[i].previousPartIds[j]:
previousPart.append(G.ObjList[q])
for j in range(len(G.ObjList[i].previousFrameIds)):
for q in range(len(G.ObjList)):
if G.ObjList[q].id==G.ObjList[i].previousFrameIds[j]:
previousFrame.append(G.ObjList[q])
G.ObjList[i].defineRouting(previousPart, previousFrame, next)
#Dispatch should be changed to identify what the the successor is.
#nextPart and nextFrame will become problematic
elif G.ObjList[i].type=="Dismantle":
nextPart=[]
nextFrame=[]
for j in range(len(G.ObjList[i].nextPartIds)):
for q in range(len(G.ObjList)):
if G.ObjList[q].id==G.ObjList[i].nextPartIds[j]:
nextPart.append(G.ObjList[q])
for j in range(len(G.ObjList[i].nextFrameIds)):
for q in range(len(G.ObjList)):
if G.ObjList[q].id==G.ObjList[i].nextFrameIds[j]:
nextFrame.append(G.ObjList[q])
G.ObjList[i].defineRouting(previous, nextPart, nextFrame)
else:
G.ObjList[i].defineRouting(previous, next)
#used to convert a string read from the input to object type
def str_to_class(str):
return getattr(sys.modules[__name__], str)
#initializes all the objects that are in the topology
def initializeObjects():
for j in range(len(G.ObjList)):
G.ObjList[j].initialize()
for j in range(len(G.RepairmanList)):
G.RepairmanList[j].initialize()
#activates all the objects
def activateObjects():
for j in range(len(G.ObjList)):
try:
activate(G.ObjList[j],G.ObjList[j].run())
except AttributeError:
pass
#the main script that is ran
def main():
#create an empty list to store all the objects in
G.ObjList=[]
#user inputs the id of the JSON file
topologyId=raw_input("give the topology id\n")
try:
#G.CMSDFile=open('CMSDInputs/Topology01.xml', "r")
G.CMSDFile=open('CMSDInputs/Topology'+str(topologyId)+'.xml', "r")
except IOError:
print "no such topology file. The programm is terminated"
sys.exit()
start=time.time() #start counting execution time
#read the input from the JSON file and create the line
G.InputData=G.CMSDFile.read()
G.CMSDData=parseString(G.InputData)
readGeneralInput()
readResources()
readProcessIdentifiersSequence()
readProcesses()
setPredecessorIDs()
setSuccessorIDs()
setTopology()
#run the experiment (replications)
for i in range(G.numberOfReplications):
print "start run number "+str(i+1)
G.seed+=1
G.Rnd=Random(G.seed)
initialize() #initialize the simulation
initializeObjects()
activateObjects()
simulate(until=G.maxSimTime) #start the simulation
#carry on the post processing operations for every object in the topology
for j in range(len(G.ObjList)):
G.ObjList[j].postProcessing(G.maxSimTime)
#output trace to excel
if(G.trace=="Yes"):
G.traceFile.save('trace'+str(i+1)+'.xls')
G.traceIndex=0 #index that shows in what row we are
G.sheetIndex=1 #index that shows in what sheet we are
G.traceFile = xlwt.Workbook() #create excel file
G.traceSheet = G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True) #create excel sheet
G.outputSheet.write(G.outputIndex,0, "Execution Time")
G.outputSheet.write(G.outputIndex,1, str(time.time()-start)+" seconds")
G.outputIndex+=2
#output data to excel for every object in the topology
for j in range(len(G.ObjList)):
G.ObjList[j].outputResultsXL(G.maxSimTime)
G.outputFile.save("output.xls")
print "execution time="+str(time.time()-start)
if __name__ == '__main__': main()
\ No newline at end of file
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