fmdtools 2.0.5__tar.gz → 2.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. {fmdtools-2.0.5 → fmdtools-2.0.7}/LICENSE +1 -1
  2. {fmdtools-2.0.5/fmdtools.egg-info → fmdtools-2.0.7}/PKG-INFO +5 -5
  3. {fmdtools-2.0.5 → fmdtools-2.0.7}/README.md +2 -2
  4. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/asg_demo/demo_model.py +2 -5
  5. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multiflow_demo/multiflow_demo.py +5 -5
  6. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multirotor/drone_mdl_dynamic.py +19 -10
  7. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multirotor/drone_mdl_hierarchical.py +2 -2
  8. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multirotor/drone_mdl_rural.py +5 -5
  9. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multirotor/drone_mdl_static.py +1 -1
  10. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multirotor/drone_mdl_urban.py +6 -6
  11. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multirotor/test_multirotor.py +1 -1
  12. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/pump/ex_pump.py +4 -4
  13. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/pump/parallelism_methods.py +36 -17
  14. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/pump/pump_stochastic.py +7 -7
  15. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/pump/test_pump_stochastic.py +18 -18
  16. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/rover_model.py +3 -3
  17. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/tank/tank_model.py +7 -3
  18. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/taxiway/asset.py +4 -5
  19. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/taxiway/common.py +1 -1
  20. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/taxiway/model.py +14 -14
  21. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/taxiway/test_asset.py +4 -4
  22. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/__init__.py +1 -1
  23. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/common.py +358 -84
  24. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/graph/base.py +1 -1
  25. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/graph/model.py +20 -3
  26. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/history.py +158 -147
  27. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/phases.py +18 -21
  28. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/result.py +227 -243
  29. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/tabulate.py +135 -92
  30. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/architecture/action.py +11 -6
  31. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/architecture/base.py +30 -13
  32. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/architecture/component.py +3 -5
  33. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/architecture/function.py +25 -11
  34. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/base.py +127 -10
  35. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/block/base.py +37 -20
  36. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/block/function.py +7 -9
  37. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/container/mode.py +3 -0
  38. fmdtools-2.0.7/fmdtools/define/container/rand.py +602 -0
  39. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/flow/commsflow.py +59 -9
  40. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/flow/multiflow.py +96 -10
  41. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/object/base.py +18 -13
  42. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/object/coords.py +875 -550
  43. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/sim/propagate.py +3 -2
  44. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/sim/sample.py +102 -95
  45. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/sim/scenario.py +0 -4
  46. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/sim/search.py +145 -37
  47. {fmdtools-2.0.5 → fmdtools-2.0.7/fmdtools.egg-info}/PKG-INFO +5 -5
  48. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools.egg-info/SOURCES.txt +1 -0
  49. {fmdtools-2.0.5 → fmdtools-2.0.7}/pyproject.toml +1 -1
  50. fmdtools-2.0.7/tests/test_hierarchical.py +78 -0
  51. {fmdtools-2.0.5 → fmdtools-2.0.7}/tests/test_packages.py +20 -14
  52. fmdtools-2.0.5/fmdtools/define/container/rand.py +0 -408
  53. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/__init__.py +0 -0
  54. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/asg_demo/__init__.py +0 -0
  55. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/eps/__init__.py +0 -0
  56. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/eps/eps.py +0 -0
  57. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/eps/test_eps.py +0 -0
  58. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multiflow_demo/__init__.py +0 -0
  59. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multiflow_demo/test_multiflow.py +0 -0
  60. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multirotor/__init__.py +0 -0
  61. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/multirotor/opt_drone_rural.py +0 -0
  62. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/pump/__init__.py +0 -0
  63. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/pump/jointfaults_ex.py +0 -0
  64. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/pump/pump_indiv.py +0 -0
  65. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/pump/test_pump.py +0 -0
  66. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/pump/test_pump_example.py +0 -0
  67. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/__init__.py +0 -0
  68. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/opt_rover.py +0 -0
  69. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/optimization/ea_analysis.py +0 -0
  70. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/optimization/search_rover.py +0 -0
  71. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/optimization/untitled2.py +0 -0
  72. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/rover_degradation.py +0 -0
  73. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/rover_mode_space.py +0 -0
  74. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/rover_model_human.py +0 -0
  75. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/rover/test_rover.py +0 -0
  76. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/tank/__init__.py +0 -0
  77. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/tank/tank_optimization_model.py +0 -0
  78. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/tank/test_tank.py +0 -0
  79. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/taxiway/ATC.py +0 -0
  80. {fmdtools-2.0.5 → fmdtools-2.0.7}/examples/taxiway/test_model.py +0 -0
  81. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/__init__.py +0 -0
  82. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/graph/__init__.py +0 -0
  83. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/graph/label.py +0 -0
  84. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/analyze/graph/style.py +0 -0
  85. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/__init__.py +0 -0
  86. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/architecture/__init__.py +0 -0
  87. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/architecture/geom.py +0 -0
  88. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/block/__init__.py +0 -0
  89. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/block/action.py +0 -0
  90. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/block/component.py +0 -0
  91. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/container/__init__.py +0 -0
  92. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/container/base.py +0 -0
  93. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/container/parameter.py +0 -0
  94. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/container/state.py +0 -0
  95. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/container/time.py +0 -0
  96. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/environment.py +0 -0
  97. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/flow/__init__.py +0 -0
  98. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/flow/base.py +0 -0
  99. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/object/__init__.py +0 -0
  100. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/object/geom.py +0 -0
  101. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/define/object/timer.py +0 -0
  102. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools/sim/__init__.py +0 -0
  103. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools.egg-info/dependency_links.txt +0 -0
  104. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools.egg-info/requires.txt +0 -0
  105. {fmdtools-2.0.5 → fmdtools-2.0.7}/fmdtools.egg-info/top_level.txt +0 -0
  106. {fmdtools-2.0.5 → fmdtools-2.0.7}/setup.cfg +0 -0
  107. {fmdtools-2.0.5 → fmdtools-2.0.7}/tests/test_graph.py +0 -0
