0
$\begingroup$

Can Mathematica 9 convert a Boolean representation of an RBD to its symbolic algebraic form?

If I have a simple series Reliability Block Diagram made up of 2 components, c1 and c2

bexpr1=And[c1,c2]

and the corresponding symbolic representation for the system would be RS1 = R1*R2

The system I am interested in is more complex and contains 7 components in a 4 path architecture:

path1=And[c1,c2,c5,c7]

path2=And[c1,c3,c5,c7]

path3=And[c1,c3,c6,c7]

path4=And[c1,c4,c6,c7]

bexpr2=Or[path1,path2,path3,path4]

How can the algebraic form of the reliability function be obtained for bexpr2 using Mathematica?

The solution can be seen on page 5 of the PDF file at the following link

http://www.reliasoft.com/newsletter/2Q2000/index.htm

Thank you.

Daniel,

Thank you for your reply but I think it too is not correct and I' m not sure why. See below for a comparision of the two solution methods. Am I mis-interpreting something here ?

Also, I agree that Eq.(3) is undersimplified. Perhaps the author intentionally left it in that form to help show how this problem can be solved manually (pencil & paper).

equation3 = (r1*r4*r6*r7) + (r1*r3*r6*r7) - (r1*r3*r4*r6*r7) + (r1*r2*r3*r4*
r5*r6*r7) + (r1*r3*r4*r5*r6*r7) - (r1*r2*r3*r4*r5*r6*r7) - (r1*r2*r3*r5*
r6*r7) - (r1*r3*r5*r6*r7) + (r1*r2*r3*r5*r6*r7) - (r1*r2*r4*r5*r6*
r7) - (r1*r3*r4*r5*r6*r7) + (r1*r2*r3*r4*r5*r6*r7) + (r1*r2*r5*r7) + (r1*
r3*r5*r7) - (r1*r2*r3*r5*r7) (* Eq.(3) ReliabilityEdge volume 1, Issue 1 *)

r1 r2 r5 r7 + r1 r3 r5 r7 - r1 r2 r3 r5 r7 + r1 r3 r6 r7 + r1 r4 r6 r7 - r1 r3 r4 r6 r7 - r1 r3 r5 r6 r7 - r1 r2 r4 r5 r6 r7 + r1 r2 r3 r4 r5 r6 r7

Original Problem

path1 = And[c1, c2, c5, c7];
path2 = And[c1, c3, c5, c7];
path3 = And[c1, c3, c6, c7];
path4 = And[c1, c4, c6, c7];
bexpr = Or[path1, path2, path3, path4]

(c1 && c2 && c5 && c7) || (c1 && c3 && c5 && c7) || (c1 && c3 && c6 && c7) || (c1 && c4 && c6 && c7)

Ilian' s Solution (1)

dists = Table[{ToExpression["c" ~~ ToString[i]], 
   BernoulliDistribution[ToExpression["r" ~~ ToString[i]]]}, {i, 7}] 

{{c1, BernoulliDistribution[r1]}, {c2, BernoulliDistribution[r2]}, {c3, BernoulliDistribution[r3]}, {c4, BernoulliDistribution[r4]}, {c5, BernoulliDistribution[r5]}, {c6, BernoulliDistribution[r6]}, {c7, BernoulliDistribution[r7]}}

survivalfunction1 = Expand[PDF[ReliabilityDistribution[bexpr, dists], 1]]

r1 r2 r5 r7 + r1 r3 r5 r7 - r1 r2 r3 r5 r7 + r1 r3 r6 r7 + r1 r4 r6 r7 - r1 r3 r4 r6 r7 - r1 r3 r5 r6 r7 - r1 r2 r4 r5 r6 r7 + r1 r2 r3 r4 r5 r6 r7

Simplify[survivalfunction1/
  equation3] (* This show that the results are equivalent *)

1

Daniel' s Solution (2)

bexpr2 = BooleanConvert[bexpr, "ANF"]

(c1 && c2 && c5 && c7) [Xor] (c1 && c3 && c5 && c7) [Xor] (c1 && c3 && c6 && c7) [Xor] (c1 && c4 && c6 && c7) [Xor] (c1 && c2 && c3 && c5 && c7) [Xor] (c1 && c3 && c4 && c6 && c7) [Xor] (c1 && c3 && c5 && c6 && c7) [Xor] (c1 && c2 && c4 && c5 && c6 && c7) [Xor] (c1 && c2 && c3 && c4 && c5 && c6 && c7)

