package causation.lab; import exercise.*; import tetrad.graph.TetradGraph; /** * This class does the evaluation of the student's submission for any * Causality Lab exercise. As of right now, all it tests is whether * the submitted graph is the same as the correct one, or else has the * same D-separation facts. * * @version 0.9 June 20, 1999 * @author David Danks */ public class CLEvaluator implements Evaluator { /** * Null constructor. Doesn't do anything */ public CLEvaluator() { ; } /** * @param ex The CLExercise for this CausalityLab * @param sol The student's submission * @return A CLResults object encoded the outcome */ public Evaluation evaluate(Exercise ex, Submission sub) { TetradGraph exTG = null; TetradGraph subTG = null; if (ex instanceof CLExercise) exTG = ((CLExercise)ex).getTetradGraph(); else return null; if (sub instanceof CLSubmission) subTG = ((CLSubmission)sub).getTetradGraph(); else return null; if (exTG.isEquivalentTo(subTG)) return new CLEvaluation(CLEvaluation.CORRECT_DIGRAPH); else { DSeparationFacts exDSF = new DSeparationFacts(exTG); DSeparationFacts subDSF = new DSeparationFacts(subTG); if (exDSF.equals(subDSF)) return new CLEvaluation(CLEvaluation.EQUIVALENT_DIGRAPH); else return new CLEvaluation(CLEvaluation.INCORRECT_DIGRAPH); } } }