* Example 3:
* The next example is from SHARPE86 Users Guide.
* a TMR of TMR model using fault trees
* Each TMR subsytem is allowed to be different, in general

format 8
ftree fcc1(lambda1,lambda2,lambda3)
* to each basic event, we now attach a distribution function,
* its time to failure distribution function; assumed to be exponential
* failure rates are symbolic.
basic A exp(lambda1)
basic B exp(lambda2)
basic C exp(lambda3)
* next two kofn gates have statistically identical inputs
kofn Afail k,n, A
kofn Bfail k,n, B
kofn Cfail k,n, C
*the next kofn gate has statistically distinct inputs
kofn Sysfail ksys,nsys, Afail Bfail Cfail
end

bind
k 2
n 3
ksys 2
nsys 3
lambda1 0.0001
lambda2 0.0001
lambda3 0.0001
end

* can ask for the mean time to system failure
expr mean(fcc1;lambda1,lambda2,lambda3)

* can ask for the variance of the system time to failure
expr variance(fcc1;lambda1,lambda2,lambda3)

* can ask for the coefficient of variation of system time to failure
var coeff ((variance(fcc1;lambda1,lambda2,lambda3))^0.5)/mean(fcc1;lambda1,lambda2,lambda3)
expr coeff

* Next we ask for closed-form (in time variable t) time-to-failure
* distribution function
cdf (fcc1;lambda1,lambda2,lambda3)

* Now we ask for numerical values of system failure probabilities
* at mission times, 10 thru 60 at 10 hour intervals.
eval (fcc1;lambda1,lambda2,lambda3) 10 60 10

* loop construct is now available in sharpe; 
loop i,1,10,1
   bind lambda1 i*.00001
   expr value(100;fcc1;lambda1,lambda2,lambda3)
   * the failure prob of the system is evaluated at time 100
end
end