survivalfunction2temp = bexpr2 /. {And -> Times, Xor -> Plus}

c1 c2 c5 c7 + c1 c3 c5 c7 + c1 c2 c3 c5 c7 + c1 c3 c6 c7 + c1 c4 c6 c7 + c1 c3 c4 c6 c7 + c1 c3 c5 c6 c7 + c1 c2 c4 c5 c6 c7 + c1 c2 c3 c4 c5 c6 c7

survivalfunction2stringtemp = ToString[survivalfunction2temp]

"c1 c2 c5 c7 + c1 c3 c5 c7 + c1 c2 c3 c5 c7 + c1 c3 c6 c7 + c1 c4 c6 c7 + c1 \ c3 c4 c6 c7 + c1 c3 c5 c6 c7 + c1 c2 c4 c5 c6 c7 + c1 c2 c3 c4 c5 c6 c7"

survivalfunction2string = 
 StringReplace[survivalfunction2stringtemp, "c" -> "r"]

"r1 r2 r5 r7 + r1 r3 r5 r7 + r1 r2 r3 r5 r7 + r1 r3 r6 r7 + r1 r4 r6 r7 + r1 \ r3 r4 r6 r7 + r1 r3 r5 r6 r7 + r1 r2 r4 r5 r6 r7 + r1 r2 r3 r4 r5 r6 r7"

survivalfunction2 = ToExpression[survivalfunction2string]

r1 r2 r5 r7 + r1 r3 r5 r7 + r1 r2 r3 r5 r7 + r1 r3 r6 r7 + r1 r4 r6 r7 + r1 r3 r4 r6 r7 + r1 r3 r5 r6 r7 + r1 r2 r4 r5 r6 r7 + r1 r2 r3 r4 r5 r6 r7

Simplify[survivalfunction2/
  equation3](* This show that the results are not equivalent *)

(r4 r6 + r2 (1 + r3) r5 (1 + r4 r6) + r3 (r5 + r6 + r4 r6 + r5 r6))/( r4 r6 + r2 (-1 + r3) r5 (-1 + r4 r6) + r3 (r5 + r6 - r4 r6 - r5 r6))

Let' s do a quick numerical sanity check.

r1 = r2 = r3 = r4 = r5 = r6 = r7 = 1;

survivalfunction1  (* This is the correct numerical value *)

1

survivalfunction2  (* This is numerically not possible, must be less than or 
equal to one *)

9

Upon examination of survivalfunction2 I notice there are no negative signs in the algebra . . . not sure why. Also, I apologize here if everything is not formatted with all proper formatting, I'm still unfamiliar with much at StackExchange.


Clay,

Thank you for the reply. I believe there may be a problem with your code as it produces a result that differs from Eq.(3) in the referenced PDF file.

I tested the following code on the system architecture that I posted (associated with Eq.(3) ) and other simpler systems and it appears to accurately produce the algebra for the reliability function.

dists = Table[{ToExpression["c" ~~ ToString[i]], BernoulliDistribution[ToExpression["r" ~~ ToString[i]]]}, {i, 7}];

Expand[PDF[ReliabilityDistribution[bexpr2, dists], 1]]

The above code was produced by Ilian Gachevski in his posting at Wolfram Community. Thanks again for your inputs.

$\endgroup$
4
  • 2
    $\begingroup$ It might be beneficial to point out cross-postings (which are fine, like in this case to WRI community) to avoid duplicated efforts and to help later visitors in search of a solution. $\endgroup$
    – Yves Klett
    Commented Aug 24, 2013 at 6:38
  • $\begingroup$ Possibly my use of Xor is not what is wanted for this problem. Maybe it should be a boolean counting function that gives 1 is exactly one clause is true, else 0. $\endgroup$ Commented Aug 28, 2013 at 14:22
  • 1
    $\begingroup$ Hopefully version 10 (which I understand is in the works) will have this transform as a more native feature. An integrated block diagram editor that can pictorially display the boolean logic would also be helpful for this kind of analysis. $\endgroup$
    – Steve
    Commented Aug 28, 2013 at 21:59
  • $\begingroup$ Malte, thank you for your solution. I think I'll stay with Illian's approach since it's being documented should provide stability into the future. $\endgroup$
    – Steve
    Commented Sep 6, 2013 at 14:04

3 Answers 3

3
$\begingroup$

The most direct way, but undocumented and therefore subject to change in future versions, is to use a Library function:

