Skip to content

Commit

Permalink
Example yml
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeda committed Jan 24, 2025
1 parent 3c7db2e commit 46a25e5
Showing 1 changed file with 194 additions and 5 deletions.
199 changes: 194 additions & 5 deletions src/semeio/fmudesign/probabilit_idea.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,8 @@ A high-level method such as `exp.report()` can generate a default document with
- **Output Formats**: HTML, PDF, Markdown.
- **Customization**: Possibly via YAML or similar config files to tailor the final report.

---

With these updates, **Probabilit** retains *lazy evaluation* (generating samples on demand) but drops any notion of caching the generated samples. Each new request for results triggers fresh sampling (unless the user explicitly decides otherwise).
"""

```python
import pytest
import polars as pl
from probabilit import Probabilit
Expand Down Expand Up @@ -319,4 +316,196 @@ def test_comprehensive_project_analysis():

assert report is not None
exp.save("comprehensive_risk_model.yml")

```

## Example of yml

# comprehensive_risk_model.yml

```yml
metadata:
name: "Comprehensive Project Risk Analysis"
description: "Complete risk analysis including direct costs, quality impacts, schedule effects, market variations, and risk adjustments"
created_at: "2024-03-20T10:00:00Z"
version: "1.0"
sample_size: 10000
sampling_method: "latin_hypercube"

variables:
# Direct Material and Equipment
Steel_Cost:
type: "Normal"
specification: "percentiles"
parameters:
p10: 800000
p90: 1200000

Maintenance_Cost:
type: "LogNormal"
specification: "percentiles"
parameters:
p10: 50000
p90: 150000

Daily_Fuel_Cost:
type: "Uniform"
parameters:
min_val: 1000
max_val: 1500

Equipment_Lifetime:
type: "Weibull"
parameters:
shape: 2.5
scale: 5000

# Labor and Productivity
Productivity_Factor:
type: "Triangular"
specification: "percentiles"
parameters:
p10: 85
p50: 100
p90: 110

Daily_Worker_Absences:
type: "DiscreteUniform"
parameters:
min_val: 0
max_val: 5

# Quality and Inspection
Quality_Score:
type: "Beta"
parameters:
alpha: 5
beta: 2

Weekly_Quality_Issues:
type: "Poisson"
parameters:
lambda_param: 3.5

Successful_Inspections:
type: "Binomial"
parameters:
n: 10
p: 0.8

Certification_Attempts:
type: "NegativeBinomial"
parameters:
r: 3
p: 0.6

# Schedule and Timing
Schedule_Duration:
type: "BetaPERT"
parameters:
min_val: 8
most_likely: 10
max_val: 14

Repair_Time:
type: "Gamma"
parameters:
shape: 2
scale: 1.5

Time_Between_Failures:
type: "Exponential"
parameters:
rate: 0.1

Price_Variation:
type: "StudentT"
parameters:
df: 5

Overhead_Rate:
type: "KDE"
data: [0.12, 0.15, 0.14, 0.13, 0.16, 0.15, 0.14]

correlations:
cost_variables:
method: "iman-conover"
variables:
- Steel_Cost
- Maintenance_Cost
- Daily_Fuel_Cost
matrix:
Steel_Cost: [1.0, 0.6, 0.4]
Maintenance_Cost: [0.6, 1.0, 0.3]
Daily_Fuel_Cost: [0.4, 0.3, 1.0]

productivity_variables:
method: "iman-conover"
variables:
- Productivity_Factor
- Daily_Worker_Absences
matrix:
Productivity_Factor: [1.0, -0.4]
Daily_Worker_Absences: [-0.4, 1.0]

quality_schedule_variables:
method: "iman-conover"
variables:
- Quality_Score
- Schedule_Duration
- Repair_Time
matrix:
Quality_Score: [1.0, -0.5, -0.3]
Schedule_Duration: [-0.5, 1.0, 0.4]
Repair_Time: [-0.3, 0.4, 1.0]

expressions:
equipment_replacement_cost:
formula: "100000 * (10000 / Equipment_Lifetime)"

rework_cost:
formula: "Weekly_Quality_Issues * 5000 * (1 - Quality_Score)"

inspection_cost:
formula: "(10 - Successful_Inspections) * 2000"

certification_cost:
formula: "Certification_Attempts * 10000"

downtime_cost:
formula: "(Repair_Time / Time_Between_Failures) * Schedule_Duration * 5000"

schedule_delay_cost:
formula: "Schedule_Duration * Daily_Fuel_Cost"

market_adjusted_cost:
formula: "(1 + Price_Variation * 0.1)"

direct_cost:
formula: "(Steel_Cost + Maintenance_Cost + equipment_replacement_cost + Productivity_Factor * 1000000 * (1 + Daily_Worker_Absences * 0.01)) * market_adjusted_cost"

indirect_cost:
formula: "rework_cost + inspection_cost + certification_cost + downtime_cost + schedule_delay_cost"

total_cost:
formula: "(direct_cost + indirect_cost) * (1 + Overhead_Rate)"

outputs:
plots:
- type: "histogram"
variable: "total_cost"
title: "Total Project Cost Distribution"
- type: "tornado"
variable: "total_cost"
title: "Sensitivity Analysis"

report:
format: "html"
title: "Comprehensive Project Risk Analysis"
description: |
Complete risk analysis with all variables contributing to final cost:
- Direct costs (materials, equipment, labor)
- Quality and inspection impacts
- Schedule effects
- Market variations
- Risk adjustments
```

0 comments on commit 46a25e5

Please sign in to comment.