locked
Model has zero probability RRS feed

  • Question

  • Hi all,

    I've been trying to work with Infer.NET on C# and I've been having the following problem. I'm trying to implement a model similar to the difficulty vs. ability ("how to grade a test without knowing the answers"), but the test I'm checking is with three topics (it's the Israeli variant of the GRE, so the topics are verbal (Hebrew), math and English). I've been modeling it in a manner very similar to the difficulty vs. ability method. I've written an initial piece of code which worked; however, it did not account for a student not answering a question. When I added that part, I got an error of "model has zero probability". Can anyone tell me what I'm doing wrong? Any help would be greatly appreciated!

    Just so I'm clear - the model compiles, but when I try to use the engine to infer anything it crashes saying "model has zero probability".

        class Test
        {
            public static int NUM_OF_TOPICS = 3;
            public static int ENGLISH_TOPIC_CODE = 0;
            public static int MATH_TOPIC_CODE = 1;
            public static int VERBAL_TOPIC_CODE = 2;
            public static int NUM_OF_RESP = 4;
            
            public VariableArray<VariableArray<double>, double[][]> TopicAbility; //ability[t][s] = student s's ability in topic t
            public VariableArray<double> BaseAbility; //baseability[s] = student's basic ability
            //questionscore[t][s][q] = topicability[t][s] + discrimination[t][s][q]
            public VariableArray<VariableArray<VariableArray<double>, double[][]>, double[][][]> StudentQuestionScore;
            //response[t][s][q] = response of student s to question q in topic t.
            public VariableArray<VariableArray<VariableArray<int>, int[][]>, int[][][]> Response;
            //basetopicdifficulty[t] = the difficulty of topic t
            public VariableArray<double> BaseTopicDifficulty;
            //difficulty[t][q] = question q (in topic t)'s difficulty
            public VariableArray<VariableArray<double>, double[][]> Difficulty;
            //discrimination[t][s][q] = question q's discrimination factor against student s, under topic t
            public VariableArray<VariableArray<VariableArray<double>, double[][]>, double[][][]> Discrimination;
            //correctanswers[t][q] = the correct answer to question q in topic t
            public VariableArray<VariableArray<int>, int[][]> TrueAnswers;
    
            public VariableArray<VariableArray<VariableArray<bool>, bool[][]>, bool[][][]> DidStudentRespondVar;
            
            //correct[t][s][q] = true iff student s answered q correctly in topic t
            //public VariableArray<VariableArray<VariableArray<bool>, bool[][]>, bool[][][]> Correct;
    
            
            
            public InferenceEngine Engine = new InferenceEngine();
            //prior on Gaussian perturbations
            public Variable<double> baseAbilityPerturbation = Variable.New<double>().Named("Base Ability Perturbation");
            public Variable<double> topicBiasPerturbation = Variable.New<double>().Named("Topic Bias Perturbation");
            public Variable<double> difficultyPerturbation = Variable.New<double>().Named("Difficulty Perturbation");
            public Variable<double> discriminationPerturbation = Variable.New<double>().Named("Discrimination Perturbation");
            public Variable<double> baseDifficultyPerturbation = Variable.New<double>().Named("Base Topic Difficulty Perurbation");
            /*
            private Variable<Gaussian> p_baseAbilityPrior = Variable.New<Gaussian>().Named("Base Ability Prior");
            private VariableArray<Gaussian> p_abilityBiasPrior; //prior on students' ability in topic t
            private VariableArray<Gaussian> p_difficultyPrior; //prior on question q's difficulty (in topic t)
            private VariableArray<Gamma> p_discriminationFactor; //prior on question q's discrimination factor (in topic t)
            
             */
            private Variable<int> p_nstudents = Variable.New<int>().Named("Number of Students");
    
            private Range T = new Range(NUM_OF_TOPICS).Named("Num of Topics");//the range for the topics
            private VariableArray<int> p_nquestions;
            private Range Q;//the range for the questions - each topic has a different # of questions!
            private Range S;//the range for the students
            //Inferred Posteriors 
            public Gaussian[] BaseTopicDifficultyPosterior;
            public Gaussian[][] DifficultyPosterior = null;
            public Gaussian[] BaseAbilityPosterior = null;
            public Gaussian[][] TopicAbilityPosterior = null;
    
            public static int get_num_of_lines_in_file(string file_name)
            {
                return File.ReadLines(@file_name).Count();
            }
    
            //return a large table whose entries are the student responses to a given topic
            //T[s][q] = the answer student s gave for question q. 
            //file entries are assumed to be of the form s,q,a where 
            //s is the student index
            //q is the question index
            //a is the answer the student gave
            public static int[][] generate_student_responses(string file_name,int num_of_students,int num_of_questions)
            {
                int[][] student_responses = new int[num_of_students][];
                for (int s = 0;s < num_of_students;s++)
                {
                    student_responses[s] = new int[num_of_questions];
                }
                for (int s = 0; s < num_of_students; s++)
                {
                    for (int q = 0;q < num_of_questions;q++)
                    {
                        student_responses[s][q] = 0;
                    }
                }
                
                string line;
                string[] split_line;
                System.IO.StreamReader file = new System.IO.StreamReader(file_name);
                int student_id;
                int question_id;
                int student_response;
                while ((line = file.ReadLine())!= null)
                {
                    split_line = line.Split(',');
                    student_id = Convert.ToInt32(split_line[0]);
                    question_id = Convert.ToInt32(split_line[1]);
                    student_response = Convert.ToInt32(split_line[2]);
                    if (student_id < num_of_students+1)
                    {
                        //NOTE THE -1 here: the student indices start from 1 in the CSV files
                        student_responses[student_id - 1][question_id - 1] = student_response;
                    }
                    
                }
                file.Close();
                return student_responses;
            }
            public static int[] generate_correct_answers(string file_name)
            {
                string line;
                string[] split_line;
                System.IO.StreamReader file = new System.IO.StreamReader(file_name);
                int question_id;
                int answer;
                
                int num_of_questions = get_num_of_lines_in_file(file_name);
                int[] correct_answers = new int[num_of_questions];
                while ((line = file.ReadLine())!= null)
                {
                    split_line = line.Split(',');
                    question_id = Convert.ToInt32(split_line[0]);
                    answer = Convert.ToInt32(split_line[1]);
                    correct_answers[question_id - 1] = answer;
                }
                file.Close();
                return correct_answers;
            }
    
            private void p_initProbabilisticGraphicalModel()
            {
    
                //I'm assuming here that all topics have the same students.
                S = new Range(p_nstudents).Named("num of students");
                S.AddAttribute(new Sequential());
                p_nquestions = Variable.Array<int>(T).Named("number of questions");
                Q = new Range(p_nquestions[T]).Named("ranges of number of questions per topic");
    
                Engine.Compiler.UseSerialSchedules = true;
     
                BaseTopicDifficulty = Variable.Array<double>(T).Named("Base Topic Difficulty");
                //init difficulty RV
                Difficulty = Variable.Array(Variable.Array<double>(Q), T).Named("Question Difficulty");
                //init correct RV
                //Correct = Variable.Array(Variable.Array(Variable.Array<bool>(Q), S), T).Named("IsCorrect");
                //init student ability RV
                BaseAbility = Variable.Array<double>(S).Named("Base Ability");
                TopicAbility = Variable.Array(Variable.Array<double>(S), T).Named("Topic Ability");
                //init discrimination factor
                Discrimination = Variable.Array(Variable.Array(Variable.Array<double>(Q), S), T).Named("Discrimination");
                //init responses
                Response = Variable.Array(Variable.Array(Variable.Array<int>(Q), S), T).Named("Response");
                DidStudentRespondVar = Variable.Array(Variable.Array(Variable.Array<bool>(Q), S), T).Named("Did Student Respond");
                TrueAnswers = Variable.Array(Variable.Array<int>(Q), T).Named("True Answers");
                StudentQuestionScore = Variable.Array(Variable.Array(Variable.Array<double>(Q), S), T).Named("Student Score on Question");
                //DidStudentAnswer = Variable.Array(Variable.Array(Variable.Array<bool>(Q), S), T).Named("Did Student Answer the Question");
                
                //set up prior for all the random variables.
                BaseTopicDifficulty[T] = Variable.GaussianFromMeanAndVariance(0, baseDifficultyPerturbation).ForEach(T);
                using (Variable.ForEach(T))
                {
                    using (Variable.ForEach(Q))
                    {
                        Difficulty[T][Q] = BaseTopicDifficulty[T] + Variable.GaussianFromMeanAndVariance(0, difficultyPerturbation);
                    }
                }
                using (Variable.ForEach(S))
                {
                    BaseAbility[S] = Variable.GaussianFromMeanAndVariance(0, baseAbilityPerturbation).Named("base ability") ;
                }
                using (Variable.ForEach(T))
                {
                    using (Variable.ForEach(S))
                    {
                        var StudentTopicBias = Variable.GaussianFromMeanAndPrecision(0, topicBiasPerturbation).Named("Student Topic Bias");
                        TopicAbility[T][S] = BaseAbility[S] + StudentTopicBias;
                    }
                }
                using (Variable.ForEach(T))
                {
                    using (Variable.ForEach(Q))
                    {
                        using (Variable.ForEach(S))
                        {
                            Discrimination[T][S][Q] = Variable.GaussianFromMeanAndVariance(0, discriminationPerturbation).Named("Discrimination");
                            StudentQuestionScore[T][S][Q] = TopicAbility[T][S] + Discrimination[T][S][Q];
                            //DidStudentAnswer[T][S][Q] = Variable<bool>.Bernoulli(0.5);
                        }
                    }
                }
    
    
    
                TrueAnswers[T][Q] = Variable<int>.Random(Discrete.Uniform(NUM_OF_RESP)).ForEach(T, Q);
    
    
                using (Variable.ForEach(T))
                {
                    using (Variable.ForEach(S))
                    {
                        using (Variable.ForEach(Q))
                        {
                            //Correct[T][S][Q] = Variable.Bernoulli(0.5);
                            using (Variable.If(DidStudentRespondVar[T][S][Q]))
                            {
                                var advantage = StudentQuestionScore[T][S][Q] - Difficulty[T][Q];
                                var correct = (advantage > 0);
                                using (Variable.If(correct))
                                {
                                    Response[T][S][Q] = TrueAnswers[T][Q];
                                }
                                using (Variable.IfNot(correct))
                                {
                                    Response[T][S][Q] = Variable.DiscreteUniform(NUM_OF_RESP).Named("Student Is Randomly Guessing");
                                }
                            }
                        }
                    }
                }
            }
            public Test()
            {
                //initialize the probabilistic graphical model we use
                p_initProbabilisticGraphicalModel();
                
    
            }
            //assumes that all observed variables have been set
            public void RevealPriors(
                int[][][] dataset,
                int[][] correct_answers,
                double baseAbilityObserved,
                double topicBiasObserved,
                double baseDifficulty,
                double difficultyPriorObserved,
                double discriminationFactorObserved)
            {
                bool[][][] didstudentrespond = new bool[NUM_OF_TOPICS][][];
                for (int t = 0;t< NUM_OF_TOPICS;t++)
                {
                    didstudentrespond[t] = new bool[dataset[t].Length][];
                    for (int s = 0;s< dataset[t].Length;s++)
                    {
                        didstudentrespond[t][s] = new bool[dataset[t][s].Length];
                        for (int q = 0;q<didstudentrespond[t][s].Length;q++)
                        {
                            didstudentrespond[t][s][q] = (dataset[t][s][q] > 0);
                        }
                    }
                }
                //reveal the actual student responses and the correct answers to the questions
                Response.ObservedValue = dataset;
                TrueAnswers.ObservedValue = correct_answers;
                DidStudentRespondVar.ObservedValue = didstudentrespond;
                int[] numofquestions = new int[NUM_OF_TOPICS];
                for (int t = 0; t < NUM_OF_TOPICS; t++)
                {
                    numofquestions[t] = dataset[t][0].Length;
                }
                p_nquestions.ObservedValue = numofquestions;
                p_nstudents.ObservedValue = dataset[0].Length;
                baseAbilityPerturbation.ObservedValue = baseAbilityObserved;
                topicBiasPerturbation.ObservedValue = topicBiasObserved;
                baseDifficultyPerturbation.ObservedValue = baseDifficulty;
                difficultyPerturbation.ObservedValue = difficultyPriorObserved;
                discriminationPerturbation.ObservedValue = discriminationFactorObserved;
    
                /*
                p_baseAbilityPrior.ObservedValue = baseAbilityPriorObserved;
                p_difficultyPrior.ObservedValue = difficultyPriorObserved;
                p_abilityBiasPrior.ObservedValue = abilityBiasPriorObserved;
                p_discriminationFactor.ObservedValue = discriminationFactorObserved;
                */
            }
            public void LearnPosteriors()
            {
                Engine.ShowFactorGraph = true;
                BaseTopicDifficultyPosterior = Engine.Infer<Gaussian[]>(BaseTopicDifficulty);
                DifficultyPosterior = Engine.Infer<Gaussian[][]>(Difficulty);
                BaseAbilityPosterior = Engine.Infer<Gaussian[]>(BaseAbility);
                TopicAbilityPosterior = Engine.Infer<Gaussian[][]>(TopicAbility);
            }
        }


    • Edited by Yair Zick Tuesday, June 10, 2014 2:47 PM
    Tuesday, June 10, 2014 2:30 PM

Answers

  • To wrap up this thread, the issue was that some of the responses were outside of the range 0-3 as expected by the model.  Also the code was using GammaFromMeanAndVariance(0, 1) in various places.  That is an improper distribution which causes inference issues.  Finally, the code was using Variable.GaussianFromMeanAndVariance with unknown variance.  That factor is experimental (as reported by the compiler).  Better results are obtained by using Variable.GaussianFromMeanAndPrecision with unknown precision.
    Tuesday, June 17, 2014 5:22 PM
    Owner

All replies

  • This is answered in the FAQ.  Your issue is in the line:  Response[T][S][Q] = TrueAnswers[T][Q];   Since both of these variables are observed.
    Tuesday, June 10, 2014 4:35 PM
    Owner
  • Hi Tom,

    Thanks for the quick reply. So - instead of using = I should be using Variable.ConstrainEqual() right?

    As was advised in the forum and by Yoram, I have switched to the observed responses method. Now, I keep a class called TestTopic

    that maintains observations for that topic + the correct answer key for that topic (see code)

        /*
         * This class describes a single test topic, 
         * it holds a list of observed answers by students on that topic, and 
         * the correct answers to the questions.
         */
        class TestTopic
        {
            public string Name = "DefaultTestTopic";
            public void Named(string n)
            {
                Name = n;
            }
    
            public Variable<int> nObservations = Variable.New<int>();
            public Range numOfObservations;
    
    
            public Variable<int> nQuestions = Variable.New<int>();
            public Range numOfQuestions;
    
            /*
             * These three variable arrays hold the observed values:
             * ObsStudentID: the ID of the student
             * ObsQuestionID: the question he answered
             * ObsStudentResponse: what was the response he gave
             */
            public VariableArray<int> ObsStudentID;
            public VariableArray<int> ObsQuestionID;
            public VariableArray<int> ObsStudentResponse;
    
            /*
             * This array holds the correct answers to questions on this topic
             */
            public VariableArray<int> CorrectAnswer;
            /*
             * This is the difficulty of the topic
             */
            public Variable<double> TopicDifficulty;
            /*
             * This array holds the question difficulties
             */
            public VariableArray<double> QuestionDifficulty;
            /*
             * The discrimination of a question is some random noise added to the difficulty
             */
            public VariableArray<double> QuestionDiscrimination;
            /*
             * each one of the students has a baseline topic ability, which is used
             * to gauge their ability to answer questions on that topic.
             */
            public VariableArray<double> StudentTopicAbility;
    
            public Variable<double> baseDifficultyPerturbation;
    
            public Variable<double> TopicBiasPerturbation;
            /*
             * To initialize a topic, we need to give it a name ("English","Math" etc.) 
             * and to tell it the range of the students that we are using (this is because we 
             * want to coordinate the students among all topics, and not have the model think 
             * that each topic has a distinct set of students.
             * 
             * We also need to pass to the topic the number of possible answers to this topic 
             * (this is designed for an MCQ)
             */
            public void init(VariableArray<double> StudentBaseAbility,Range StudentRange, int num_of_resp)
            {
    
                TopicBiasPerturbation = 
                    Variable.GammaFromMeanAndVariance(0,1).Named("Topic Bias Perturbation in " + Name);
    
                nObservations.Named("Num of Observations in " + Name);
                nQuestions.Named("Number of Questions in " + Name);
                baseDifficultyPerturbation = 
                    Variable.GammaFromMeanAndVariance(0,1).Named("Base Topic Difficulty Perurbation in "+ Name);
    
                numOfObservations = new Range(nObservations).Named("Number of Observations Range in "+ Name);
                numOfQuestions = new Range(nQuestions).Named("Number of Questions Range in "+Name);
    
                ObsStudentID = Variable.Array<int>(numOfObservations).Named("Observed Student ID in " + Name);
                ObsQuestionID = Variable.Array<int>(numOfObservations).Named("Observed Question ID in " + Name);
                ObsStudentResponse = Variable.Array<int>(numOfObservations).Named("Observed Student Response in " + Name);
    
    
                CorrectAnswer = Variable.Array<int>(numOfQuestions).Named("Correct Answer in " + Name);
    
                TopicDifficulty = Variable.GaussianFromMeanAndVariance(0, baseDifficultyPerturbation).Named(Name + " base difficulty");
                //init intrinsic difficulties of questions in this topic
                QuestionDifficulty = Variable.Array<double>(numOfQuestions).Named("Question Difficulty in " + Name);
                QuestionDifficulty[numOfQuestions] = Variable.GaussianFromMeanAndVariance(0, 1).ForEach(numOfQuestions);
    
                QuestionDiscrimination = Variable.Array<double>(numOfQuestions).Named("Question Discrimination in " + Name);
                QuestionDiscrimination[numOfQuestions] = Variable.GammaFromMeanAndVariance(0, 1).ForEach(numOfQuestions);
                StudentTopicAbility = Variable.Array<double>(StudentRange).Named("Student Topic Ability in " + Name);
                using (Variable.ForEach(StudentRange))
                {
                    var StudentTopicBias = Variable.GaussianFromMeanAndPrecision(0, TopicBiasPerturbation);
                    StudentTopicAbility[StudentRange].SetTo(StudentBaseAbility[StudentRange] + StudentTopicBias);
                }
                
                using (Variable.ForEach(numOfObservations))
                {
                    Variable<int> q = ObsQuestionID[numOfObservations]-1;
                    Variable<int> s = ObsStudentID[numOfObservations]-1;
                    Variable<double> advantage = (StudentTopicAbility[s] - QuestionDifficulty[q]);
                    Variable<double> advantagenoisy = Variable.GaussianFromMeanAndVariance(advantage, QuestionDiscrimination[q]);
                    Variable<bool> correct = (advantagenoisy > 0);
                    using (Variable.If(correct))
                    {
                        Variable.ConstrainEqual(ObsStudentResponse[numOfObservations],CorrectAnswer[q]);
                    }
                    using (Variable.IfNot(correct))
                    {
                        Variable.ConstrainEqual(ObsStudentResponse[numOfObservations],(Variable.DiscreteUniform(num_of_resp) + 1));
                    }
    
                }
            }
            public void RevealObservations(List<ObservedResponse> observed_responses)
            {
                int num_of_observations = observed_responses.Count;
                int[] obs_student_id = new int[num_of_observations];
                int[] obs_qID = new int[num_of_observations];
                int[] obs_student_response= new int[num_of_observations];
                for (int obs = 0; obs < num_of_observations; obs++)
                {
                    obs_qID[obs] = observed_responses[obs].questionID;
                    obs_student_id[obs] = observed_responses[obs].studentID;
                    obs_student_response[obs] = observed_responses[obs].response;
                }
                nObservations.ObservedValue = num_of_observations;
                ObsQuestionID.ObservedValue = obs_qID;
                ObsStudentID.ObservedValue = obs_student_id;
                ObsStudentResponse.ObservedValue = obs_student_response;
            }
            public void RevealCorrectAnswers(int[] correct_answers)
            {
                nQuestions.ObservedValue = correct_answers.Length;
                CorrectAnswer.ObservedValue = correct_answers;
            }
    
           
    
        }
    

    and a larger class that contains three instances of TestTopic (English, Verbal, Math). The class ObservedResponse just wraps the response triplet (studentId,questionId,response) to ease readability.

       class ObservedResponse
            {
                public int studentID;
                public int questionID;
                public int response;
                public ObservedResponse(int s,int q,int r)
                {
                    studentID = s;
                    questionID = q;
                    response = r;
                }
    
            }
    
            class AdaptiveTestWithObservations
            {
                public static int NUM_OF_TOPICS = 3;
                public static int ENGLISH_TOPIC_CODE = 0;
                public static int MATH_TOPIC_CODE = 1;
                public static int VERBAL_TOPIC_CODE = 2;
                public static int NUM_OF_RESP = 4;
    
                public TestTopic EnglishTopic = new TestTopic();
                
                public TestTopic VerbalTopic = new TestTopic();
                
                public TestTopic MathTopic = new TestTopic();
    
                public Variable<int> nStudents = Variable.New<int>().Named("Number of Students");
                public Range StudentRange;
    
                public VariableArray<double> StudentBaseAbility;
    
                public Variable<double> studentBaseAbilityPerturbation = Variable.GammaFromMeanAndVariance(0, 1).Named("Student Base Ability Perturbation");
    
                public InferenceEngine Engine = new InferenceEngine();
    
                public void init()
                {
                    EnglishTopic.Named("English");
                    VerbalTopic.Named("Verbal");
                    MathTopic.Named("Math");
                    Engine.Compiler.UseSerialSchedules = true;
                    
                    StudentRange = new Range(nStudents);
                    StudentRange.AddAttribute(new Sequential());
    
                    StudentBaseAbility = Variable.Array<double>(StudentRange).Named("Student Base Ability");
                    StudentBaseAbility[StudentRange] = Variable.GaussianFromMeanAndVariance(0, studentBaseAbilityPerturbation).ForEach(StudentRange);
                    
                    EnglishTopic.init(StudentBaseAbility, StudentRange, NUM_OF_RESP);
                    VerbalTopic.init(StudentBaseAbility,StudentRange, NUM_OF_RESP);
                    MathTopic.init(StudentBaseAbility,StudentRange, NUM_OF_RESP);
    
                    
                }
    
                //return a list whose entries are the student responses to a given topic
                
                public static List<ObservedResponse> generate_student_responses(string file_name,int num_of_students,int max_num_of_questions = 0)
                {
                    List<ObservedResponse> obsresponses = new List<ObservedResponse>();
                    
                    string line;
                    string[] split_line;
                    System.IO.StreamReader file = new System.IO.StreamReader(file_name);
                    int student_id;
                    int question_id;
                    int student_response;
                    while ((line = file.ReadLine()) != null)
                    {
                        split_line = line.Split(',');
                        student_id = Convert.ToInt32(split_line[0]);
                        question_id = Convert.ToInt32(split_line[1]);
                        student_response = Convert.ToInt32(split_line[2]);
                        if (student_response > 0 && 
                            student_id< num_of_students)
                        {
                            if (max_num_of_questions == 0)
                            {
                                obsresponses.Add(new ObservedResponse(student_id, question_id, student_response));
                            }
                            else
                            {
                                if (question_id <=max_num_of_questions)
                                {
                                    obsresponses.Add(new ObservedResponse(student_id, question_id, student_response));
                                }
                            }
    
                        }
    
    
                    }
                    file.Close();
                    return obsresponses;
                }
                public static int get_num_of_lines_in_file(string file_name)
                {
                    return File.ReadLines(@file_name).Count();
                }
                public static int[] generate_correct_answers(string file_name,int max_num_of_questions=0)
                {
                    string line;
                    string[] split_line;
                    System.IO.StreamReader file = new System.IO.StreamReader(file_name);
                    int question_id;
                    int answer;
                    int num_of_questions;
                    if (max_num_of_questions > 0 && max_num_of_questions < get_num_of_lines_in_file(file_name))
                    {
                        num_of_questions = max_num_of_questions;
                    }
                    else
                    {
                        num_of_questions = get_num_of_lines_in_file(file_name);
                    }
                    
                    int[] correct_answers = new int[num_of_questions];
                    int count = 0;
                    while (((line = file.ReadLine()) != null) && count < num_of_questions)
                    {
                        split_line = line.Split(',');
                        question_id = Convert.ToInt32(split_line[0]);
                        answer = Convert.ToInt32(split_line[1]);
                        if (question_id<= num_of_questions)
                        {
                            correct_answers[question_id - 1] = answer;
                            count++;
                        }
    
                    }
                    file.Close();
                    return correct_answers;
                }
            }

    But, now I'm getting another error -

    An unhandled exception of type 'System.Exception' occurred in Infer.Compiler.dll
    Additional information: Scheduling constraints cannot be satisfied.  This is usually due to a missing or overspecified method attribute

    This occurs when the model is compiling, so I'm completely confused (before it was compiling)

    Wednesday, June 11, 2014 1:11 AM
  • Variable.ConstrainEqual does not solve the original problem.  Your new version will throw the same AllZeroException when it runs, since you haven't addressed the underlying issue which is explained in the FAQ.  I suggest using your original code with the correct fix to resolve the AllZeroException.
    Wednesday, June 11, 2014 10:36 AM
    Owner
  • Hey Tom,

    Perhaps I'm missing something - I don't see any reference to this type of problem, and all examples appearing on the website do exactly what I do (that is, setting the variables to being equal rather than something else).

    Wednesday, June 11, 2014 1:43 PM
  • It is possible for you to send us a runnable (but failing) version of the original model, via the infersup address?  Then we can figure out the root cause.

    Wednesday, June 11, 2014 2:47 PM
    Owner
  • To wrap up this thread, the issue was that some of the responses were outside of the range 0-3 as expected by the model.  Also the code was using GammaFromMeanAndVariance(0, 1) in various places.  That is an improper distribution which causes inference issues.  Finally, the code was using Variable.GaussianFromMeanAndVariance with unknown variance.  That factor is experimental (as reported by the compiler).  Better results are obtained by using Variable.GaussianFromMeanAndPrecision with unknown precision.
    Tuesday, June 17, 2014 5:22 PM
    Owner