-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server gotowy, domyslnie juz malo zmian w C#, 0 w interfejsie
- Loading branch information
Showing
26 changed files
with
3,136 additions
and
21,588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16,843 changes: 117 additions & 16,726 deletions
16,843
server-predictor-tests/server-predictor-tests/bin/Debug/GeneratedSource/Model0_Gibbs.cs
Large diffs are not rendered by default.
Oops, something went wrong.
258 changes: 258 additions & 0 deletions
258
server-predictor-tests/server-predictor-tests/bin/Debug/GeneratedSource/Model10_Gibbs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
using System; | ||
using MicrosoftResearch.Infer; | ||
using MicrosoftResearch.Infer.Maths; | ||
using MicrosoftResearch.Infer.Distributions; | ||
using MicrosoftResearch.Infer.Collections; | ||
using MicrosoftResearch.Infer.Factors; | ||
using System.Collections.Generic; | ||
|
||
namespace MicrosoftResearch.Infer.Models.User | ||
{ | ||
/// <summary> | ||
/// Generated algorithm for performing inference | ||
/// </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 Execute(numberOfIterations) method | ||
/// 4) Use the XXXMarginal() methods to retrieve posterior marginals for different variables. | ||
/// | ||
/// Generated by Infer.NET 2.5 at 04:18 on 21 maja 2013. | ||
/// </remarks> | ||
public partial class Model10_Gibbs : IGeneratedAlgorithm | ||
{ | ||
#region Fields | ||
/// <summary>Field backing the NumberOfIterationsDone property</summary> | ||
private int numberOfIterationsDone; | ||
/// <summary>Field backing the vVector11 property</summary> | ||
private Vector VVector11; | ||
/// <summary>The number of iterations last computed by Changed_vVector11. Set this to zero to force re-execution of Changed_vVector11</summary> | ||
public int Changed_vVector11_iterationsDone; | ||
/// <summary>The number of iterations last computed by Changed_vVector11_Init_numberOfIterationsDecreased. Set this to zero to force re-execution of Changed_vVector11_Init_numberOfIterationsDecreased</summary> | ||
public int Changed_vVector11_Init_numberOfIterationsDecreased_iterationsDone; | ||
/// <summary>True if Changed_vVector11_Init_numberOfIterationsDecreased has performed initialisation. Set this to false to force re-execution of Changed_vVector11_Init_numberOfIterationsDecreased</summary> | ||
public bool Changed_vVector11_Init_numberOfIterationsDecreased_isInitialised; | ||
/// <summary>The number of iterations last computed by Changed_numberOfIterationsDecreased_vVector11. Set this to zero to force re-execution of Changed_numberOfIterationsDecreased_vVector11</summary> | ||
public int Changed_numberOfIterationsDecreased_vVector11_iterationsDone; | ||
/// <summary>Message to marginal of 'vint23'</summary> | ||
public GibbsMarginal<Discrete,int> vint23_marginal_F; | ||
public PointMass<Vector> vVector11_marginal; | ||
#endregion | ||
|
||
#region Properties | ||
/// <summary>The number of iterations done from the initial state</summary> | ||
public int NumberOfIterationsDone | ||
{ get { | ||
return this.numberOfIterationsDone; | ||
} | ||
} | ||
|
||
/// <summary>The externally-specified value of 'vVector11'</summary> | ||
public Vector vVector11 | ||
{ get { | ||
return this.VVector11; | ||
} | ||
set { | ||
this.VVector11 = value; | ||
this.numberOfIterationsDone = 0; | ||
this.Changed_vVector11_Init_numberOfIterationsDecreased_iterationsDone = 0; | ||
this.Changed_numberOfIterationsDecreased_vVector11_iterationsDone = 0; | ||
this.Changed_vVector11_iterationsDone = 0; | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Methods | ||
/// <summary>Get the observed value of the specified variable.</summary> | ||
/// <param name="variableName">Variable name</param> | ||
public object GetObservedValue(string variableName) | ||
{ | ||
if (variableName=="vVector11") { | ||
return this.vVector11; | ||
} | ||
throw new ArgumentException("Not an observed variable name: "+variableName); | ||
} | ||
|
||
/// <summary>Set the observed value of the specified variable.</summary> | ||
/// <param name="variableName">Variable name</param> | ||
/// <param name="value">Observed value</param> | ||
public void SetObservedValue(string variableName, object value) | ||
{ | ||
if (variableName=="vVector11") { | ||
this.vVector11 = (Vector)value; | ||
return ; | ||
} | ||
throw new ArgumentException("Not an observed variable name: "+variableName); | ||
} | ||
|
||
/// <summary>The marginal distribution of the specified variable.</summary> | ||
/// <param name="variableName">Variable name</param> | ||
public object Marginal(string variableName) | ||
{ | ||
if (variableName=="vint23") { | ||
return this.Vint23Marginal(); | ||
} | ||
if (variableName=="vVector11") { | ||
return this.VVector11Marginal(); | ||
} | ||
throw new ArgumentException("This class was not built to infer "+variableName); | ||
} | ||
|
||
public T Marginal<T>(string variableName) | ||
{ | ||
return Distribution.ChangeType<T>(this.Marginal(variableName)); | ||
} | ||
|
||
/// <summary>The query-specific marginal distribution of the specified variable.</summary> | ||
/// <param name="variableName">Variable name</param> | ||
/// <param name="query">QueryType name. For example, GibbsSampling answers 'Marginal', 'Samples', and 'Conditionals' queries</param> | ||
public object Marginal(string variableName, string query) | ||
{ | ||
if (query=="Marginal") { | ||
return this.Marginal(variableName); | ||
} | ||
if ((variableName=="vint23")&&(query=="Samples")) { | ||
return this.Vint23Samples(); | ||
} | ||
throw new ArgumentException(((("This class was not built to infer \'"+variableName)+"\' with query \'")+query)+"\'"); | ||
} | ||
|
||
public T Marginal<T>(string variableName, string query) | ||
{ | ||
return Distribution.ChangeType<T>(this.Marginal(variableName, query)); | ||
} | ||
|
||
/// <summary>Update all marginals, by iterating message passing the given number of times</summary> | ||
/// <param name="numberOfIterations">The number of times to iterate each loop</param> | ||
/// <param name="initialise">If true, messages that initialise loops are reset when observed values change</param> | ||
private void Execute(int numberOfIterations, bool initialise) | ||
{ | ||
if (numberOfIterations<this.Changed_numberOfIterationsDecreased_vVector11_iterationsDone) { | ||
this.Changed_vVector11_Init_numberOfIterationsDecreased_isInitialised = false; | ||
this.Changed_numberOfIterationsDecreased_vVector11_iterationsDone = 0; | ||
} | ||
this.Changed_vVector11_Init_numberOfIterationsDecreased(initialise); | ||
this.Changed_numberOfIterationsDecreased_vVector11(numberOfIterations); | ||
this.Changed_vVector11(); | ||
this.numberOfIterationsDone = numberOfIterations; | ||
} | ||
|
||
public void Execute(int numberOfIterations) | ||
{ | ||
this.Execute(numberOfIterations, true); | ||
} | ||
|
||
public void Update(int additionalIterations) | ||
{ | ||
this.Execute(this.numberOfIterationsDone+additionalIterations, false); | ||
} | ||
|
||
private void OnProgressChanged(ProgressChangedEventArgs e) | ||
{ | ||
// Make a temporary copy of the event to avoid a race condition | ||
// if the last subscriber unsubscribes immediately after the null check and before the event is raised. | ||
EventHandler<ProgressChangedEventArgs> handler = this.ProgressChanged; | ||
if (handler!=null) { | ||
handler(this, e); | ||
} | ||
} | ||
|
||
/// <summary>Reset all messages to their initial values. Sets NumberOfIterationsDone to 0.</summary> | ||
public void Reset() | ||
{ | ||
this.Execute(0); | ||
} | ||
|
||
/// <summary>Computations that depend on the observed value of vVector11 and must reset on changes to numberOfIterationsDecreased</summary> | ||
/// <param name="initialise">If true, reset messages that initialise loops</param> | ||
public void Changed_vVector11_Init_numberOfIterationsDecreased(bool initialise) | ||
{ | ||
if ((this.Changed_vVector11_Init_numberOfIterationsDecreased_iterationsDone==1)&&((!initialise)||this.Changed_vVector11_Init_numberOfIterationsDecreased_isInitialised)) { | ||
return ; | ||
} | ||
this.vint23_marginal_F = new GibbsMarginal<Discrete,int>(Discrete.Uniform(this.VVector11.Count), 100, 5, true, true, false); | ||
this.Changed_vVector11_Init_numberOfIterationsDecreased_iterationsDone = 1; | ||
this.Changed_vVector11_Init_numberOfIterationsDecreased_isInitialised = true; | ||
this.Changed_numberOfIterationsDecreased_vVector11_iterationsDone = 0; | ||
} | ||
|
||
/// <summary>Computations that depend on the observed value of numberOfIterationsDecreased and vVector11</summary> | ||
/// <param name="numberOfIterations">The number of times to iterate each loop</param> | ||
public void Changed_numberOfIterationsDecreased_vVector11(int numberOfIterations) | ||
{ | ||
if (this.Changed_numberOfIterationsDecreased_vVector11_iterationsDone==numberOfIterations) { | ||
return ; | ||
} | ||
// Messages from uses of 'vint23' | ||
Discrete[] vint23_uses_B = default(Discrete[]); | ||
// Create array for 'vint23_uses' Backwards messages. | ||
vint23_uses_B = new Discrete[0]; | ||
// Message from definition of 'vint23' | ||
Discrete vint23_F = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.VVector11.Count)); | ||
// Message to 'vint23' from Discrete factor | ||
vint23_F = DiscreteFromDirichletOp.SampleAverageConditional(this.VVector11, vint23_F); | ||
for(int iteration = this.Changed_numberOfIterationsDecreased_vVector11_iterationsDone; iteration<numberOfIterations; iteration++) { | ||
// Message to 'vint23_marginal' from UsesEqualDef factor | ||
this.vint23_marginal_F = UsesEqualDefGibbsOp<int>.MarginalGibbs<Discrete>(vint23_uses_B, vint23_F, this.vint23_marginal_F); | ||
this.OnProgressChanged(new ProgressChangedEventArgs(iteration)); | ||
} | ||
// Message to 'vint23_marginal' from UsesEqualDef factor | ||
this.vint23_marginal_F = UsesEqualDefGibbsOp<int>.MarginalGibbs<Discrete>(vint23_uses_B, vint23_F, this.vint23_marginal_F); | ||
this.Changed_numberOfIterationsDecreased_vVector11_iterationsDone = numberOfIterations; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the Samples for 'vint23' given by the current state of the | ||
/// message passing algorithm. | ||
/// </summary> | ||
/// <returns>The Samples</returns> | ||
public IList<int> Vint23Samples() | ||
{ | ||
return this.vint23_marginal_F.Samples; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the Marginal for 'vint23' given by the current state of the | ||
/// message passing algorithm. | ||
/// </summary> | ||
/// <returns>The Marginal</returns> | ||
public Discrete Vint23Marginal() | ||
{ | ||
return this.vint23_marginal_F.Distribution; | ||
} | ||
|
||
/// <summary>Computations that depend on the observed value of vVector11</summary> | ||
public void Changed_vVector11() | ||
{ | ||
if (this.Changed_vVector11_iterationsDone==1) { | ||
return ; | ||
} | ||
this.vVector11_marginal = new PointMass<Vector>(this.VVector11); | ||
this.Changed_vVector11_iterationsDone = 1; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the marginal distribution for 'vVector11' given by the current state of the | ||
/// message passing algorithm. | ||
/// </summary> | ||
/// <returns>The marginal distribution</returns> | ||
public PointMass<Vector> VVector11Marginal() | ||
{ | ||
return this.vVector11_marginal; | ||
} | ||
|
||
#endregion | ||
|
||
#region Events | ||
/// <summary>Event that is fired when the progress of inference changes, typically at the end of one iteration of the inference algorithm.</summary> | ||
public event EventHandler<ProgressChangedEventArgs> ProgressChanged; | ||
#endregion | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.