Skip to content

Commit

Permalink
Change "augmented ontology" to "constrained ontology".
Browse files Browse the repository at this point in the history
  • Loading branch information
enasca committed May 25, 2017
1 parent b4d1f9c commit 6341aa2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
16 changes: 8 additions & 8 deletions src/main/java/it/poliba/enasca/ontocpnets/OntologicalCPNet.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class OntologicalCPNet extends CPNet {

/**
* The augmented ontology, constructed by adding preference domain entities to the base ontology.
* The constrained ontology, constructed by adding preference domain entities to the base ontology.
*/
OWLOntology ontology;

Expand Down Expand Up @@ -60,7 +60,7 @@ public class OntologicalCPNet extends CPNet {
/**
* @param builder
* @throws OWLOntologyCreationException if the base ontology cannot be copied into
* a local {@link OWLOntologyManager} to create the augmented ontology.
* a local {@link OWLOntologyManager} to create the constrained ontology.
*/
private OntologicalCPNet(Builder builder) throws OWLOntologyCreationException {
super(builder.baseCPNet);
Expand Down Expand Up @@ -88,12 +88,12 @@ private OntologicalCPNet(Builder builder) throws OWLOntologyCreationException {
// Copy the base ontology into a local manager.
ontology = OWLManager.createOWLOntologyManager()
.copyOntology(builder.baseOntology, OntologyCopy.SHALLOW);
// Add the new axioms to the augmented ontology.
// Add the new axioms to the constrained ontology.
if (ontology.addAxioms(Stream.concat(classDefinitions, partitions))
!= ChangeApplied.SUCCESSFULLY) {
throw new OWLRuntimeException("error while applying changes to the new ontology");
}
// Check the augmented ontology for consistency.
// Check the constrained ontology for consistency.
OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
boolean arePrefsConsistent = reasoner.isConsistent();
reasoner.dispose();
Expand Down Expand Up @@ -188,7 +188,7 @@ public Set<Outcome> paretoOptimal() throws IOException {

/**
* Creates a new buffering <code>OWLReasoner</code> using the internal {@link OWLReasonerFactory},
* with the augmented ontology as the root ontology, then executes the specified reasoning service.
* with the constrained ontology as the root ontology, then executes the specified reasoning service.
* The return value of <code>service</code> is relayed to the caller.
* After <code>service</code> returns, the reasoner is immediately disposed of.
* @param service
Expand Down Expand Up @@ -312,7 +312,7 @@ public boolean accept(IntStream branch) {
if (solver.implies(closureAsFormula, branchClause)) {
return false;
}
// Check whether the augmented ontology entails the current branch axiom.
// Check whether the constrained ontology entails the current branch axiom.
FeasibilityConstraint constraint = new FeasibilityConstraint(branchClause, domainTable);
OWLSubClassOfAxiom branchAxiom = constraint.asAxiom(concurrentDataFactory, domainTable);
if (applyService(reasoner -> reasoner.isEntailed(branchAxiom))) {
Expand Down Expand Up @@ -553,15 +553,15 @@ public Builder addPreferenceDefinition(String domainValue, OWLClassExpression de
* <pre>{@code DisjointUnion(owl:Thing, a1, a2, a3, ...)}</pre>
* is created, in order to "close down the world" with respect to preferences.
*
* <p>The augmented ontology is created by copying the base ontology into a
* <p>The constrained ontology is created by copying the base ontology into a
* local {@link OWLOntologyManager} and adding the new axioms.
*
* <p>This method fails if the invoking <code>Builder</code> is in an inconsistent state.
* For detailed information on setting the required parameters, see the javadoc
* of the remaining {@link Builder} methods.
* @return
* @throws OWLOntologyCreationException if the base ontology cannot be copied into
* a local {@link OWLOntologyManager} to create the augmented ontology.
* a local {@link OWLOntologyManager} to create the constrained ontology.
* @throws IllegalStateException if the required parameters are not set properly
*/
public OntologicalCPNet build() throws OWLOntologyCreationException {
Expand Down
32 changes: 16 additions & 16 deletions src/test/java/it/poliba/enasca/ontocpnets/OntologicalCPNetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@
public class OntologicalCPNetTest {
private OntologicalCPNet cpnet;
private ImmutableSetMultimap<String, String> preferenceVariables;
private OWLOntology augmented;
private OWLOntology constrained;
private Set<OptimalityConstraint> optimalityConstraints;
private Set<Map<String, String>> outcomesAsMaps;

@Factory(dataProvider = "factoryProvider")
public OntologicalCPNetTest(Path xmlPrefSpec, Path baseOntologyPath, Path augmentedOntologyPath,
public OntologicalCPNetTest(Path xmlPrefSpec, Path baseOntologyPath, Path constrainedOntologyPath,
ImmutableSetMultimap<String, String> preferenceVariables,
Stream<OptimalityConstraint> optimalityStream,
Stream<Map<String, String>> outcomesAsMaps)
throws Exception {
// Load the base ontology.
OWLOntology baseOntology = OWLManager.createOWLOntologyManager()
.loadOntologyFromOntologyDocument(baseOntologyPath.toFile());
// Load the augmented ontology with a different manager to avoid conflicts.
OWLOntology augmentedOntology = OWLManager.createOWLOntologyManager()
.loadOntologyFromOntologyDocument(augmentedOntologyPath.toFile());
// Load the constrained ontology with a different manager to avoid conflicts.
OWLOntology constrainedOntology = OWLManager.createOWLOntologyManager()
.loadOntologyFromOntologyDocument(constrainedOntologyPath.toFile());
// Build the mapping that will be converted into class definition axioms.
Map<String, OWLClassExpression> preferences =
collectOntologicalPreferences(augmentedOntology, preferenceVariables.values().stream());
collectOntologicalPreferences(constrainedOntology, preferenceVariables.values().stream());
// Build the current OntologicalCPNet instance.
CPNet baseCPNet = new CPNet(xmlPrefSpec, Paths.get(NuSMVRunnerTest.NUSMV_EXECUTABLE.toURI()));
OntologicalCPNet.Builder cpnetBuilder = OntologicalCPNet.builder(baseCPNet, baseOntology);
Expand All @@ -57,7 +57,7 @@ public OntologicalCPNetTest(Path xmlPrefSpec, Path baseOntologyPath, Path augmen
}
this.cpnet = cpnetBuilder.build();
this.preferenceVariables = preferenceVariables;
this.augmented = augmentedOntology;
this.constrained = constrainedOntology;
this.optimalityConstraints = optimalityStream.collect(Collectors.toSet());
this.outcomesAsMaps = outcomesAsMaps.collect(Collectors.toSet());
}
Expand All @@ -68,8 +68,8 @@ public static Object[][] factoryProvider() throws Exception {
Path hotelXMLPrefSpec = Paths.get(CPNetTest.class.getResource("/hotel_preferences.xml").toURI());
// The base ontology.
Path hotelBaseOntology = Paths.get(CPNetTest.class.getResource("/hotel_ontology.owl").toURI());
// The "augmented" ontology is constructed by adding preference definitions to the base ontology.
Path hotelAugmentedOntology = Paths.get(CPNetTest.class.getResource("/hotel_ontology_augmented.owl").toURI());
// The "constrained" ontology is constructed by adding preference definitions to the base ontology.
Path hotelConstrainedOntology = Paths.get(CPNetTest.class.getResource("/hotel_ontology_constrained.owl").toURI());
// The set of preference variables and domain values that are expected to be read from the XML spec file.
ImmutableSetMultimap<String, String> hotelPreferenceVariables =
ImmutableSetMultimap.<String, String>builder()
Expand Down Expand Up @@ -126,18 +126,18 @@ public static Object[][] factoryProvider() throws Exception {
.put("R", "Rl").put("W", "Wy").put("B", "Bn").put("C", "Cy").put("P", "Pl").build())
.build();
return new Object[][]{
{hotelXMLPrefSpec, hotelBaseOntology, hotelAugmentedOntology,
{hotelXMLPrefSpec, hotelBaseOntology, hotelConstrainedOntology,
hotelPreferenceVariables, hotelOptimalityStream, hotelOutcomes}
};
}

@Test
public void testAugmentedOntology() throws Exception {
public void testConstrainedOntology() throws Exception {
// Uncomment this line to save the ontology in the default temp directory
//cpnet.ontology.saveOntology(new RDFXMLDocumentFormat(), Files.newOutputStream(Files.createTempFile("ontology", ".owl")));
cpnet.ontology.logicalAxioms().forEach(
axiom -> Assert.assertTrue(augmented.containsAxiomIgnoreAnnotations(axiom)));
Assert.assertEquals(cpnet.ontology.getLogicalAxiomCount(), augmented.getLogicalAxiomCount());
axiom -> Assert.assertTrue(constrained.containsAxiomIgnoreAnnotations(axiom)));
Assert.assertEquals(cpnet.ontology.getLogicalAxiomCount(), constrained.getLogicalAxiomCount());
}

@Test
Expand All @@ -163,7 +163,7 @@ public void testComputeOptimum() throws Exception {
* that is for each axiom
* <pre>{@code SubClassOf(owl:Thing, ObjectUnionOf(X, Y, ...)) }</pre>
* there exists no proper subset <em>Q</em> of <em>{X, Y, ...}</em> such that
* <em>Q</em> is entailed by the augmented ontology.
* <em>Q</em> is entailed by the constrained ontology.
* @throws Exception
*/
@Test
Expand All @@ -183,10 +183,10 @@ public void testComputeClosure() throws Exception {
.map(subset -> df.getOWLSubClassOfAxiom(
df.getOWLThing(),
df.getOWLObjectUnionOf(subset)))
// Assert that the new covering axiom is not entailed by the augmented ontology.
// Assert that the new covering axiom is not entailed by the constrained ontology.
.forEach(axiom -> Assert.assertFalse(
cpnet.applyService(reasoner -> reasoner.isEntailed(axiom)),
String.format("the axiom %s is entailed by the augmented ontology", axiom)));
String.format("the axiom %s is entailed by the constrained ontology", axiom)));
}

@Test
Expand Down

0 comments on commit 6341aa2

Please sign in to comment.