Input:
  
Output:
    
(1) for all do
(2) if then
(3)  
(4) end if
(5) end for
(6) Composition Model = PM
(7) while Last iteration change Composition Model do
(8)  for all do
(9)  for all do
(10)   if then
(11)    
(12)    
(13)      end if
(14)   end for
(15) end for
(16) end while
(17) return Composition Model
Algorithm 2: Scene-based service composition.