Ejemplo n.º 1
0
        public ConstraintBasedStructureLearner(IList <RandomVariable> randomVariables, DualKeyDictionary <RandomVariable, ICollection <ISet <RandomVariable> > > independencies)
        {
            _randomVariables = randomVariables;
            _independencies  = independencies;
            _dag             = DagPattern <RandomVariable> .InitCompleteDag(randomVariables);

            _collectedConditions = new DualKeyDictionary <RandomVariable, ISet <RandomVariable> >();
            foreach (var x in _dag.Nodes)
            {
                foreach (var y in _dag.Nodes.Where(y => x != y))
                {
                    _collectedConditions[x, y] = new HashSet <RandomVariable>();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Identifies as many conditional independencies in the model as possible.
        /// </summary>
        public DualKeyDictionary <RandomVariable, ICollection <ISet <RandomVariable> > > FindIndependencies(IList <FaultRandomVariable> faults, ICollection <McsRandomVariable> minimalCriticalSets, IList <BooleanRandomVariable> states, BooleanRandomVariable hazard)
        {
            _hazard = hazard;
            _faults = faults;
            _minimalCriticalSets = new HashSet <McsRandomVariable>(minimalCriticalSets);
            _states = states;
            _conditionalIndependencies = new DualKeyDictionary <RandomVariable, ICollection <ISet <RandomVariable> > >();

            var variablesForCalculation = GetVariablesForCalculation();

            CalculatePairIndependencies(variablesForCalculation);

            if (_config.UseDccaResultsForLearning && _minimalCriticalSets.Count > 0)
            {
                GenerateDccaIndependencies();
                CalculateFurtherDccaIndependencies();
            }

            return(_conditionalIndependencies);
        }