@@ -1,4 +1,4 @@
1
- fmdtools version 2.0.5
1
+ fmdtools version 2.0.7
2
2
  ---------------------------
3
3
  Apache License
4
4
  Version 2.0, January 2004
@@ -1,10 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: fmdtools
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: System resilience modelling, simulation, and assessment in Python
5
5
  Author: fmdtools Developers
6
6
  Maintainer-email: Daniel Hulse <daniel.e.hulse@nasa.gov>
7
- License: fmdtools version 2.0.5
7
+ License: fmdtools version 2.0.7
8
8
  ---------------------------
9
9
  Apache License
10
10
  Version 2.0, January 2004
@@ -357,7 +357,7 @@ This may then be installed using:
357
357
  Note that this version reflects the latest version on the ``main`` git branch along with any local changes. To use a particular version of ``fmdtools`` you can checkout the tag corresponding to the version you want, e.g.:
358
358
 
359
359
  ```
360
- git checkout v2.0.5
360
+ git checkout v2.0.7
361
361
  ```
362
362
 
363
363
 
@@ -495,7 +495,7 @@ To cite a particular version of the fmdtools, you may use:
495
495
  author = {{NASA}},
496
496
  title = {fmdtools},
497
497
  url = {https://github.com/nasa/fmdtools},
498
- version = {2.0.5}, # <- replace with your version number
498
+ version = {2.0.7},
499
499
  date = {2024-11-13},
500
500
  }
501
501
  ```
@@ -97,7 +97,7 @@ This may then be installed using:
97
97
  Note that this version reflects the latest version on the ``main`` git branch along with any local changes. To use a particular version of ``fmdtools`` you can checkout the tag corresponding to the version you want, e.g.:
98
98
 
99
99
  ```
100
- git checkout v2.0.5
100
+ git checkout v2.0.7
101
101
  ```
102
102
 
103
103
 
@@ -235,7 +235,7 @@ To cite a particular version of the fmdtools, you may use:
235
235
  author = {{NASA}},
236
236
  title = {fmdtools},
237
237
  url = {https://github.com/nasa/fmdtools},
238
- version = {2.0.5}, # <- replace with your version number
238
+ version = {2.0.7},
239
239
  date = {2024-11-13},
240
240
  }
241
241
  ```
@@ -157,7 +157,7 @@ class ProduceHazard(Function):
157
157
  class PassStates(State):
158
158
  """Whether or not the hazard is ultimately passed or mitigated."""
159
159
 
160
- hazards_mitigated: int = 0
160
+ hazards_mitigated: int = 0
161
161
  hazards_propagated: int = 0
162
162
 
163
163
 
@@ -185,7 +185,7 @@ class HazardModel(FunctionArchitecture):
185
185
  self.add_flow("hazard", Hazard)
186
186
  self.add_fxn("produce_hazard", ProduceHazard, 'hazard')
187
187
  self.add_fxn("detect_hazard", DetectHazard, 'hazard')
188
- self.add_fxn("pass_hazard", PassHazard, 'hazard')
188
+ self.add_fxn("pass_hazard", PassHazard, 'hazard')
189
189
 
190
190
 
191
191
  if __name__ == '__main__':
@@ -194,9 +194,6 @@ if __name__ == '__main__':
194
194
  result_fault, mdlhist_fault = prop.one_fault(mdl, 'detect_hazard',
195
195
  'act_unable', time=4,
196
196
  desired_result='graph')
197
- result_fault, mdlhist_fault = prop.one_fault(mdl, 'detect_hazard',
198
- 'perceive_failed', time=4,
199
- desired_result='graph')
200
197
 
