// Path: src/main/java/org/semanticweb/owl/explanation/api/ExplanationProgressMonitor.java
// public interface ExplanationProgressMonitor<E> {
// 
//     /**
//      * Called by explanation generators that support progress monitors.  This is
//      * called when a new explanation is found for an entailment when searching for
//      * multiple explanations.
//      *
//      * @param generator            The explanation generator that found the explanation
//      * @param explanation          The explanation that was found
//      *                             for the entailment or <code>false</code> if the explanation generator should stop finding explanations
//      *                             at the next opportunity.
//      * @param allFoundExplanations All of the explanations found so far for the specified entailment
//      */
//     void foundExplanation(ExplanationGenerator<E> generator, Explanation<E> explanation, Set<Explanation<E>> allFoundExplanations);
// 
//     /**
//      * The explanation generator will periodically check to see if it should continue finding explanations by calling
//      * this method.
//      *
//      * @return <code>true</code> if the explanation generator should cancel the explanation finding process or <code>false</code>
//      *         if the explanation generator should continue.
//      */
//     boolean isCancelled();
// }
// 
// Path: src/main/java/org/semanticweb/owl/explanation/impl/blackbox/checker/ConsistencyEntailmentChecker.java
// public class ConsistencyEntailmentChecker implements org.semanticweb.owl.explanation.impl.blackbox.EntailmentChecker<OWLAxiom> {
// 
//     private OWLAxiom entailment;
// 
//     private OWLReasonerFactory reasonerFactory;
// 
//     private int counter;
// 
//     private boolean consistent = false;
// 
//     private long timeout = Long.MAX_VALUE;
// 
//     public ConsistencyEntailmentChecker(OWLReasonerFactory reasonerFactory, long timeout) {
//         this.timeout = timeout;
//         this.reasonerFactory = reasonerFactory;
//         OWLDataFactory df = new OWLDataFactoryImpl();
//         this.entailment = df.getOWLSubClassOfAxiom(
//                 df.getOWLThing(),
//                 df.getOWLNothing()
//         );
//     }
// 
// 
// 
//     public int getCounter() {
//         return counter;
//     }
// 
//     public void resetCounter() {
//         counter = 0;
//     }
// 
//     public OWLAxiom getEntailment() {
//         return entailment;
//     }
// 
// 
//     public Set<OWLAxiom> getModule(Set<OWLAxiom> axioms) {
//         return axioms;
//     }
// 
//     public Set<OWLEntity> getEntailmentSignature() {
//         return Collections.emptySet();
//     }
// 
//     public Set<OWLEntity> getSeedSignature() {
//         return Collections.emptySet();
//     }
// 
//     public boolean isEntailed(final Set<OWLAxiom> axiom) {
// 
//         TelemetryTimer timer = new TelemetryTimer();
//         TelemetryTimer loadTimer = new TelemetryTimer();
//         TelemetryTimer checkTimer = new TelemetryTimer();
//         TelemetryInfo info = new DefaultTelemetryInfo("entailmentcheck", timer, loadTimer, checkTimer);
//         TelemetryTransmitter transmitter = TelemetryTransmitter.getTransmitter();
//         transmitter.beginTransmission(info);
//         try {
// //        System.out.print("Checking entailment....");
//             transmitter.recordMeasurement(info, "input size", axiom.size());
//             counter++;
//             timer.start();
//             OWLOntologyManager man = OWLManager.createOWLOntologyManager();
//             OWLOntology ont = man.createOntology(axiom);
//             SimpleConfiguration config = new SimpleConfiguration(timeout);
//             timer.start();
//             loadTimer.start();
//             OWLReasoner r = reasonerFactory.createReasoner(ont, config);
//             loadTimer.stop();
//             transmitter.recordTiming(info, "load time", timer);
//             checkTimer.start();
//             consistent = r.isConsistent();
//             checkTimer.stop();
//             timer.stop();
//             transmitter.recordTiming(info, "check time", checkTimer);
//             transmitter.recordTiming(info, "time", timer);
//             r.dispose();
// 
// //        System.out.println(" done!");
//             return !consistent;
//         }
//         catch (OWLOntologyCreationException e) {
//             throw new OWLRuntimeException(e);
//         }
//         finally {
//             transmitter.endTransmission(info);
//         }
//     }
// 
//     public String getModularisationTypeDescription() {
//         return "none";
//     }
// 
//     public boolean isUseModularisation() {
//         return false;
//     }
// 
//     public Set<OWLAxiom> getEntailingAxioms(Set<OWLAxiom> axioms) {
//         return null;
//     }
// }


import org.semanticweb.owl.explanation.api.ExplanationProgressMonitor;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owl.explanation.impl.blackbox.checker.ConsistencyEntailmentChecker;
import java.util.Set;
package org.semanticweb.owl.explanation.impl.blackbox;


/*
 * Copyright (C) 2009, University of Manchester
 *
 * Modifications to the initial code base are copyright of their
 * respective authors, or their employers as appropriate.  Authorship
 * of the modifications may be determined from the ChangeLog placed at
 * the end of this file.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

/**
 * Author: Matthew Horridge<br>
 * The University of Manchester<br>
 * Information Management Group<br>
 * Date: 24-May-2009
 */
public class InconsistentOntologyClashExpansionStrategy implements ExpansionStrategy {

    private int count = 0;

    private StructuralTypePriorityExpansionStrategy strategy = new StructuralTypePriorityExpansionStrategy();

