I am working on an object diagram and would like to use this kind of notation:
To convey a disjoint. Is there a way to do this?
In your picture you have Entity-Relationship diagram, which has nothing to do with UML. Likewise UML Object diagram is concerned with visualizing actual instances, so my guess is that you were looking for Class Diagram.
In UML, you could model this as a generalization set
hide circle
class Patient
Patient <|-- Outpatient
Patient <|-- Resident
GeneralizationSet ..(Patient, Outpatient)
(Patient, Resident) .. GeneralizationSet
class GeneralizationSet {
isDisjoint = true
}
the isDisjoint = true tells us that it can be either one or the other, but not both.
Related
I am reading Autosar document and in one of the document (Autosar_TemplateModelingGuideline.pdf), it says that:
Composite aggregation, forming a whole-part relationship
Regular association, expressing a reference from the associating to
the associated model element
My question is: what is the difference between these two in practice? How do I have to interpret them in a class diagram, e.g. the Com Module in Autosar.:
The AUTOSAR COM module’s Configuration Overview
Consider Specified class ComGwSignalRef surrounded with a red rectangle. This class has a composition relation with ComGwSignalRef class and two regular association with ComGroupSignal and ComSignal.
How would you interpret this as a developer and how do you implement in C?
if regular association is a reference to an object that has independent life from ComGwSignalRef why designer do not use instanceRef here?
if it is not a reference, why did the designer not use composition?
PS. There is a concept in Autosar "InstanceRef" which is used for reference for independent object with independent lifecycle.
Maybe you should also consider the following:
The Com Configuration is an instance of the EcuC configuration meta-model as defined in the AUTOSAR_TPS_EcuConfiguration.
The ComGwSignalRef is of type EcucChoiceContainerDef, and as such, the two destination associations of ComSignal and ComGroupSignal have a meaning. Only one of these "choices" can be selected in the final configuration as a reference. In AUTOSAR metamodel, that is the definition of how EcucChoiceContainerDef works, in UML you might need here an additional constraint element to define the XOR relation of two associations.
An object can only be composed as part of one object.
A <>- C -<>B
In the diagram above C is composed in A and B. This would lead to the following instances:
a: A <>- c: C -<> b:B
Now the specific instance c is now part of both a and b.
What happen would with c if b goes out of scope? By the semantics it should be destroyed and not be destroyed (a still exists).
Or more pointed:
Take Alice,Bob, and Collar Bone as examples. Alice’s collar bone cannot be part of Bob.
UML is a modeling language and has not the same expressiveness as, say a C compiler. This is by design to simplify things.
Remember: All models are wrong, but some are useful. — George E. P. Box
I tried to use the same object property between multiple classes, but I got a warning that the same object property has been set multiple times as follows, can you please let me know what is wrong with that and how to solve it? Does this restrict reasoning later on (i.e. confuse the reasoner since the same object property is set multiple times)?
Thanks
Contrary to the comments it actually is very problematic to use the same object property between multiple classes.
What you don't see in your visualization is that in RDF/OWL, the starting point of your relation arrows is modelled as rdfs:domain and the target point of the arrows is modelled as rdfs:range.
The semantic of an OWL class is that it is a set of individuals and rdfs:domain and rdfs:range specify the domain, respectively range of a relation. That is, they specify the sets of allowed values in subject, respectively object position of a triple with that relation in the predicate position.
If you express your example in RDF Turtle it would look like this:
:hasPart rdfs:domain :ClassA, :ClassB;
rdfs:range :ClassB, :ClassC, :ClassD.
This causes multiple problems:
Intersection
The semantic of multiple domains, respectively ranges, is the intersection of those classes, not the union!
Even if we disregard the relation between :ClassB and :ClassD, this means :hasPart is only allowed by individuals that are instances of class C and class D at the same time!
For example, lets say class A is "car", class B is "tire" and class C is "motor". Now you want to say that a car can have tires and motors but what you actually specify is that a car can only have things that are a motor and a tire at the same time!
Unwanted but allowed usage
If you fix the first problem but specifying the union instead of the intersection, it will be very messy in serialized RDF because you need a large amount of triples to represent OWL restrictions such as unions. But even if you do that, you could now connect an instance of class A with an instance of class D, which is not allowed in the image.
Solution
The solution is simple, just separate those relations, for example into :hasB, :hasC and :hasD, although in a real scenario you can probably find a more suitable naming scheme, where the "has" prefix is often not used. For example, in DBpedia, the property for the country of a city is expressed using dbo:country, not dbo:hasCountry.
This question is about Ontologies , I am implementing an ontology about potential physical attacks on wireless sensors as devices.
I created class Modification_Attack meaning attacks which modify in the sensor itself. I created Programming_Modification as an instance of this class, is this logical, is it better a sub-class or neither an instance nor a sub-class?
What is the main difference between instances and sub-classes?
This question isn't really unique to OWL ontologies; it comes up in object-oriented programming, and in set theory in mathematics. A class is a collection of its members. E.g.,
Person ≡ { person1, person2, … }
Suppose you have another class:
TallPerson ≡ { person63, person102, … }
A class A is a subclass of the class B if every element of A is also an element of B:
(A ⊆ B) ≡ (x ∈ A → x ∈ B)
So, for instance, if every member of TallPerson is also a member of Person, then TallPerson is a subclass of Person.
I created class Modification_Attack meaning attacks which modify in
the sensor itself.I created Programming_Modification as an instance of
this class , is this logical , is it better a sub-class or neither an
instance nor a sub-class?
This is a choice that you need to make. It really depends on the context and how you intend to use the ontology. If you're observing attacks in the wild and trying to categorize them, you probably want a subclass, but you'll want to have instances of Programming_Modification. That is, you'll want something like:
Programming_Modification ≡ { attack24, attack89, … }
But if you've got some other kind of use case, where you you want to talk about Programming_Modification as a single entity, then it might make more sense for it to be an individual.
I have been thinking through the same issue. And I think the same thing can be both an instance and a subclass depending on whether you plan to use it conceptually or not, which can be simplified to whether you would describe it using the or a.
For example, I am working on a materials ontology, where the main class is Material. A particular type of material is Steel. If I say the steel then steel an instance of Material. If I say a steel then Steel is a subclass of Material. Further, steel is an instance of Steel. And it would be more appropriate to also give it some kind of meaningful identifier like steel-1.
It all seems to come down whether you are using a term as a conceptual class or as a name for some instance of that class. In your case, I think it would probably be more appropriate to say Programming_Modification is a subclass as you could probably have many of such modifications which you would refer to as the first Programming_Modification or the second Programming_Modification . Would love to see what you came up with though if you have a solution.
I have modelled the following in my Ontology:
Club employs some Player, Player hasNationality some Nationality, Player hasNationalStatus value National_Player, Country is equivalent to Nationality.
I want the Ontology to infer that:
If a Player hasNationality some Nationality and, Player hasNationalStatus value National_Player then, Country(Same as the nationality the player has) employs Player.
As an example:
{Steven_Gerrard} hasNationality value England and, {Steven_Gerrard} hasNationalStatus value National_Player therefore, {England} employs [Steven_Gerrard}.
Is there a possible way to add this knowledge to Protege?
Thanks.
Edit:
Error Messages:
Error 42 Logged at Tue Apr 01 20:49:24 BST 2014
OWLReasonerRuntimeException: Non-simple object property 'http://www.semanticweb.org/u1cjd/ontologies/2014/1/untitled-ontology-2#employs' is used as a simple one
and
Error 43 Logged at Tue Apr 01 20:49:24 BST 2014
ReasonerInternalException: tRole.cpp:243: assertion 'Ancestor.empty() && Descendant.empty()' fails
This is possible, and it's actually very similar to the technique I mentioned in an answer to your previous question, Adding statements of knowledge to an OWL Ontology in Protege), and the structure of this answer is almost identical to my answer to a recent answers.semanticweb.com question, OWL property inference from blank node - modelling.
You just need to use some rolification and a property chain axiom. The point to note is that the existing data has the form of the upper arrows, and the desired information is in the lower arrows.
It's not enough to give employs the subproperty hasNationality-1, because you want to ensure that the player has a particular national status. This is where you need rolification. You want employs to have a subproperty chain of hasNationality-1 • p, where p is a special property that only relates players with national status to themselves. You can do that with rolification. Just declare a new object property RNationalPlayers and assert the axioms
hasNationalStatus value National_Player EquivalentTo R_NationalPlayer some Self
inverse(hasNationality) o R_NationalPlayer subPropertyOf employs
In the description logic syntax, these would be something like:
=hasNationalStatus.National_Player ≡ ∃RNationalPlayer.Self
hasNationality-1 • RNationalPlayer ⊑ employs
This will work in some reasoners, but unfortunately, this does bring us out of OWL 2 DL and into OWL full. This was discussed in some detail in the comments on this answer. As the error message in the updated question indicates, employs is now a non-simple property, and used in a place where only simple properties should be used. See 11.1 Property Hierarchy and Simple Object Property Expressions for more about what makes a property simple or not, and 11.2 The Restrictions on the Axiom Closure for more about properties can appear where.
However, it sounds like you're using a reasoner that supports SWRL rules, in which case you could simply add the rule:
hasNationality(?player,?country) ∧ hasNationalStatus(?player,National_Player) → employs(?country,?player)
The problem domain features a large population of named snarks. Some of the snarks are boojums.
There are at least two ways to model this:
// as a property:
class Snark {
string name;
bool is_boojum;
};
// as a list:
class Snark {
typedef long Id;
Id id;
string name;
};
tree<Snark::Id> boojums;
It seems intuitive that if we determined that snarks come in male and female, we would add a "sex" property to the snark class definition; and if we determined that all but five snarks were vanquished subjects, we would make a list of royals.
Are there principles one can apply, or is it a matter of architectural preference?
What problem are you trying to solve?
If the purpose of recording the royalty of the snarks is to display a crown on their heads in the GUI, then it makes sense for it to merely be an attribute. (Alternatively, there could be a RoyalSnark subclass, with an overridden Render method.)
If the purpose is to quickly find all the royal snarks, then a list is more appropriate - otherwise you would need to look at every snark and check its attribute.
I believe that the information entropy associated with the classification can be a guide to which method to use. Low-entropy classifications (i.e. most of the objects have the same value) suggest a list implementation tracking the exceptional cases, while high-entropy classifications (you cannot make any very good predictions about which classification an object will have) suggest a property implementation.
As a derived class:
class Snark
{
virtual void Approach(Creature& approacher) {};
};
class Boojum : public Snark
{
virtual void Approach(Creature& approacher)
{
approacher.softlySuddenlyVanishAway();
}
};
That natural way to do it seems to be a property in all cases.
You might use a list for performance, or to optimise space. Both reasons strike me as potential cases of premature optimisation, breaking encapsulation, and/or storing redundant data with the consequent risk of lack of integrity (because I should still be able to query the object itself to find out if it is royal - I shouldn't have to know that this property is handled in a special way for reasons of performance). You could I suppose hide the list implementation behind a getter, to make it behave as a property.
Also, if these objects were stored in a DB, the performance issue pretty much goes away as the DB layer can create the list at runtime using a query anyway.
If you're asking about database modeling, then it's most straightforward to treat is_boojum as an attribute column in the table Snarks. If you need to search for all boojums, the query is simple:
SELECT * FROM Snarks WHERE is_boojum = 1
This gives logically correct answers, and it's easy to model. It might not be so speedy, because indexing a column with low selectivity (many rows with identical values) isn't very efficient, and might not benefit from the index at all.
But your question was about modeling, not optimization.
Hmmm. My first thought is that, indeed, Boojum is a subtype of Snark. but the specification seems to argue against it, for "the snark was a boojum, you see." Well, that means the snark is_a Boojum, and that would make the inheritance graph cyclic. Can't have that.
On the other hand, I do'nt think there's any indication that a Snark can become a Boojum; either it's a Boojum or it's not.
I think probably you want a Boojum mixin --
abstract class Snark { /*...*/ };
class PlainSnark extends Snark {/*...*/};
class RoyalSnark extends Snark implements Boojum {/*...*/};