In: Reliability`Library`StructureFunction[bexpr2]
Out: c1 c3 ((1 - c5) (-1 + c6) - (1 - c2 c5) (-1 + c4 c6)) c7 + c1 (1 + (1 - c2 c5) (-1 + c4 c6)) c7

Use Expand if you would like the simpler structure showing the cutsets in a clearer way:

In: %//Expand
Out: c1 c2 c5 c7 + c1 c3 c5 c7 - c1 c2 c3 c5 c7 + c1 c3 c6 c7 +
    c1 c4 c6 c7 - c1 c3 c4 c6 c7 - c1 c3 c5 c6 c7 - c1 c2 c4 c5 c6 c7 +
    c1 c2 c3 c4 c5 c6 c7

Note: I am one of the developers originally developing reliability functionality in Mathematica

$\endgroup$
2
$\begingroup$

Possibly you want to convert to "algebraic normal form" and, from there, to a boolean algebra expression in terms of plus and times.

path1 = And[c1, c2, c5, c7];
path2 = And[c1, c3, c5, c7];
path3 = And[c1, c3, c6, c7];
path4 = And[c1, c4, c6, c7];
bexpr2 = BooleanConvert[Or[path1, path2, path3, path4], "ANF"]

(* Out[25]= (c1 && c2 && c5 && c7) \[Xor] (c1 && c3 && c5 && 
   c7) \[Xor] (c1 && c3 && c6 && c7) \[Xor] (c1 && c4 && c6 && 
   c7) \[Xor] (c1 && c2 && c3 && c5 && c7) \[Xor] (c1 && c3 && c4 && 
   c6 && c7) \[Xor] (c1 && c3 && c5 && c6 && c7) \[Xor] (c1 && c2 && 
   c4 && c5 && c6 && c7) \[Xor] (c1 && c2 && c3 && c4 && c5 && c6 && 
   c7) *)

bexpr3 = bexpr2 /. {And -> Times, Xor -> Plus}

(* Out[26]= c1 c2 c5 c7 + c1 c3 c5 c7 + c1 c2 c3 c5 c7 + c1 c3 c6 c7 + 
 c1 c4 c6 c7 + c1 c3 c4 c6 c7 + c1 c3 c5 c6 c7 + c1 c2 c4 c5 c6 c7 + 
 c1 c2 c3 c4 c5 c6 c7 *)

By the way, that equation 3 in the PDF is probably undersimplified. You will notice the same terms appearing more than once.

$\endgroup$
0
$\begingroup$

I have not found an inherent translation. For these problems I create the boolean functions:

rOr[list__] := 1 - (Times @@ (1 - # & /@ {list}))
rAnd[list__] := Times[list]

Once you enter the logic you want (using your example)

path1 = And[c1, c2, c5, c7];
path2 = And[c1, c3, c5, c7];
path3 = And[c1, c3, c6, c7];
path4 = And[c1, c4, c6, c7];
bexpr2 = Or[path1, path2, path3, path4]

Which will give the logical expression of the cutsets:

 Out[35]= (c1 && c2 && c5 && c7) || (c1 && c3 && c5 && c7) || (c1 && c3 && c6 && c7) || (c1 && c4 && c6 && c7)

At this point substitute the functions And and Or for the boolean functions. You can expand the expression and define values for the variables at this point.

In[36]:= bexpr2 /. {And -> rAnd, Or -> rOr}
Out[36]= 1 - (1 - c1 c2 c5 c7) (1 - c1 c3 c5 c7) (1 - 
c1 c3 c6 c7) (1 - c1 c4 c6 c7)

In[38]:= bexpr2 /. {And -> rAnd, Or -> rOr} // Expand
Out[38]= c1 c2 c5 c7 + c1 c3 c5 c7 + c1 c3 c6 c7 + c1 c4 c6 c7 -  
c1^2 c2 c3 c5^2 c7^2 - c1^2 c2 c3 c5 c6 c7^2 - c1^2 c3^2 c5 c6 c7^2 -
c1^2 c2 c4 c5 c6 c7^2 - c1^2 c3 c4 c5 c6 c7^2 - 
c1^2 c3 c4 c6^2 c7^2 + c1^3 c2 c3^2 c5^2 c6 c7^3 + 
c1^3 c2 c3 c4 c5^2 c6 c7^3 + c1^3 c2 c3 c4 c5 c6^2 c7^3 + 
c1^3 c3^2 c4 c5 c6^2 c7^3 - c1^4 c2 c3^2 c4 c5^2 c6^2 c7^4

Hope this helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.