201
198
  result_fault.graph.draw()
202
199
  ex_fxn = DetectHazard('detect_hazard')
@@ -66,10 +66,10 @@ class Mover(Function):
66
66
  # communicate
67
67
  if self.p.x_up != 0.0:
68
68
  self.internal_info.s.x = self.loc.s.x
69
- self.internal_info.send("all", "local", "x")
69
+ self.internal_info.send("all", "x")
70
70
  elif self.p.y_up != 0.0:
71
71
  self.internal_info.s.y = self.loc.s.y
72
- self.internal_info.send("all", "local", "y")
72
+ self.internal_info.send("all", "y")
73
73
 
74
74
  def find_classification(self, scen, fxnhist):
75
75
  return {"last_x": self.loc.s.x, "min_x": fxnhist.faulty.location.get(self.name).x}
@@ -89,8 +89,8 @@ class Coordinator(Function):
89
89
 
90
90
  def static_behavior(self, time):
91
91
  self.coord_view.receive()
92
- self.coord_view.update("local", "mover_1", "y")
93
- self.coord_view.update("local", "mover_2", "x")
92
+ self.coord_view.update("y", to_update="local", to_get="mover_1")
93
+ self.coord_view.update("x", to_update="local", to_get="mover_2")
94
94
 
95
95
 
96
96
  class ExModel(FunctionArchitecture):
@@ -100,7 +100,7 @@ class ExModel(FunctionArchitecture):
100
100
  def init_architecture(self, **kwargs):
101
101
 
102
102
  self.add_flow("communications", Communications)
103
- self.add_flow("location", Location)
103
+ self.add_flow("location", Location)
104
104
  self.add_fxn("mover_1", Mover, "communications", "location", p={"x_up": 1.0})
105
105
  self.add_fxn("mover_2", Mover, "communications", "location", p={"y_up": 1.0})
106
106
 
@@ -86,8 +86,8 @@ class SightGrid(Coords):
86
86
  container_p = DroneEnvironmentGridParam
87
87
 
88
88
  def init_properties(self, *args, **kwargs):
89
- """Set target true between 0 and 150 in the x and 10 and 160 in the y."""
90
- self.set_range("target", True, 0, 150, 10, 160)
89
+ """Set target true between 0 and 155 in the x and 10 and 155 in the y."""
90
+ self.set_range("target", True, 0, 155, 10, 155)
91
91
 
92
92
 
93
93
  class DroneEnvironment(Environment):
@@ -189,12 +189,12 @@ class PlanPathState(State):
189
189
  class PlanPathParams(Parameter):
190
190
  """Defines flightplan."""
191
191
 
192
- goals = ((0.0, 0.0, 50.0),
193
- (100.0, 0.0, 50.0),
194
- (100.0, 100.0, 50.0),
195
- (150.0, 150.0, 50.0),
196
- (0.0, 0.0, 50.0),
197
- (0.0, 0.0, 0.0))
192
+ goals = ((0.0, 0.0, 50.0),
193
+ (100.0, 0.0, 50.0),
194
+ (100.0, 100.0, 50.0),
195
+ (150.0, 150.0, 50.0),
196
+ (0.0, 0.0, 50.0),
197
+ (0.0, 0.0, 0.0))
198
198
 
199
199
 
200
200
  class PlanPathTime(Time):
@@ -391,7 +391,8 @@ class ViewEnvironment(Function):
391
391
  self.dofs.s.x - width/2,
392
392
  self.dofs.s.x + width/2,
393
393
  self.dofs.s.y - height/2,
394
- self.dofs.s.y + height/2)
394
+ self.dofs.s.y + height/2,
395
+ outside_error=False)
395
396
 
396
397
 
397
398
  class Drone(FunctionArchitecture):
@@ -521,17 +522,24 @@ def script_env_viewed(**kwargs):
521
522
  """Show the viewed properties of the environment in various configurations."""
522
523
  mdl = Drone(**kwargs)
523
524
  ec, mdlhist = fs.propagate.nominal(mdl)
525
+ l_k = dict(new_labs={'viewed': 'viewed_true', 'target': 'target_true'})
524
526
  mdl.flows['environment'].c.assign_from(mdlhist.flows.environment.c, 10)
525
527
  mdl.flows['environment'].c.show({'viewed': {}})
526
528
 
527
529
  mdl.flows['environment'].c.show({'viewed': {}, 'target': {}})
528
530
  mdl.flows['environment'].c.show({'target': {},
529
531
  'viewed': {'alpha': 0.5}},
532
+ legend_kwargs=l_k,
530
533
  collections={'start': {}, 'safe': {}})
531
534
 
532
535
  mdl.flows['environment'].c.show_from(10, mdlhist.flows.environment.c,
533
- {'viewed': {}}, title='hi')
536
+ {'viewed': {}}, title='hi',
537
+ legend_kwargs=l_k)
534
538
  properties={'target': {'alpha': 0.6}, 'viewed': {'alpha': 0.5}}
