locked
Adding a factor (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • julia posted on 08-13-2009 5:13 AM

    Hi

    I am trying to add a factor to infer.net but it seems that I am missing something.

     

    1) In Factor.cs I have added

    public static double MyFactor (double a, double b, double c) { return (a-b)*(a+b-c) ; }

     

    2) I created a file MyFactorVmpOp.cs containing

    namespace MicrosoftResearch.Infer.Factors {

        [ FactorMethod ( typeof(Factor), "MyFactor", typeof(double), typeof(double), typeof(double) ) ]

        public static class MyFactorVmpOp {

            public static Gaussian MyFactorAverageLogarithm( Gaussian A, Gaussian B, Gaussian C ){ };

            public static Gaussian AAverageLogarithm( Gaussian MyFactor, Gaussian B, Gaussian C ){ };

            public static Gaussian BAverageLogarithm( Gaussian MyFactor, Gaussian A, Gaussian C ){ };

            public static Gaussian CAverageLogarithm( Gaussian MyFactor, Gaussian A, Gaussian B ){ };

        }

    }

     

    3) In the file containing the main script, I have added the line

    [assembly: MicrosoftResearch.Infer.Factors.HasMessageFunctions]

     

    4) I call the factor using

    Variable<double> x = Variable<double>.Factor(Factor.MyFactor, x,y,w);

    but at compilation it says 'MicrosoftResearch.Factors.Factor' does not contain a definition for 'MyFactor'

     

    It seems that it doesn't take into account the change in Factor.cs. I have read the help on that subject but there doesn't seem to be anything else to do... any idea?

     

    Thanks, Julia

    Friday, June 3, 2011 5:28 PM

Answers

  • jwinn replied on 12-11-2009 9:01 PM

    There's no need to modify Factor.cs - just create the static factor method 'MyFactor' anywhere in your own code e.g. in a class called MyNewFactors.  Then call it with:

    Variable<double> x = Variable<double>.Factor(MyNewFactors.MyFactor, x,y,w);

    John W.

    Friday, June 3, 2011 5:28 PM