    private InconsistentOntologyExpansionStrategy defaultStrategy = new InconsistentOntologyExpansionStrategy();
    
// Path: src/main/java/org/semanticweb/owl/explanation/api/ExplanationProgressMonitor.java
// public interface ExplanationProgressMonitor<E> {
// 
//     /**
//      * Called by explanation generators that support progress monitors.  This is
//      * called when a new explanation is found for an entailment when searching for
//      * multiple explanations.
//      *
//      * @param generator            The explanation generator that found the explanation
//      * @param explanation          The explanation that was found
//      *                             for the entailment or <code>false</code> if the explanation generator should stop finding explanations
//      *                             at the next opportunity.
//      * @param allFoundExplanations All of the explanations found so far for the specified entailment
//      */
//     void foundExplanation(ExplanationGenerator<E> generator, Explanation<E> explanation, Set<Explanation<E>> allFoundExplanations);
// 
//     /**
//      * The explanation generator will periodically check to see if it should continue finding explanations by calling
//      * this method.
//      *
//      * @return <code>true</code> if the explanation generator should cancel the explanation finding process or <code>false</code>
//      *         if the explanation generator should continue.
//      */
//     boolean isCancelled();
// }
// 
// Path: src/main/java/org/semanticweb/owl/explanation/impl/blackbox/checker/ConsistencyEntailmentChecker.java
// public class ConsistencyEntailmentChecker implements org.semanticweb.owl.explanation.impl.blackbox.EntailmentChecker<OWLAxiom> {
// 
//     private OWLAxiom entailment;
// 
//     private OWLReasonerFactory reasonerFactory;
// 
//     private int counter;
// 
//     private boolean consistent = false;
// 
//     private long timeout = Long.MAX_VALUE;
// 
//     public ConsistencyEntailmentChecker(OWLReasonerFactory reasonerFactory, long timeout) {
//         this.timeout = timeout;
//         this.reasonerFactory = reasonerFactory;
//         OWLDataFactory df = new OWLDataFactoryImpl();
//         this.entailment = df.getOWLSubClassOfAxiom(
//                 df.getOWLThing(),
//                 df.getOWLNothing()
//         );
//     }
// 
// 
// 
//     public int getCounter() {
//         return counter;
//     }
// 
//     public void resetCounter() {
//         counter = 0;
//     }
// 
//     public OWLAxiom getEntailment() {
//         return entailment;
//     }
// 
// 
//     public Set<OWLAxiom> getModule(Set<OWLAxiom> axioms) {
//         return axioms;
//     }
// 
//     public Set<OWLEntity> getEntailmentSignature() {
//         return Collections.emptySet();
//     }
// 
//     public Set<OWLEntity> getSeedSignature() {
//         return Collections.emptySet();
//     }
// 
//     public boolean isEntailed(final Set<OWLAxiom> axiom) {
// 
//         TelemetryTimer timer = new TelemetryTimer();
//         TelemetryTimer loadTimer = new TelemetryTimer();
//         TelemetryTimer checkTimer = new TelemetryTimer();
//         TelemetryInfo info = new DefaultTelemetryInfo("entailmentcheck", timer, loadTimer, checkTimer);
//         TelemetryTransmitter transmitter = TelemetryTransmitter.getTransmitter();
//         transmitter.beginTransmission(info);
//         try {
// //        System.out.print("Checking entailment....");
//             transmitter.recordMeasurement(info, "input size", axiom.size());
//             counter++;
//             timer.start();
//             OWLOntologyManager man = OWLManager.createOWLOntologyManager();
//             OWLOntology ont = man.createOntology(axiom);
//             SimpleConfiguration config = new SimpleConfiguration(timeout);
//             timer.start();
//             loadTimer.start();
//             OWLReasoner r = reasonerFactory.createReasoner(ont, config);
//             loadTimer.stop();
//             transmitter.recordTiming(info, "load time", timer);
//             checkTimer.start();
//             consistent = r.isConsistent();
//             checkTimer.stop();
//             timer.stop();
//             transmitter.recordTiming(info, "check time", checkTimer);
//             transmitter.recordTiming(info, "time", timer);
//             r.dispose();
// 
// //        System.out.println(" done!");
//             return !consistent;
//         }
//         catch (OWLOntologyCreationException e) {
//             throw new OWLRuntimeException(e);
//         }
//         finally {
//             transmitter.endTransmission(info);
//         }
//     }
// 
//     public String getModularisationTypeDescription() {
//         return "none";
//     }
// 
//     public boolean isUseModularisation() {
//         return false;
//     }
// 
//     public Set<OWLAxiom> getEntailingAxioms(Set<OWLAxiom> axioms) {
//         return null;
//     }
// }


// Path: src/main/java/org/semanticweb/owl/explanation/impl/blackbox/InconsistentOntologyClashExpansionStrategy.java
import org.semanticweb.owl.explanation.api.ExplanationProgressMonitor;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owl.explanation.impl.blackbox.checker.ConsistencyEntailmentChecker;
import java.util.Set;

package org.semanticweb.owl.explanation.impl.blackbox;


/*
 * Copyright (C) 2009, University of Manchester
 *
 * Modifications to the initial code base are copyright of their
 * respective authors, or their employers as appropriate.  Authorship
 * of the modifications may be determined from the ChangeLog placed at
 * the end of this file.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

/**
 * Author: Matthew Horridge<br>
 * The University of Manchester<br>
 * Information Management Group<br>
 * Date: 24-May-2009
 */
public class InconsistentOntologyClashExpansionStrategy implements ExpansionStrategy {

    private int count = 0;

    private StructuralTypePriorityExpansionStrategy strategy = new StructuralTypePriorityExpansionStrategy();

    private InconsistentOntologyExpansionStrategy defaultStrategy = new InconsistentOntologyExpansionStrategy();
    
    public Set<OWLAxiom> doExpansion(Set<OWLAxiom> axioms, EntailmentChecker checker, ExplanationProgressMonitor<?> progressMonitor) {