def build_system(self): source = Source() M1 = Machine('M1', cycle_time=1) B1 = Buffer('B1', capacity=5) M2 = Machine('M2', cycle_time=1) sink = Sink() source.define_routing(downstream=[M1]) M1.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=[M1], downstream=[M2]) M2.define_routing(upstream=[B1], downstream=[sink]) sink.define_routing(upstream=[M2]) return System(objects=[source, M1, B1, M2, sink])
def main(): source = Source() M1 = Machine(name='M1', cycle_time=1) B1 = Buffer(capacity=5) M2 = Machine(name='M2', cycle_time=1) sink = Sink() source.define_routing(downstream=[M1]) M1.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=[M1], downstream=[M2]) M2.define_routing(upstream=[B1], downstream=[sink]) sink.define_routing(upstream=[M2]) system = System([source, M1, B1, M2, sink]) system.simulate(simulation_time=utils.WEEK)
def main(): source = Source() M1 = Machine(name='M1', cycle_time=1) #M99 = Machine(name='M99', cycle_time=1) station1 = [M1] #, M99] B1 = Buffer(capacity=10) M2 = Machine(name='M2', cycle_time=1) M3 = Machine(name='M3', cycle_time=1) M4 = Machine(name='M4', cycle_time=1) station2 = [M2, M3, M4] B2 = Buffer(capacity=10) sink = Sink() M5 = Machine(name='M5', cycle_time=1) M6 = Machine(name='M6', cycle_time=1) station3 = [M5, M6] B3 = Buffer(capacity=10) source.define_routing(downstream=station1) for machine in station1: machine.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=station1, downstream=station2) for machine in station2: #machine.define_routing(upstream=[B1,B3],downstream=[B2,sink]) #possible for station2 to get a part upstream from B1, then #send that to sink -> this needs rules #define upstream first, then do if-statement for downstream? machine.define_routing(upstream=[B1, B3]) if machine.upstream == [B1]: #part came from B1, then: machine.define_routing(downstream=[B2]) if machine.upstream == [B3]: #part came from B3, then: machine.define_routing(downstream=[sink]) #if machine.upstream == [B1]: #part came from B1, then: # machine.define_routing(upstream=[B1], downstream=[B2]) #if machine.upstream == [B3]: #part came from B3, then: # machine.define_routing(upstream=[B3], downstream=[sink]) B2.define_routing(upstream=station2, downstream=station3) for machine in station3: machine.define_routing(upstream=[B2], downstream=[B3]) sink.define_routing(upstream=station2) #objects = [source] + station1 + [B1] + station2 + [B2] + station3 + [B3] + [sink] objects = [source, B1, B2, B3, sink] + station1 + station2 + station3 system = System(objects) system.simulate(simulation_time=10000)
def build_system(self): cm = {'constant': 10} source = Source() M1 = Machine('M1', cycle_time=1, degradation_matrix=degradation_matrix, cm_distribution=cm) B1 = Buffer('B1', capacity=5) M2 = Machine('M2', cycle_time=1, degradation_matrix=degradation_matrix, cm_distribution=cm) sink = Sink() source.define_routing(downstream=[M1]) M1.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=[M1], downstream=[M2]) M2.define_routing(upstream=[B1], downstream=[sink]) sink.define_routing(upstream=[M2]) return System(objects=[source, M1, B1, M2, sink])
def main(): degradation_matrix = [[0.9, 0.1, 0., 0., 0.], [0., 0.9, 0.1, 0., 0.], [0., 0., 0.9, 0.1, 0.], [0., 0., 0., 0.9, 0.1], [0., 0., 0., 0., 1.]] cbm_threshold = 3 pm_distribution = {'geometric': 0.25} cm_distribution = {'geometric': 0.10} source = Source() M1 = Machine(name='M1', cycle_time=1, degradation_matrix=degradation_matrix, cbm_threshold=cbm_threshold, pm_distribution=pm_distribution, cm_distribution=cm_distribution) B1 = Buffer(capacity=10) M2 = Machine(name='M2', cycle_time=2, degradation_matrix=degradation_matrix, cbm_threshold=cbm_threshold, pm_distribution=pm_distribution, cm_distribution=cm_distribution) sink = Sink() objects = [source, M1, B1, M2, sink] source.define_routing(downstream=[M1]) M1.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=[M1], downstream=[M2]) M2.define_routing(upstream=[B1], downstream=[sink]) sink.define_routing(upstream=[M2]) maintainer = Maintainer(capacity=1) system = System(objects=objects, maintainer=maintainer) random.seed(1) system.simulate(simulation_time=utils.WEEK)
def main(): source = Source(part_type=QualityPart) M1 = QualityMachine( name='M1', quality_distribution=lambda: 1 - 0.1 * random.random(), # [0.9, 1.0] cycle_time=1) B1 = Buffer('B1', capacity=10) M2 = QualityMachine( name='M2', quality_distribution=lambda: 0.8 - 0.2 * random.random(), # [0.6, 0.8] cycle_time=2) M3 = QualityMachine( name='M3', quality_distribution=lambda: 0.6 - 0.3 * random.random(), # [0.3, 0.6] cycle_time=2) sink = Sink() source.define_routing(downstream=[M1]) M1.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=[M1], downstream=[M2, M3]) M2.define_routing(upstream=[B1], downstream=[sink]) M3.define_routing(upstream=[B1], downstream=[sink]) sink.define_routing(upstream=[M2, M3]) system = System([source, M1, B1, M2, M3, sink]) random.seed(1) system.simulate(simulation_time=utils.DAY) print() for machine in system.machines: machine_parts = [ part for part in sink.contents if machine.name in part.routing_history ] average_quality = (sum([part.quality for part in machine_parts]) / machine.parts_made) print(f'{machine.name} average part quality: {average_quality:.2%}')
def main(): degradation_matrix = [ [0.9, 0.1, 0., 0., 0. ], [0., 0.9, 0.1, 0., 0. ], [0., 0., 0.9, 0.1, 0. ], [0., 0., 0., 0.9, 0.1], [0., 0., 0., 0., 1. ] ] source = Source() M1 = Machine( name='M1', cycle_time=1, degradation_matrix=degradation_matrix, cm_distribution={'geometric': 0.1} ) B1 = Buffer(capacity=5) M2 = Machine( name='M2', cycle_time=1, degradation_matrix=degradation_matrix, cm_distribution={'geometric': 0.1} ) sink = Sink() source.define_routing(downstream=[M1]) M1.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=[M1], downstream=[M2]) M2.define_routing(upstream=[B1], downstream=[sink]) sink.define_routing(upstream=[M2]) maintainer = Maintainer(capacity=1) system = System([source, M1, B1, M2, sink], maintainer=maintainer) random.seed(1) system.simulate(simulation_time=utils.WEEK)
def main(): source = Source() M1 = Machine('M1', cycle_time=2) M2 = Machine('M2', cycle_time=2) station1 = [M1, M2] B1 = Buffer(capacity=5) M3 = Machine('M3', cycle_time=3) M4 = Machine('M4', cycle_time=3) M5 = Machine('M5', cycle_time=3) station2 = [M3, M4, M5] B2 = Buffer(capacity=5) M6 = Machine('M6', cycle_time=2) M7 = Machine('M7', cycle_time=2) station3 = [M6, M7] sink = Sink() source.define_routing(downstream=station1) for machine in station1: machine.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=station1, downstream=station2) for machine in station2: machine.define_routing(upstream=[B1], downstream=[B2]) B2.define_routing(upstream=station2, downstream=station3) for machine in station3: machine.define_routing(upstream=[B2], downstream=[sink]) sink.define_routing(upstream=station3) #objects = [source] + station1 + [B1] + station2 + [B2] + station3 + [sink] objects = [source, B1, B2, sink] + station1 + station2 + station3 system = System(objects) system.simulate(simulation_time=500)
def main(): source = Source() M1 = Machine(name='M1', cycle_time=1) M99 = Machine(name='M99', cycle_time=1) stage1 = [M1,M99] B1 =Buffer(capacity=10) M2 = Machine(name='M2', cycle_time=1) stage2 = [M2] B2 = Buffer(capacity=10) M3 = Machine(name='M3', cycle_time=1) stage3 = [M99, M3] sink = Sink() source.define_routing(downstream=stage1) for machine in stage1: machine.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=stage1, downstream=stage2) for machine in stage2: machine.define_routing(upstream=[B1], downstream=[B2]) B2.define_routing(upstream=stage2, downstream=stage3) for machine in stage3: machine.define_routing(upstream=[B2], downstream=[sink]) sink.define_routing(upstream=stage3) #objects = [source] + station1 + [B1] + station2 + [B2] + station3 + [B3] + [sink] objects = [source, B1, B2, sink] + stage1 + stage2 + stage3 system = System(objects) system.simulate(simulation_time=500)
def main(): # Parameters for both systems degradation_matrix = [ [0.9, 0.1, 0., 0., 0. ], [0., 0.9, 0.1, 0., 0. ], [0., 0., 0.9, 0.1, 0. ], [0., 0., 0., 0.9, 0.1], [0., 0., 0., 0., 1. ] ] pm_distribution = {'geometric': 0.25} # Average PM duration: 4 minutes cm_distribution = {'geometric': 0.10} # Average CM duration: 10 minutes # Define the corrective maintenance system source = Source() M1 = Machine( name='M1', cycle_time=1, degradation_matrix=degradation_matrix, cm_distribution=cm_distribution ) B1 = Buffer(capacity=10) M2 = Machine( name='M2', cycle_time=1, degradation_matrix=degradation_matrix, cm_distribution=cm_distribution ) sink = Sink() objects = [source, M1, B1, M2, sink] source.define_routing(downstream=[M1]) M1.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=[M1], downstream=[M2]) M2.define_routing(upstream=[B1], downstream=[sink]) sink.define_routing(upstream=[M2]) maintainer = Maintainer(capacity=1) corrective_maintenance_system = System(objects=objects, maintainer=maintainer) # Define the condition-based maintenance system cbm_threshold = 3 source = Source() M1 = Machine( name='M1', cycle_time=1, degradation_matrix=degradation_matrix, cbm_threshold=cbm_threshold, pm_distribution=pm_distribution, cm_distribution=cm_distribution ) B1 = Buffer(capacity=10) M2 = Machine( name='M2', cycle_time=1, degradation_matrix=degradation_matrix, cbm_threshold=cbm_threshold, pm_distribution=pm_distribution, cm_distribution=cm_distribution ) sink = Sink() objects = [source, M1, B1, M2, sink] source.define_routing(downstream=[M1]) M1.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=[M1], downstream=[M2]) M2.define_routing(upstream=[B1], downstream=[sink]) sink.define_routing(upstream=[M2]) maintainer = Maintainer(capacity=1) condition_based_maintenance_system = System(objects=objects, maintainer=maintainer) # Simulate both systems replications = 50 random.seed(1) cm_results = corrective_maintenance_system.iterate_simulation( replications=replications, warm_up_time=utils.DAY, simulation_time=utils.WEEK, jobs=10, # Simulate in parallel using 10 cores verbose=False ) cm_production = [r[0] for r in cm_results] cm_average = sum(cm_production) / replications cbm_results = condition_based_maintenance_system.iterate_simulation( replications=replications, warm_up_time=utils.DAY, simulation_time=utils.WEEK, jobs=10, verbose=False ) cbm_production = [r[0] for r in cbm_results] cbm_average = sum(cbm_production) / replications print(f'Average corrective maintenance production: {cm_average:.2f} units') print(f'Average condition-based maintenance production: {cbm_average:.2f} units')
def main(): source = Source() M1 = Machine(name='M1', cycle_time=2) B1 = Buffer(capacity=4) M2 = Machine(name='M2', cycle_time=1) B2 = Buffer(capacity=8) M3 = Machine(name='M3', cycle_time=1) B3 = Buffer(capacity=16) M4 = Machine(name='M4', cycle_time=1) sink = Sink() source.define_routing(downstream=[M1]) M1.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=[M1], downstream=[M2]) M2.define_routing(upstream=[B1], downstream=[B2]) B2.define_routing(upstream=[M2], downstream=[M3]) M3.define_routing(upstream=[B2], downstream=[B3]) B3.define_routing(upstream=[M3], downstream=[M4]) M4.define_routing(upstream=[B3], downstream=[sink]) sink.define_routing(upstream=[M2]) system = System(objects=[source, M1, B1, M2, B2, M3, B3, M4, sink]) system.simulate(simulation_time=500)
def main(): source = Source() M1 = Machine(name='M1', cycle_time=1) #M99 = Machine(name='M99', cycle_time=1) stage1 = [M1] #, M99] B1 = Buffer(capacity=10) M2 = Machine(name='M2', cycle_time=1) M3 = Machine(name='M3', cycle_time=1) M4 = Machine(name='M4', cycle_time=1) M7 = Machine(name='M7', cycle_time=1) stage2 = [M2, M3, M4, M7] stage4 = [M2, M3, M4] B2 = Buffer(capacity=10) sink = Sink() M5 = Machine(name='M5', cycle_time=1) M6 = Machine(name='M6', cycle_time=1) stage3 = [M5, M6] B3 = Buffer(capacity=10) source.define_routing(downstream=stage1) for machine in stage1: machine.define_routing(upstream=[source], downstream=[B1]) B1.define_routing(upstream=stage1, downstream=stage2) for machine in stage2: machine.define_routing(upstream=[B1], downstream=[B2]) B2.define_routing(upstream=stage2, downstream=stage3) for machine in stage3: machine.define_routing(upstream=[B2], downstream=[B3]) B3.define_routing(upstream=stage3, downstream=stage4) for machine in stage4: machine.define_routing(upstream=[B3], downstream=[sink]) sink.define_routing(upstream=stage4) #objects = [source] + station1 + [B1] + station2 + [B2] + station3 + [B3] + [sink] objects = [source, B1, B2, B3, sink] + stage1 + stage2 + stage3 + stage4 system = System(objects) system.simulate(simulation_time=10000) # system.simulate(simulation_time=utils.WEEK) print(f'\nM1 parts made: {M1.parts_made}') print(f'M2 parts made: {M2.parts_made}') print(f'M3 parts made: {M3.parts_made}') print(f'M4 parts made: {M4.parts_made}') print(f'M5 parts made: {M5.parts_made}') print(f'M6 parts made: {M6.parts_made}') print(f'M7 parts made: {M7.parts_made}') print(f'Stage 1 parts made: {M1.parts_made}\n') print( f'Stage 2 parts made: {M2.parts_made + M3.parts_made + M4.parts_made + M7.parts_made}\n' ) print(f'Stage 3 parts made: {M5.parts_made + M6.parts_made}\n') print( f'Stage 4 parts made: {M2.parts_made + M3.parts_made + M4.parts_made}\n' ) print(f'Total parts made: {sink.level}') plot_throughput(system, plot_rated_throughput=False) plot_health(system)