539
+ mdl.flows['environment'].c.show_over_time([0, 10, 15],
540
+ history=mdlhist.flows.environment.c,
541
+ properties=properties, title='hi')
542
+
535
543
  ani = mdl.flows['environment'].c.animate(mdlhist.flows.environment.c,
536
544
  properties=properties,
537
545
  collections={'start': {}, 'safe': {}})
@@ -542,6 +550,7 @@ if __name__ == "__main__":
542
550
  from fmdtools.sim.sample import SampleApproach
543
551
  from fmdtools.analyze.phases import PhaseMap
544
552
  from fmdtools import analyze as an
553
+ s = SightGrid()
545
554
  import doctest
546
555
  # doctest.testmod(verbose=True)
547
556
  # script_nominal_viewed()
@@ -169,8 +169,8 @@ class AffectDOF(AffectDOFDynamic):
169
169
  """Corrects for individual line faultmodes by turning off the opposite rotor
170
170
  and upping the throttle (amp_factor)"""
171
171
  for fault in self.m.faults:
172
- if fault in self.ca.faultmodes:
173
- comp = self.ca.faultmodes[fault]
172
+ if fault in self.ca.m.sub_modes:
173
+ comp = self.ca.m.sub_modes[fault]
174
174
  opp = self.ca.p.opposite[comp]
175
175
  if self.ca.s.forward[comp] != 0.0:
176
176
  self.ca.s.forward[comp] = 0.0
@@ -111,7 +111,7 @@ class DroneParam(Parameter, readonly=True):
111
111
  phys_param: DronePhysicalParameters
112
112
  """
113
113
 
114
- respolicy: ResPolicy = ResPolicy()
114
+ respolicy: ResPolicy = ResPolicy()
115
115
  flightplan: tuple = ((0, 0, 0), # flies through a few points and back to the start
116
116
  (0, 0, 100),
117
117
  (100, 0, 100),
@@ -164,9 +164,9 @@ class BatState(State):
164
164
  Power transference with nominal value 1.0
165
165
  """
166
166
 
167
- soc: float = 100.0
167
+ soc: float = 100.0
168
168
  ee_e: float = 1.0
169
- e_t: float = 1.0
169
+ e_t: float = 1.0
170
170
 
171
171
 
172
172
  class BatMode(Mode):
@@ -347,7 +347,7 @@ class StoreEEMode(Mode):
347
347
  """Overall StoreEE mode."""
348
348
 
349
349
  failrate = 1e-4
