All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aima.core.probability.proposition.DisjunctiveProposition Maven / Gradle / Ivy

Go to download

AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.

The newest version!
package aima.core.probability.proposition;

import java.util.Map;

import aima.core.probability.RandomVariable;

/**
 * Artificial Intelligence A Modern Approach (3rd Edition): Formula 13.4, page
 * 489.
*
* * We can also derive the well-known formula for the probability of a * disjunction, sometimes called the inclusion-exclusion principle:
*
* P(a OR b) = P(a) + P(b) - P(a AND b).
* * @author Ciaran O'Reilly */ public class DisjunctiveProposition extends AbstractProposition implements BinarySentenceProposition { private Proposition left = null; private Proposition right = null; // private String toString = null; public DisjunctiveProposition(Proposition left, Proposition right) { if (null == left) { throw new IllegalArgumentException( "Left side of disjunction must be specified."); } if (null == right) { throw new IllegalArgumentException( "Right side of disjunction must be specified."); } // Track nested scope addScope(left.getScope()); addScope(right.getScope()); addUnboundScope(left.getUnboundScope()); addUnboundScope(right.getUnboundScope()); this.left = left; this.right = right; } @Override public boolean holds(Map possibleWorld) { return left.holds(possibleWorld) || right.holds(possibleWorld); } @Override public String toString() { if (null == toString) { StringBuilder sb = new StringBuilder(); sb.append("("); sb.append(left.toString()); sb.append(" OR "); sb.append(right.toString()); sb.append(")"); toString = sb.toString(); } return toString; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy