/**
 * Description of the DogProblem (as in Charniak 19)
 * as a class to be linked with EBayes.
 * Author: Fabio G. Cozman (fgcozman@usp.br).
 */

import BayesianNetworks.*;

class DogProblem extends BayesNet {
    public DogProblem() {
        name = "Dog Problem";

        DiscreteVariable light_on =
            new DiscreteVariable("light-on",
                                    DiscreteVariable.CHANCE,
                                    new String[] {"true","false"});

        DiscreteVariable bowel_problem =
            new DiscreteVariable("bowel-problem",
                                    DiscreteVariable.CHANCE,
                                    new String[] {"true","false"});

        DiscreteVariable dog_out =
            new DiscreteVariable("dog-out",
                                    DiscreteVariable.CHANCE,
                                    new String[] {"true","false"});

        DiscreteVariable hear_bark =
            new DiscreteVariable("hear-bark",
                                    DiscreteVariable.CHANCE,
                                    new String[] {"true","false"});

        DiscreteVariable family_out =
            new DiscreteVariable("family-out",
                                    DiscreteVariable.CHANCE,
                                    new String[] {"true","false"});

        DiscreteFunction p1 =
            new DiscreteFunction(
                new DiscreteVariable[] {light_on},
                new DiscreteVariable[] {family_out},
                new double[] {0.6, 0.05, 0.4, 0.95});

        DiscreteFunction p2 =
            new DiscreteFunction(
                new DiscreteVariable[] {bowel_problem},
                new DiscreteVariable[] {},
                new double[] {0.01, 0.99});

        DiscreteFunction p3 =
            new DiscreteFunction(
                new DiscreteVariable[] {dog_out},
                new DiscreteVariable[] {bowel_problem, family_out},
                new double[] {0.99, 0.97, 0.9, 0.3, 0.01, 0.03, 0.1, 0.7});

        DiscreteFunction p4 =
            new DiscreteFunction(
                new DiscreteVariable[] {hear_bark},
                new DiscreteVariable[] {dog_out},
                new double[] {0.7, 0.01, 0.3, 0.99});

        DiscreteFunction p5 =
            new DiscreteFunction(
                new DiscreteVariable[] {family_out},
                new DiscreteVariable[] {},
                new double[] {0.15, 0.85});

        add( new DiscreteVariable[] 
             { light_on, hear_bark, dog_out, bowel_problem, family_out } );

        add( new DiscreteFunction[] { p1, p2, p3, p4, p5 } );
    }
}