350
- fm_args = {'nocharge': (0.2, 0, {"taxi": 0.6, "move": 0.2, "land": 0.2}),
350
+ fm_args = {'nocharge': (0.2, 0, {"taxi": 0.6, "move": 0.2, "land": 0.2}),
351
351
  'lowcharge': (0.7, 0, {"taxi": 0.6, "move": 0.2, "land": 0.2})}
352
352
  units = 'hr'
353
353
 
@@ -934,7 +934,7 @@ if __name__ == "__main__":
934
934
 
935
935
  # run approach - all faults in "move" mode
936
936
  mdl = Drone()
937
- app = SampleApproach(mdl, phasemaps=phasemaps)
937
+ app = SampleApproach(mdl, phasemaps=phasemaps)
938
938
  app.add_faultdomain("drone_faults", "all")
939
939
  app.add_faultsample("move_scens", "fault_phases", "drone_faults", "move",
940
940
  phasemap='plan_path', args=(3,))
@@ -351,7 +351,7 @@ class HoldPayloadState(State):
351
351
  Force from the ground
352
352
  """
353
353
 
354
- force_gr: float = 1.0
354
+ force_gr: float = 1.0
355
355
 
356
356
 
357
357
  class HoldPayload(Function):
@@ -535,13 +535,13 @@ if __name__ == "__main__":
535
535
  plot_env_with_traj_z(hists, mdl)
536
536
  plot_env_with_traj(hists, mdl)
537
537
  statsfmea = an.tabulate.FMEA(endresults, app, group_by=('function', 'fault'),
538
- weight_metrics=['rate'],
539
- avg_metrics=['unsafe_flight_time', 'cost', 'repcost',
540
- 'landcost', 'body_strikes',
541
- 'head_strikes', 'property_restrictions'])
542
- statsfmea.sort_by_metric("cost")
538
+ average_metric=['rate', 'unsafe_flight_time', 'cost',
539
+ 'repcost', 'landcost', 'body_strikes',
540
+ 'head_strikes', 'property_restrictions'],
541
+ rates='rate')
542
+ statsfmea.sort_by_metric("average_cost")
543
543
  statsfmea.as_table()
544
- statsfmea.as_plots("repcost", "unsafe_flight_time", "cost", "rate",
544
+ statsfmea.as_plots("average_repcost", "average_unsafe_flight_time", "average_cost", "average_rate",
545
545
  color_factor="function", suppress_ticklabels=True,
546
546
  legend_loc=2)
547
547
 
@@ -94,7 +94,7 @@ class DroneParameterTests(unittest.TestCase):
94
94
  mdl = Drone()
95
95
 
96
96
  sp = SingleFaultScenarioProblem(mdl, ("affect_dof", "rf_propwarp"),
97
- t_start=2.0, track=None)
97
+ sim_start=2.0, track=None)
98
98
  sp.add_result_objective("f1", "plan_path.t.time", time=15)
99
99
  sp.add_result_objective("f2", "dofs.s.x", time=15)
100
100
 
@@ -599,7 +599,7 @@ def script_fault_degradation_tables(**kwargs):
599
599
  """Show fault/degradation tables/plots for a given fault scenario."""
600
600
  mdl = Pump(**kwargs, track="all")
601
601
  endclass, mdlhist = propagate.one_fault(
602
- mdl, 'import_ee', 'no_v', time=29, staged=True)
602
+ mdl, 'import_ee', 'no_v', time=29, staged=True)
603
603
 
604
604
  ks = mdl.get_roles_as_dict("fxn", "flow", flex_prefixes=True)
605
605
  deghist = mdlhist.get_degraded_hist(*ks)
@@ -644,7 +644,7 @@ def script_sample_faults(track='all', **kwargs):
644
644
 
645
645
 
646
646
 
647
- c = an.tabulate.Comparison(endclasses, faultapp, default_stat=np.mean,
647
+ c = an.tabulate.Comparison(endclasses, faultapp, default_stat=np.average,
648
648
  metrics=['cost', 'rate', 'expected_cost'],
649
649
  ci_metrics=['cost'])
650
650
  c.as_table()
@@ -654,8 +654,8 @@ def script_sample_faults(track='all', **kwargs):
654
654
 
655
655
  fmea = an.tabulate.FMEA(endclasses, faultapp)
656
656
  fmea.as_table()
657
- fmea.sort_by_metric("cost")
658
- fmea.as_plot("cost", color_factor="function")
657
+ fmea.sort_by_metric("expected_cost")
658
+ fmea.as_plot("expected_cost", color_factor="function")
659
659
 
660
660
  # test cases for multiplot legend/axis sharing
661
661
  mdlhists.plot_line("flows.ee_1.s.current", "flows.sig_1.s.power",
@@ -30,33 +30,42 @@ def close_pool(pool):
30
30
  pool.close()
31
31
  pool.terminate()
32
32
 
33
- def delay_test(delays = [i for i in range(0,100,10)]):
34
- """ Delay parameter use-case described in notebook--here we are using pool.map to manually
35
- simulate the model several times over parameters we want to run."""
33
+
34
+ def delay_test(delays=[i for i in range(0, 100, 10)]):
35
+ """
36
+ Delay parameter use-case described in notebook.
37
+
38
+ Uses pool.map to manually simulate the model several times over parameters we want
39
+ to run.
40
+ """
36
41
  pool = mp.Pool(4)
37
42
  resultslist = pool.map(one_delay_helper, delays)
38
43
  close_pool(pool)
39
44
  return resultslist
40
45
 
46
+
41
47
  def one_delay_helper(delay):
42
- """This helper function is used by pool.map to generate output over the given
43
- input delays"""
48
+ """Generate output over the given input delays."""
44
49
  mdl = Pump(p=PumpParam(delay=delay))
45
50
  endclasses, mdlhists = propagate.one_fault(mdl, 'export_water', 'block')
46
51
  return endclasses
47
52
 
48
- def compare_pools(mdl, app, pools, staged=False, track=False, verbose= True, track_times='all'):
53
+
54
+ def compare_pools(mdl, app, pools, staged=False, track=False, verbose=True,
55
+ track_times='all'):
49
56
  """
50
- Method to compare the performance of different process pools on a given model/fault sampling approach
57
+ Compare the performance for given a model and sampling approach.
51
58
 
52
59
  Parameters
53
60
  ----------
54
61
  mdl : Model
55
62
  fmdtools model
56
63
  app : FaultSample
57
- SampleApproach of fault scenarios to simulate the model over using propagate.fault_sample
64
+ SampleApproach of fault scenarios to simulate the model over using
65
+ propagate.fault_sample
58
66
  pools : dict
59
- Dictionary of parallel/process pools {'poolname':pool} to compare. Pools must have a map function.
67
+ Dictionary of parallel/process pools {'poolname':pool} to compare. Pools must
68
+ have a map function.
60
69
  staged : bool, optional
61
70
  Whether to use staged execution on the model. The default is False.
62
71
  track : str/bool, optional
@@ -67,7 +76,8 @@ def compare_pools(mdl, app, pools, staged=False, track=False, verbose= True, tra
67
76
  Defines what times to include in the history. Options are:
68
77
  'all'--all simulated times
69
78
  ('interval', n)--includes every nth time in the history
70
- ('times', [t1, ... tn])--only includes times defined in the vector [t1 ... tn]
79
+ ('times', [t1, ... tn])--only includes times defined in the vector
80
+ [t1 ... tn]
71
81
 
72
82
  Returns
73
83
  -------
@@ -114,31 +124,36 @@ def parallel_mc(iters=10):
114
124
  close_pool(pool)
115
125
  return res
116
126
 
127
+
117
128
  def parallel_mc2(iters=10):
118
- """run for performance evaluation of model with map function"""
129
+ """Run to evaluate performance of model with map function."""
119
130
  pool = mp.Pool(4)
120
131
  models = [Pump() for i in range(iters)]
121
132
  result_list = pool.map(propagate.nominal, models)
122
133
  close_pool(pool)
123
134
  return result_list
124
135
 
136
+
125
137
  def one_fault_helper(args):
126
- """Helper function for parallel_mc3 to run in pool.map"""
138
+ """Helper function for parallel_mc3 to run in pool.map."""
127
139
  mdl = Pump()
128
140
  endclasses, mdlhists = propagate.one_fault(mdl, args[0], args[1])
129
141
  return endclasses, mdlhists
130
142
 
143
+
131
144
  def parallel_mc3():
132
- """run for performance evaluation of model single fault simulation"""
145
+ """Run for performance evaluation of model single fault simulation."""
133
146
  pool = mp.Pool(4)
134
147
  mdl = Pump()
135
- inputlist = [(fxn,fm) for fxn in mdl.fxns for fm in mdl.fxns[fxn].faultmodes.keys()]
148
+ inputlist = [(fxn, fm) for fxn in mdl.fxns
149
+ for fm in mdl.fxns[fxn].m.faultmodes.keys()]
136
150
  resultslist = pool.map(one_fault_helper, inputlist)
137
151
  close_pool(pool)
138
152
  return resultslist
139
153
 
154
+
140
155
  def instantiate_pools(cores, with_pathos=False):
141
- """Used to instantiate multiprocessing pools for comparison"""
156
+ """Instantiate multiprocessing pools for comparison."""
142
157
  if with_pathos:
143
158
  from pathos.pools import ParallelPool, ProcessPool, SerialPool, ThreadPool
144
159
  return {'multiprocessing': mp.Pool(cores),
@@ -150,14 +165,18 @@ def instantiate_pools(cores, with_pathos=False):
150
165
  return {'multiprocessing': mp.Pool(cores),
151
166
  'multiprocess': ms.Pool(cores)}
152
167
 
168
+
153
169
  def terminate_pools(pools):
154
170
  """End pools after comparing them."""
155
171
  for pool in pools.values():
156
172
  pool.terminate()
157
173
 
158
174
 
159
- if __name__=='__main__':
160
- mdl=Pump(sp = dict(phases=(('start',0,4),('on',5, 49),('end',50,500)), end_time=500))
175
+ if __name__ == '__main__':
176
+ mdl = Pump(sp=dict(phases=(('start', 0, 4),
177
+ ('on', 5, 49),
178
+ ('end', 50, 500)),
179
+ end_time=500))
161
180
  from fmdtools.sim.sample import FaultDomain, FaultSample
162
181
  fd = FaultDomain(mdl)
163
182
  fd.add_all()
@@ -19,7 +19,7 @@ CONDITIONS OF ANY KIND, either express or implied. See the License for the
19
19
  specific language governing permissions and limitations under the License.
20
20
  """
21
21
 
22
- from examples.pump.ex_pump import MoveWat as DetMoveWat
22
+ from examples.pump.ex_pump import MoveWat as DetMoveWat
23
23
  from examples.pump.ex_pump import ImportWater, ExportWater
24
24
  from examples.pump.ex_pump import ImportEE as DetImportEE
25
25
  from examples.pump.ex_pump import ImportSig as DetImportSig
@@ -214,13 +214,13 @@ if __name__ == "__main__":
214
214
  # print(fxn.return_probdens())
215
215
  # print(getattr(fxn, 'pds', None))
216
216
 
217
- endresults, mdlhist = propagate.one_fault(mdl, 'export_water', 'block',
218
- time=20, staged=False, run_stochastic=False,
219
- new_params={'modelparams': {'seed': 50}})
217
+ endresults, mdlhist = propagate.one_fault(mdl, 'export_water', 'block',
218
+ time=20, staged=False, run_stochastic=False,
219
+ new_params={'modelparams': {'seed': 50}})
220
220
 
221
- endresults, mdlhist = propagate.one_fault(mdl, 'export_water', 'block',
222
- time=20, staged=False, run_stochastic=True,
223
- new_params={'modelparams': {'seed': 50}})
221
+ endresults, mdlhist = propagate.one_fault(mdl, 'export_water', 'block',
222
+ time=20, staged=False, run_stochastic=True,
223
+ new_params={'modelparams': {'seed': 50}})
224
224
 
225
225
  # mdlhist['faulty']['functions']['ImportEE']['probdens']
226
226
 
@@ -44,20 +44,20 @@ class StochasticPumpTests(unittest.TestCase, CommonTests):
44
44
  def test_stochastic_pdf(self):
45
45
  """Tests that (1) track_pdf option runs and (2) gives repeated
46
46
  probability density results under the same seed(s)"""
47
- testvals = [6.634978895402383,
48
- 7.52240849998729,
49
- 0.015351713962842411,
50
- 4.19649888042945,
51
- 0.11203099056041071,
52
- 1.5036852812847645,
53
- 7.936686476148655,
54
- 0.0853617670950819,
55
- 3.0182506814918377]
47
+ testvals = [35.23570453993965,
48
+ 49.32124529702974,
49
+ 0.31327201999190035,
50
+ 21.386958080811567,
51
+ 1.1103965455215503,
52
+ 9.066120598345039,
53
+ 131.79987407014573,
54
+ 5.81402243889764,
55
+ 19.01081621541118]
56
+ mdl = Pump(r={'run_stochastic': 'track_pdf'})
56
57
  for i in range(1, 10):
57
- self.mdl.update_seed(i)
58
- self.mdl.propagate(i, run_stochastic='track_pdf')
59
- pd = self.mdl.return_probdens()
60
- # print(pd)
58
+ mdl.update_seed(i)
59
+ mdl.propagate(i, run_stochastic='track_pdf')
60
+ pd = mdl.return_probdens()
61
61
  self.assertAlmostEqual(pd, testvals[i-1])
62
62
 
63
63
  def test_run_safety(self):
@@ -67,10 +67,10 @@ class StochasticPumpTests(unittest.TestCase, CommonTests):
67
67
  res_1, hist_1 = prop.nominal(mdl, run_stochastic=True, showprogress=False)
68
68
  res_f1, hist_f1 = prop.single_faults(mdl, run_stochastic=True,
69
69
  showprogress=False)
70
- if seed == None:
70
+ if seed is None:
71
71
  seed = mdl.r.seed
72
72
  mdl2 = Pump(r={'seed': seed})
73
- res_2, hist_2 = prop.nominal(mdl2, run_stochastic=True, showprogress=False)
73
+ res_2, hist_2 = prop.nominal(mdl2, run_stochastic=True, showprogress=False)
74
74
  res_f2, hist_f2 = prop.single_faults(mdl2, run_stochastic=True,
75
75
  showprogress=False)
76
76
  self.assertTrue(all(hist_1.fxns.move_water.s.eff ==
@@ -282,7 +282,7 @@ class StochasticPumpTests(unittest.TestCase, CommonTests):
282
282
 
283
283
  if __name__ == '__main__':
284
284
  # suite = unittest.TestSuite()
285
- # suite.addTest(StochasticPumpTests("test_run_approach"))
285
+ # suite.addTest(StochasticPumpTests("test_stochastic_pdf"))
286
286
 
287
287
  # suite.addTest(StochasticPumpTests("test_save_load_nominalapproach"))
288
288
  # suite.addTest(StochasticPumpTests("test_save_load_nominalapproach_indiv"))
@@ -292,6 +292,6 @@ if __name__ == '__main__':
292
292
  # runner = unittest.TextTestRunner()
293
293
  # runner.run(suite_for_plots(StochasticPumpTests))
294
294
 
295
- # runner = unittest.TextTestRunner()
296
- # runner.run(suite_for_plots(StochasticPumpTests, True))
295
+ runner = unittest.TextTestRunner()
296
+ runner.run(suite_for_plots(StochasticPumpTests, True))
297
297
  unittest.main()
@@ -489,7 +489,7 @@ class PlanPathState(State):
489
489
 
490
490
  u_self: np.array = np.array([0.0, 0.0])
491
491
  u_lin: np.array = np.array([0.0, 0.0])
492
- u_lin_dev: np.array = np.array([0.0, 0.0])
492
+ u_lin_dev: np.array = np.array([0.0, 0.0])
493
493
  rdiff: float = 0.0
494
494
  vel_adj: float = 1.0
495
495
 
@@ -647,7 +647,7 @@ class DriveMode(Mode):
647
647
  self.init_n_faultstates(franges, phases=ph)
648
648
  if "range" in self.mode_args:
649
649
  franges = {"friction": {*np.linspace(0.0, 20, 10)},
650
- "transfer": {*np.linspace(1.0, 0.0, 10)},
650
+ "transfer": {*np.linspace(1.0, 0.0, 10)},
651
651
  "drift": {*np.linspace(-0.5, 0.5, 10)}}
652
652
  if "all" in self.mode_args:
653
653
  self.init_n_faultstates(franges, phases=ph, n="all")
@@ -668,7 +668,7 @@ class DriveMode(Mode):
668
668
 
669
669
  def add_n_modes(self, ph):
670
670
  franges = {"friction": {*np.linspace(0.0, 20, 10)},
671
- "transfer": {*np.linspace(1.0, 0.0, 10)},
671
+ "transfer": {*np.linspace(1.0, 0.0, 10)},
672
672
  "drift": {*np.linspace(-0.5, 0.5, 10)}}
673
673
  self.init_n_faultstates(franges, n=self.mode_args, phases=ph)
674
674
 
@@ -149,8 +149,8 @@ class GuideLiquidOut(GuideLiquid):
149
149
 
150
150
 
151
151
  class StoreLiquidState(State):
152
- level: float = 10.0
153
- net_flow: float = 0.0
152
+ level: float = 10.0
153
+ net_flow: float = 0.0
154
154
 
155
155
 
156
156
  class StoreLiquidMode(Mode):
@@ -419,11 +419,15 @@ if __name__ == '__main__':
419
419
  import fmdtools.sim.propagate as propagate
420
420
  from fmdtools.sim.sample import FaultDomain, FaultSample
421
421
 
422
- mdl = Tank()
422
+ mdl = Tank(track='all')
423
423
 
424
424
  endclass, mdlhist = propagate.one_fault(mdl, 'human', 'look_not_visible', time=2,
425
425
  staged=True)
426
426
 
427
+ from fmdtools.define.architecture.function import FunctionArchitectureGraph
428
+ mg = FunctionArchitectureGraph(mdl)
429
+ fig, ax = mg.draw_from(10, mdlhist)
430
+
427
431
  # nominal run
428
432
  endresults, mdlhist = propagate.nominal(mdl, desired_result=['endclass', 'graph'])
429
433
  mdlhist.plot_line("fxns.store_water.s.level")
@@ -25,7 +25,7 @@ CONDITIONS OF ANY KIND, either express or implied. See the License for the
25
25
  specific language governing permissions and limitations under the License.
26
26
  """
27
27
 
28
- from common import default_air_loc, AssetParams, Location, Requests, Environment
28
+ from common import AssetParams, Location, Requests, Environment
29
29
 
30
30
  from fmdtools.define.container.state import State
31
31
  from fmdtools.define.container.mode import Mode
@@ -33,7 +33,6 @@ from fmdtools.define.container.time import Time
33
33
  from fmdtools.define.block.function import Function
34
34
 
35
35
  from shapely.geometry import Point, Polygon
36
- from shapely.ops import nearest_points
37
36
  import numpy as np
38
37
 
39
38
 
@@ -73,7 +72,7 @@ class Asset(Function):
73
72
  self.perc_requests.s.put(asset_req="land")
74
73
  atc_requests.s.assign(self.perc_requests.s, as_copy=True)
75
74
 
76
- self.perc_requests.update("atc", "local", "asset_req")
75
+ self.perc_requests.update("asset_req", to_update="atc", to_get="local",)
77
76
 
78
77
  self.perc_location = self.location.create_local("percieved", s=self.location.s)
79
78
 
@@ -189,7 +188,7 @@ class Asset(Function):
189
188
  self.perc_requests.s.put(asset_req="none")
190
189
  def send_perception(self):
191
190
  self.perc_location.s.assign(self.location.s)
192
- self.perc_requests.send('atc', 'local', 'asset_req')
191
+ self.perc_requests.send('atc', 'asset_req')
193
192
  def determine_visioncov(self, xd, yd):
194
193
  """
195
194
  Creates the polygon corresponding to the asset's vision cone.
@@ -265,7 +264,7 @@ class Asset(Function):
265
264
  colassets[i] = local_pos.distance(assetpos)
266
265
  if len(colassets) > 0:
267
266
  asset = min(colassets, key=colassets.get)
268
- assetloc = getattr(self.location.glob, asset)
267
+ assetloc = getattr(self.location.glob, asset)
269
268
  distance = colassets[asset]
270
269
  if in_vision and assetloc:
271
270
  self.closest_location.s.assign(assetloc.s)
@@ -823,7 +823,7 @@ def plot_tstep(mdl, mdlhist, t, fxnattr="", locattr="", markersize=10,
823
823
  if fxnattr:
824
824
  try:
825
825
  atthist = mdlhist.fxns.get(f + "." + fxnattr)
826
- except AttributeError:
826
+ except Exception or AttributeError:
827
827
  atthist = None
828
828
  if (not atthist is None) and len(atthist) > 0:
829
829
  if fxnattr == "s.visioncov" and atthist[t]: