-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
2,008 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,20 @@ | ||
**/.idea/ | ||
**/__pycache__/ | ||
**/.ipynb_checkpoints | ||
*.pyc | ||
|
||
*.vscode/ | ||
|
||
mow_demo2.ipynb | ||
|
||
simpy_test.ipynb | ||
validation/ | ||
logs/ | ||
simenv/ | ||
|
||
maintsim/test.ipynb | ||
setup.py | ||
|
||
*.csv | ||
*.ipynb | ||
!demo.ipynb | ||
*.csv | ||
*.html | ||
*.pkl | ||
*.pyc | ||
*.txt | ||
*.vscode/ | ||
*.xlsx | ||
|
||
maintsim/.ipynb_checkpoints/test-checkpoint.ipynb | ||
maintsim.py | ||
simpy_test.ipynb | ||
maintsim_example.html | ||
maintsim_example.ipynb | ||
mow_demo.ipynb | ||
mow_demo2.ipynb | ||
pm_reliability.ipynb | ||
pmow_demo.ipynb | ||
maintsim/concurrent downtime demo.ipynb | ||
maintsim/degradation.py | ||
maintsim/Simpy demo.ipynb | ||
maintsim/system viz.ipynb | ||
maintsim/demo.html | ||
!requirements.txt | ||
!LICENSE.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scipy==1.5.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import random | ||
|
||
class Asset: | ||
""" | ||
Parent class for assets in the system. All objects should extend this class, and | ||
there should be no instances. | ||
""" | ||
def __init__(self, name, selection_priority=1): | ||
self.name = name | ||
# assets with higher priority will be selected over those with lower priority | ||
# when competing for resources or space. | ||
self.selection_priority = selection_priority | ||
|
||
self.upstream = [] | ||
self.downstream = [] | ||
|
||
def initialize(self): | ||
pass | ||
|
||
def get_candidate_givers(self, blocked=False): | ||
""" | ||
Returns a list of assets that can give a part to this asset from among the | ||
upstream assets. | ||
If 'blocked=True' then only return assets that are currently blocked. | ||
""" | ||
candidates = [] | ||
for candidate in self.upstream: | ||
if blocked: | ||
if candidate.blocked: | ||
candidates.append(candidate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
class Buffer: | ||
def __init__(self, name='Buffer', capacity=float('inf'), initial_level=0): | ||
self.name = name | ||
self.capacity = capacity | ||
self.initial_level = initial_level | ||
self.level = initial_level | ||
|
||
self.env = None | ||
|
||
self.level_data = {'time': [0], 'level': [initial_level]} | ||
|
||
self.pending_requests = [] | ||
|
||
def initialize(self): | ||
self.level = self.initial_level | ||
|
||
self.reserved_content = 0 | ||
self.reserved_vacancy = 0 | ||
|
||
if self.env.collect_data: | ||
self.level_data = {'time': [0], 'level': [self.initial_level]} | ||
|
||
def can_get_part(self): | ||
return self.level + self.reserved_vacancy < self.capacity | ||
|
||
def reserve_content(self, quantity=1): | ||
self.reserved_content += 1 | ||
|
||
def get(self, quantity=1): | ||
if not self.is_empty(): | ||
self.level -= quantity | ||
self.reserved_content -= quantity | ||
|
||
if self.env.collect_data: | ||
self.level_data['time'].append(self.env.now) | ||
self.level_data['level'].append(self.level) | ||
|
||
else: | ||
raise RuntimeError('Attempting to take more parts than available.') | ||
|
||
def reserve_vacancy(self, quantity=1): | ||
self.reserved_vacancy += 1 | ||
|
||
def put(self, quantity=1): | ||
if not self.is_full(): | ||
self.level += quantity | ||
self.reserved_vacancy -= 1 | ||
|
||
if self.env.collect_data: | ||
self.level_data['time'].append(self.env.now) | ||
self.level_data['level'].append(self.level) | ||
|
||
else: | ||
raise RuntimeError('Attempting to put part in full buffer.') | ||
|
||
def is_empty(self): | ||
#return self.level - self.reserved_content == 0 | ||
return self.level == 0 | ||
|
||
def is_full(self): | ||
#return self.level + self.reserved_vacancy == self.capacity | ||
return self.level == self.capacity | ||
|
||
def can_give(self): | ||
return self.level - self.reserved_content > 0 | ||
|
||
def can_receive(self): | ||
return self.level + self.reserved_vacancy < self.capacity | ||
|
||
# def get_available_space(self): | ||
# return self.capacity - self.level | ||
|
||
# def get_available_parts(self): | ||
# return self.level | ||
|
||
def define_routing(self, upstream=[], downstream=[]): | ||
self.upstream = upstream | ||
self.downstream = downstream | ||
|
||
def get_candidate_givers(self, only_free=False, blocked=False): | ||
if blocked: | ||
# get only candidate givers that can give a part | ||
return [obj for obj in self.get_candidate_givers() if obj.blocked] | ||
else: | ||
return [obj for obj in self.upstream if obj.can_give()] | ||
|
||
def get_candidate_receivers(self, only_free=False, starved=False): | ||
if starved: | ||
return [obj for obj in self.get_candidate_receivers() if obj.starved] | ||
else: | ||
# get only candidate receivers that can accept a part | ||
return [obj for obj in self.downstream if obj.can_receive()] | ||
|
Oops, something went wrong.