echo Example 2:
* Example 2: A Reliability Block diagram 
* Used to compute Steady-state availability

block parsys
* a component has attached to it, its steady-state unavailability
* this is known to be failure rate divided by the sum of the failure rate
* and the repair rate. We assume all components have their own repair facility
comp unit prob(lam/(lam+mu))
* the system as whole has n s-independent units; only one required to
* function for the system to be up
kofn sys1 1,n,unit
end

bind
lam 0.0001
end

* variable named sysunavail is the  system steady-state unavailability 
var sysunavail sysprob(parsys)
* variable named downtimeis the system downtime in minutes per year
var downtime 8760*sysunavail
* variable named sysavail is the system steady-state availability 
var sysavail 1-sysunavail

* vary the repair rate in the outer loop below
loop i,0.5,2.0,0.5
  bind mu i
* vary the number of units in the inner loop below
  loop j,5,1,-1
    bind n j
* print the values of sysavail, sysunavail and downtime
    expr  sysavail, sysunavail,downtime
  end
end

* Example 2a: A Reliability Block diagram
* Used to compute Steady-state availability
* small difference between Example 2 and 2a is
* that component MTTR and MTTF are specified rather than
* component failure rate and repair rate

block parsysa
* a component has attached to it, its steady-state unavailability
* this is known to be component MTTR divided by the sum of the MTTF
* and MTTR. We assume all components have their own repair facility
comp unit prob(MTTR/(MTTF+MTTR))
* the system as whole has n s-independent units; only one required to
* function for the system to be up
kofn sys1 1,n,unit
end

bind
MTTF 10000
end

* variable named sysunavail is the  system steady-state unavailability
var sysunavaila sysprob(parsysa)
* variable named downtimeis the system downtime in minutes per year
var downtimea 8760*sysunavaila
* variable named sysavail is the system steady-state availability
var sysavaila 1-sysunavaila

* vary the repair rate in the outer loop below
loop i,2.0,0.5,-0.5
  bind MTTR i
* vary the number of units in the inner loop below
  loop j,5,1,-1
    bind n j
* print the values of sysavail, sysunavail and downtime
    expr  sysavaila, sysunavaila,downtimea
  end
end

end

