Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException with CELOE and ClassExpressionLearningProblem #105

Open
posixcompliance opened this issue May 2, 2022 · 4 comments
Open
Labels

Comments

@posixcompliance
Copy link

posixcompliance commented May 2, 2022

Given the following code and the current release DL-Learner 1.5, there is a ClassCastException thrown during alg.start();.

        OWLOntologyManager manager = OWLManager.createConcurrentOWLOntologyManager();
        OWLOntology ontology = manager.loadOntologyFromOntologyDocument(getClass().getResourceAsStream("/Test.owl"));
        Configuration reasonerConfiguration = new Configuration();
        // using HermiT
        OWLReasoner reasoner = new ReasonerFactory().createReasoner(ontology, reasonerConfiguration);

        AbstractKnowledgeSource ks = new OWLAPIOntology(ontology);
        ks.init();

        OWLAPIReasoner rc = new OWLAPIReasoner(reasoner);
        rc.init();

        ClassExpressionLearningProblem lp = new ClassExpressionLearningProblem(rc);
        lp.setClassToDescribe(IRI.create("#Positive"));
        lp.init();

        CELOE alg = new CELOE(lp, rc);
        alg.setMaxExecutionTimeInSeconds(10);
        alg.init();

        alg.start();
java.lang.ClassCastException: class org.dllearner.utilities.ReasoningUtils cannot be cast to class org.dllearner.utilities.ReasoningUtilsCLP (org.dllearner.utilities.ReasoningUtils and org.dllearner.utilities.ReasoningUtilsCLP are in unnamed module of loader 'app')

	at org.dllearner.learningproblems.ClassExpressionLearningProblem.computeScore(ClassExpressionLearningProblem.java:184)
	at org.dllearner.learningproblems.ClassExpressionLearningProblem.evaluate(ClassExpressionLearningProblem.java:266)
	at org.dllearner.learningproblems.ClassExpressionLearningProblem.evaluate(ClassExpressionLearningProblem.java:53)
	at org.dllearner.core.AbstractLearningProblem.evaluate(AbstractLearningProblem.java:103)
	at org.dllearner.utilities.owl.EvaluatedDescriptionSet.add(EvaluatedDescriptionSet.java:71)
	at org.dllearner.algorithms.celoe.CELOE.addNode(CELOE.java:609)
	at org.dllearner.algorithms.celoe.CELOE.start(CELOE.java:331)

Perhaps this could be an issue with me using a single class #Positive as the class to describe?

@SimonBin SimonBin added the bug label May 20, 2022
@SimonBin
Copy link
Member

seems to be a bug; if you want to test something with a single named class you can see if the ClassLearningProblem (no Expression) does any good

@posixcompliance
Copy link
Author

I have tested again and can confirm that the code works with just ClassLearningProblem. However, the same exception as above is still being thrown when I use a real class expression.

I tested with code like the following:

        ClassExpressionLearningProblem lp = new ClassExpressionLearningProblem(rc);
        lp.setClassExpressionToDescribe(
            df.getOWLObjectHasValue(
                    df.getOWLObjectProperty(IRI.create("testProperty")),
                    df.getOWLNamedIndividual(IRI.create("testIndividual"))
            )
        );
        lp.init();

@posixcompliance
Copy link
Author

Upon further investigation I think the issue in ClassExpressionLearningProblem may be with the cast to the following class cast:

Coverage[] cc = ((ReasoningUtilsCLP)reasoningUtil).getCoverageCLP(description, classInstances, superClassInstances);

But the instance was created to be a ReasoningUtils Object by:

@SimonBin
Copy link
Member

right, but there are more subtle issues to consider in e.g. the CELOE algorithm when trying to use such a Learning Problem, which currently does too many assumptions about supported learning problems; so I fear than that needs to be done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants