Lindo Systems

! Optimal redundancy in a series/parallel system;
! A System consists of a set of stages/subsystems.
The System fails if and only if one or more stages/subsystem fails.
A stage consists of a set of components.
A subsystem fails if and only if every component fails;
! Keywords: Reliability, Series-parallel, Redundancy;
Sets:
 stage: p, c, n, psnof;
endsets
data:
! The stages in the series system;
 stage = suba1  suba2 suba3;
! The cost of each component at each stage;
      c =  150    220   100;
! The probability of failure by a single
 component at each stage;
      p =  .01   .02   .005;
!The budget limit;
     budget = 800; 
enddata

! For extremely small or large numbers is is numerically
   better to work with logarithms;
! Maximize the log of probability of no failure;
  max = lognofail;
       pnofail = @exp(lognofail); ! Actual Prob(No systems failure);

  @FOR( stage(i):
 ! Prob( at least one component works) =
      1 - Prob( all fail);
    psnof(i) = 1 - p(i)^n(i);
 ! We need at least one component in each stage;
    n(i) >= 1;
 ! And it must be an integer;
    @gin(n(i));
     );

 ! Prob( all stages successful) = psnof(1)*psnof(2)*...,
  so log(Prob( all stages successful)) = 
    @log(psnof(1))+@log(psnof(2))+ ...;
 ! log of no system failure...;
  @free( lognofail);
  lognofail = @sum(stage(i): @log(psnof(i)));

 ! And we must be within budget;
  @sum(stage(i): c(i)*n(i)) <= budget;