context: using System;
  using MicrosoftResearch.Infer;
  using MicrosoftResearch.Infer.Distributions;
  using MicrosoftResearch.Infer.Collections;
  using MicrosoftResearch.Infer.Factors;
  
  namespace MicrosoftResearch.Infer.Models.User
  {
  	/// <summary>
  	/// Class for performing inference in model 'Model' using algorithm 'ExpectationPropagation'.
  	/// </summary>
  	/// <remarks>
  	/// The easiest way to use this class is to wrap an instance in a CompiledAlgorithm object and use
  	/// the methods on CompiledAlgorithm to set parameters and execute inference.
  	/// 
  	/// If you instead wish to use this class directly, you must perform the following steps:
  	/// 1) Create an instance of the class
  	/// 2) Set the value of any externally-set fields e.g. data, priors
  	/// 3) Call the Reset() method
  	/// 4) Call the Initialise() method once
  	/// 5) Call the Update() method multiple times  - each call performs one iteration of inference
  	/// 6) Use the XXXMarginal() methods to retrieve posterior marginals for different variables.
  	/// 
  	/// Generated by Infer.NET 2.3 beta 4 at 19:26 on 29 May 2010.
  	/// </remarks>
  	public class Model5_EP : IIterativeProcess
  	{
  		#region Fields
  		// Messages from uses of 'vbool4'
  		public Bernoulli[] vbool4_uses_B;
  		// The constant 'vBernoulli12'
  		public Bernoulli vBernoulli12;
  		// Message from definition of 'vbool4'
  		public Bernoulli vbool4_F;
  		// Messages from uses of 'vbool48'
  		public Bernoulli[] vbool48_uses_B;
  		// The constant 'vBernoulli56'
  		public Bernoulli vBernoulli56;
  		// Message from definition of 'vbool48'
  		public Bernoulli vbool48_F;
  		// Messages from uses of 'vbool290'
  		public Bernoulli[] vbool290_uses_B;
  		// Message from definition of 'vbool290'
  		public Bernoulli vbool290_F;
  		// Messages from uses of 'vbool56'
  		public Bernoulli[] vbool56_uses_B;
  		// The constant 'vBernoulli64'
  		public Bernoulli vBernoulli64;
  		// Message from definition of 'vbool56'
  		public Bernoulli vbool56_F;
  		// Messages from uses of 'vbool306'
  		public Bernoulli[] vbool306_uses_B;
  		// Message from definition of 'vbool306'
  		public Bernoulli vbool306_F;
  		// Messages from uses of 'vbool74'
  		public Bernoulli[] vbool74_uses_B;
  		// The constant 'vBernoulli82'
  		public Bernoulli vBernoulli82;
  		// Message from definition of 'vbool74'
  		public Bernoulli vbool74_F;
  		// Messages from uses of 'vbool314'
  		public Bernoulli[] vbool314_uses_B;
  		// Message from definition of 'vbool314'
  		public Bernoulli vbool314_F;
  		// Messages from uses of 'vbool126'
  		public Bernoulli[] vbool126_uses_B;
  		// The constant 'vBernoulli134'
  		public Bernoulli vBernoulli134;
  		// Message from definition of 'vbool126'
  		public Bernoulli vbool126_F;
  		// Messages from uses of 'vbool322'
  		public Bernoulli[] vbool322_uses_B;
  		// Message from definition of 'vbool322'
  		public Bernoulli vbool322_F;
  		// Messages from uses of 'vbool82'
  		public Bernoulli[] vbool82_uses_B;
  		// The constant 'vBernoulli90'
  		public Bernoulli vBernoulli90;
  		// Message from definition of 'vbool82'
  		public Bernoulli vbool82_F;
  		// Messages from uses of 'vbool330'
  		public Bernoulli[] vbool330_uses_B;
  		// Message from definition of 'vbool330'
  		public Bernoulli vbool330_F;
  		// Messages from uses of 'vbool134'
  		public Bernoulli[] vbool134_uses_B;
  		// The constant 'vBernoulli142'
  		public Bernoulli vBernoulli142;
  		// Message from definition of 'vbool134'
  		public Bernoulli vbool134_F;
  		// Messages from uses of 'vbool354'
  		public Bernoulli[] vbool354_uses_B;
  		// Message from definition of 'vbool354'
  		public Bernoulli vbool354_F;
  		// Messages from uses of 'vbool147'
  		public Bernoulli[] vbool147_uses_B;
  		// The constant 'vBernoulli155'
  		public Bernoulli vBernoulli155;
  		// Message from definition of 'vbool147'
  		public Bernoulli vbool147_F;
  		// Messages from uses of 'vbool462'
  		public Bernoulli[] vbool462_uses_B;
  		// Message from definition of 'vbool462'
  		public Bernoulli vbool462_F;
  		// Messages from uses of 'vbool118'
  		public Bernoulli[] vbool118_uses_B;
  		// The constant 'vBernoulli126'
  		public Bernoulli vBernoulli126;
  		// Message from definition of 'vbool118'
  		public Bernoulli vbool118_F;
  		// Messages from uses of 'vbool346'
  		public Bernoulli[] vbool346_uses_B;
  		// Message from definition of 'vbool346'
  		public Bernoulli vbool346_F;
  		// Messages from uses of 'vbool22'
  		public Bernoulli[] vbool22_uses_B;
  		// The constant 'vBernoulli30'
  		public Bernoulli vBernoulli30;
  		// Message from definition of 'vbool22'
  		public Bernoulli vbool22_F;
  		// Messages from uses of 'vbool362'
  		public Bernoulli[] vbool362_uses_B;
  		// Message from definition of 'vbool362'
  		public Bernoulli vbool362_F;
  		// Messages from uses of 'vbool165'
  		public Bernoulli[] vbool165_uses_B;
  		// The constant 'vBernoulli173'
  		public Bernoulli vBernoulli173;
  		// Message from definition of 'vbool165'
  		public Bernoulli vbool165_F;
  		// Messages from uses of 'vbool427'
  		public Bernoulli[] vbool427_uses_B;
  		// Message from definition of 'vbool427'
  		public Bernoulli vbool427_F;
  		// Messages from uses of 'vbool95'
  		public Bernoulli[] vbool95_uses_B;
  		// The constant 'vBernoulli103'
  		public Bernoulli vBernoulli103;
  		// Message from definition of 'vbool95'
  		public Bernoulli vbool95_F;
  		// Messages from uses of 'vbool338'
  		public Bernoulli[] vbool338_uses_B;
  		// Message from definition of 'vbool338'
  		public Bernoulli vbool338_F;
  		// Messages from uses of 'vbool30'
  		public Bernoulli[] vbool30_uses_B;
  		// The constant 'vBernoulli38'
  		public Bernoulli vBernoulli38;
  		// Message from definition of 'vbool30'
  		public Bernoulli vbool30_F;
  		// Messages from uses of 'vbool298'
  		public Bernoulli[] vbool298_uses_B;
  		// Message from definition of 'vbool298'
  		public Bernoulli vbool298_F;
  		// Messages from uses of 'vbool173'
  		public Bernoulli[] vbool173_uses_B;
  		// The constant 'vBernoulli181'
  		public Bernoulli vBernoulli181;
  		// Message from definition of 'vbool173'
  		public Bernoulli vbool173_F;
  		// Messages from uses of 'vbool435'
  		public Bernoulli[] vbool435_uses_B;
  		// Message from definition of 'vbool435'
  		public Bernoulli vbool435_F;
  		// Messages from uses of 'vbool461'
  		public Bernoulli[] vbool461_uses_B;
  		// Message from definition of 'vbool461'
  		public Bernoulli vbool461_F;
  		// Message to definition of 'vbool290'
  		public Bernoulli vbool290_B;
  		// Messages to uses of 'vbool48'
  		public Bernoulli[] vbool48_uses_F;
  		// Messages to uses of 'vbool4'
  		public Bernoulli[] vbool4_uses_F;
  		// Message to definition of 'vbool306'
  		public Bernoulli vbool306_B;
  		// Messages to uses of 'vbool56'
  		public Bernoulli[] vbool56_uses_F;
  		// The constant 'vBernoulli5'
  		public Bernoulli vBernoulli5;
  		// Message to definition of 'vbool314'
  		public Bernoulli vbool314_B;
  		// Messages to uses of 'vbool74'
  		public Bernoulli[] vbool74_uses_F;
  		// Message to definition of 'vbool322'
  		public Bernoulli vbool322_B;
  		// Messages to uses of 'vbool126'
  		public Bernoulli[] vbool126_uses_F;
  		// Message to definition of 'vbool330'
  		public Bernoulli vbool330_B;
  		// Messages to uses of 'vbool82'
  		public Bernoulli[] vbool82_uses_F;
  		// Message to definition of 'vbool354'
  		public Bernoulli vbool354_B;
  		// Messages to uses of 'vbool134'
  		public Bernoulli[] vbool134_uses_F;
  		// Message to definition of 'vbool462'
  		public Bernoulli vbool462_B;
  		// Messages to uses of 'vbool147'
  		public Bernoulli[] vbool147_uses_F;
  		// Message to definition of 'vbool346'
  		public Bernoulli vbool346_B;
  		// Messages to uses of 'vbool118'
  		public Bernoulli[] vbool118_uses_F;
  		// Message to definition of 'vbool362'
  		public Bernoulli vbool362_B;
  		// Messages to uses of 'vbool22'
  		public Bernoulli[] vbool22_uses_F;
  		// Message to definition of 'vbool427'
  		public Bernoulli vbool427_B;
  		// Messages to uses of 'vbool165'
  		public Bernoulli[] vbool165_uses_F;
  		// The constant 'vBernoulli6'
  		public Bernoulli vBernoulli6;
  		// Message to definition of 'vbool338'
  		public Bernoulli vbool338_B;
  		// Messages to uses of 'vbool95'
  		public Bernoulli[] vbool95_uses_F;
  		// Message to definition of 'vbool298'
  		public Bernoulli vbool298_B;
  		// Messages to uses of 'vbool30'
  		public Bernoulli[] vbool30_uses_F;
  		// Message to definition of 'vbool435'
  		public Bernoulli vbool435_B;
  		// Messages to uses of 'vbool173'
  		public Bernoulli[] vbool173_uses_F;
  		// Message to definition of 'vbool461'
  		public Bernoulli vbool461_B;
  		// Message to marginal of 'vbool290'
  		public Bernoulli vbool290_marginal_B;
  		// Message to marginal of 'vbool306'
  		public Bernoulli vbool306_marginal_B;
  		// Message to marginal of 'vbool314'
  		public Bernoulli vbool314_marginal_B;
  		// Message to marginal of 'vbool322'
  		public Bernoulli vbool322_marginal_B;
  		// Message to marginal of 'vbool330'
  		public Bernoulli vbool330_marginal_B;
  		// Message to marginal of 'vbool354'
  		public Bernoulli vbool354_marginal_B;
  		// Message to marginal of 'vbool462'
  		public Bernoulli vbool462_marginal_B;
  		// Message to marginal of 'vbool346'
  		public Bernoulli vbool346_marginal_B;
  		// Message to marginal of 'vbool362'
  		public Bernoulli vbool362_marginal_B;
  		// Message to marginal of 'vbool427'
  		public Bernoulli vbool427_marginal_B;
  		// Message to marginal of 'vbool338'
  		public Bernoulli vbool338_marginal_B;
  		// Message to marginal of 'vbool298'
  		public Bernoulli vbool298_marginal_B;
  		// Message to marginal of 'vbool435'
  		public Bernoulli vbool435_marginal_B;
  		// Message to marginal of 'vbool461'
  		public Bernoulli vbool461_marginal_B;
  		// Message to marginal of 'vbool4'
  		public Bernoulli vbool4_marginal_B;
  		// Message to marginal of 'vbool48'
  		public Bernoulli vbool48_marginal_B;
  		// Message to marginal of 'vbool56'
  		public Bernoulli vbool56_marginal_B;
  		// Message to marginal of 'vbool74'
  		public Bernoulli vbool74_marginal_B;
  		// Message to marginal of 'vbool126'
  		public Bernoulli vbool126_marginal_B;
  		// Message to marginal of 'vbool82'
  		public Bernoulli vbool82_marginal_B;
  		// Message to marginal of 'vbool134'
  		public Bernoulli vbool134_marginal_B;
  		// Message to marginal of 'vbool147'
  		public Bernoulli vbool147_marginal_B;
  		// Message to marginal of 'vbool118'
  		public Bernoulli vbool118_marginal_B;
  		// Message to marginal of 'vbool22'
  		public Bernoulli vbool22_marginal_B;
  		// Message to marginal of 'vbool165'
  		public Bernoulli vbool165_marginal_B;
  		// Message to marginal of 'vbool95'
  		public Bernoulli vbool95_marginal_B;
  		// Message to marginal of 'vbool30'
  		public Bernoulli vbool30_marginal_B;
  		// Message to marginal of 'vbool173'
  		public Bernoulli vbool173_marginal_B;
  		#endregion
  
  		#region Methods
  		/// <summary>
  		/// Configures constant values that will not change during the lifetime of the class.
  		/// </summary>
  		/// <remarks>
  		/// This method should be called once only after the class is instantiated.  In future, it will likely become
  		/// the class constructor.
  		/// </remarks>
  		public void Reset()
  		{
  			// Create array for 'vbool4_uses' backwards messages.
  			this.vbool4_uses_B = new Bernoulli[1];
  			this.vBernoulli12 = new Bernoulli(0.5);
  			for(int _ind0 = 0; _ind0<1; _ind0++)
  			{
  				this.vbool4_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(this.vBernoulli12);
  			}
  			this.vbool4_F = ArrayHelper.MakeUniform<Bernoulli>(vBernoulli12);
  			// Message to 'vbool4' from Random factor
  			this.vbool4_F = UnaryOp<bool>.RandomAverageConditional<Bernoulli>(this.vBernoulli12);
  			// Create array for 'vbool48_uses' backwards messages.
  			this.vbool48_uses_B = new Bernoulli[2];
  			this.vBernoulli56 = new Bernoulli(0.5);
  			for(int _ind0 = 0; _ind0<2; _ind0++)
  			{
  				this.vbool48_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(this.vBernoulli56);
  			}
  			this.vbool48_F = ArrayHelper.MakeUniform<Bernoulli>(vBernoulli56);
  			// Message to 'vbool48' from Random factor
  			this.vbool48_F = UnaryOp<bool>.RandomAverageConditional<Bernoulli>(this.vBernoulli56);
  			// Create array for 'vbool290_uses' backwards messages.
  			this.vbool290_uses_B = new Bernoulli[1];
  			for(int _ind0 = 0; _ind0<1; _ind0++)
  			{
  				this.vbool290_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			}
  			this.vbool290_F = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			// Create array for 'vbool56_uses' backwards messages.
  			this.vbool56_uses_B = new Bernoulli[3];
  			this.vBernoulli64 = new Bernoulli(0.5);
  			for(int _ind0 = 0; _ind0<3; _ind0++)
  			{
  				this.vbool56_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(this.vBernoulli64);
  			}
  			this.vbool56_F = ArrayHelper.MakeUniform<Bernoulli>(vBernoulli64);
  			// Message to 'vbool56' from Random factor
  			this.vbool56_F = UnaryOp<bool>.RandomAverageConditional<Bernoulli>(this.vBernoulli64);
  			// Create array for 'vbool306_uses' backwards messages.
  			this.vbool306_uses_B = new Bernoulli[1];
  			for(int _ind0 = 0; _ind0<1; _ind0++)
  			{
  				this.vbool306_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			}
  			this.vbool306_F = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			// Create array for 'vbool74_uses' backwards messages.
  			this.vbool74_uses_B = new Bernoulli[2];
  			this.vBernoulli82 = new Bernoulli(0.5);
  			for(int _ind0 = 0; _ind0<2; _ind0++)
  			{
  				this.vbool74_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(this.vBernoulli82);
  			}
  			this.vbool74_F = ArrayHelper.MakeUniform<Bernoulli>(vBernoulli82);
  			// Message to 'vbool74' from Random factor
  			this.vbool74_F = UnaryOp<bool>.RandomAverageConditional<Bernoulli>(this.vBernoulli82);
  			// Create array for 'vbool314_uses' backwards messages.
  			this.vbool314_uses_B = new Bernoulli[1];
  			for(int _ind0 = 0; _ind0<1; _ind0++)
  			{
  				this.vbool314_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			}
  			this.vbool314_F = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			// Create array for 'vbool126_uses' backwards messages.
  			this.vbool126_uses_B = new Bernoulli[2];
  			this.vBernoulli134 = new Bernoulli(0.5);
  			for(int _ind0 = 0; _ind0<2; _ind0++)
  			{
  				this.vbool126_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(this.vBernoulli134);
  			}
  			this.vbool126_F = ArrayHelper.MakeUniform<Bernoulli>(vBernoulli134);
  			// Message to 'vbool126' from Random factor
  			this.vbool126_F = UnaryOp<bool>.RandomAverageConditional<Bernoulli>(this.vBernoulli134);
  			// Create array for 'vbool322_uses' backwards messages.
  			this.vbool322_uses_B = new Bernoulli[1];
  			for(int _ind0 = 0; _ind0<1; _ind0++)
  			{
  				this.vbool322_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			}
  			this.vbool322_F = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			// Create array for 'vbool82_uses' backwards messages.
  			this.vbool82_uses_B = new Bernoulli[2];
  			this.vBernoulli90 = new Bernoulli(0.01);
  			for(int _ind0 = 0; _ind0<2; _ind0++)
  			{
  				this.vbool82_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(this.vBernoulli90);
  			}
  			this.vbool82_F = ArrayHelper.MakeUniform<Bernoulli>(vBernoulli90);
  			// Message to 'vbool82' from Random factor
  			this.vbool82_F = UnaryOp<bool>.RandomAverageConditional<Bernoulli>(this.vBernoulli90);
  			// Create array for 'vbool330_uses' backwards messages.
  			this.vbool330_uses_B = new Bernoulli[1];
  			for(int _ind0 = 0; _ind0<1; _ind0++)
  			{
  				this.vbool330_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			}
  			this.vbool330_F = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			// Create array for 'vbool134_uses' backwards messages.
  			this.vbool134_uses_B = new Bernoulli[3];
  			this.vBernoulli142 = new Bernoulli(0.5);
  			for(int _ind0 = 0; _ind0<3; _ind0++)
  			{
  				this.vbool134_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(this.vBernoulli142);
  			}
  			this.vbool134_F = ArrayHelper.MakeUniform<Bernoulli>(vBernoulli142);
  			// Message to 'vbool134' from Random factor
  			this.vbool134_F = UnaryOp<bool>.RandomAverageConditional<Bernoulli>(this.vBernoulli142);
  			// Create array for 'vbool354_uses' backwards messages.
  			this.vbool354_uses_B = new Bernoulli[1];
  			for(int _ind0 = 0; _ind0<1; _ind0++)
  			{
  				this.vbool354_uses_B[_ind0] = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			}
  			this.vbool354_F = ArrayHelper.MakeUniform<Bernoulli>(new Bernoulli());
  			// Create array for 'vbool147_uses' backwards messages.
  			this.vbool147_uses_B = new Bernoulli[2];
  			this.vBernoulli155 = new Bernoulli(0.01);
  
gt: 			for(int _ind0 = 0; _ind0<2; _ind0++)