fuzzy-dl-owl2 1.0.7__py3-none-any.whl → 1.0.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fuzzy_dl_owl2/fuzzydl/__init__.py +2 -1
- fuzzy_dl_owl2/fuzzydl/assertion/assertion.py +1 -0
- fuzzy_dl_owl2/fuzzydl/assertion/atomic_assertion.py +2 -0
- fuzzy_dl_owl2/fuzzydl/classification_node.py +64 -0
- fuzzy_dl_owl2/fuzzydl/concept/__init__.py +2 -0
- fuzzy_dl_owl2/fuzzydl/concept/atomic_concept.py +1 -1
- fuzzy_dl_owl2/fuzzydl/concept/choquet_integral.py +6 -0
- fuzzy_dl_owl2/fuzzydl/concept/concept.py +8 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/crisp_concrete_concept.py +1 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_concrete_concept.py +1 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_number/triangular_fuzzy_number.py +12 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/left_concrete_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/linear_concrete_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/modified_concrete_concept.py +4 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/right_concrete_concept.py +2 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/trapezoidal_concrete_concept.py +1 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/triangular_concrete_concept.py +2 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/linearly_modified_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/modified_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/triangularly_modified_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/negated_nominal.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/operator_concept.py +8 -0
- fuzzy_dl_owl2/fuzzydl/concept/qowa_concept.py +4 -0
- fuzzy_dl_owl2/fuzzydl/concept/quasi_sugeno_integral.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/sigma_concept.py +71 -0
- fuzzy_dl_owl2/fuzzydl/concept/sigma_count.py +56 -0
- fuzzy_dl_owl2/fuzzydl/concept/sugeno_integral.py +4 -0
- fuzzy_dl_owl2/fuzzydl/concept_equivalence.py +5 -0
- fuzzy_dl_owl2/fuzzydl/concrete_feature.py +6 -0
- fuzzy_dl_owl2/fuzzydl/domain_axiom.py +3 -0
- fuzzy_dl_owl2/fuzzydl/feature_function.py +3 -0
- fuzzy_dl_owl2/fuzzydl/fuzzydl_to_owl2.py +169 -27
- fuzzy_dl_owl2/fuzzydl/general_concept_inclusion.py +6 -0
- fuzzy_dl_owl2/fuzzydl/individual/created_individual.py +41 -2
- fuzzy_dl_owl2/fuzzydl/individual/individual.py +14 -0
- fuzzy_dl_owl2/fuzzydl/individual/representative_individual.py +9 -0
- fuzzy_dl_owl2/fuzzydl/knowledge_base.py +2033 -249
- fuzzy_dl_owl2/fuzzydl/label.py +18 -10
- fuzzy_dl_owl2/fuzzydl/milp/expression.py +33 -23
- fuzzy_dl_owl2/fuzzydl/milp/inequation.py +8 -0
- fuzzy_dl_owl2/fuzzydl/milp/milp_helper.py +720 -22
- fuzzy_dl_owl2/fuzzydl/milp/show_variables_helper.py +82 -0
- fuzzy_dl_owl2/fuzzydl/milp/solution.py +23 -0
- fuzzy_dl_owl2/fuzzydl/milp/variable.py +7 -0
- fuzzy_dl_owl2/fuzzydl/modifier/linear_modifier.py +3 -0
- fuzzy_dl_owl2/fuzzydl/modifier/modifier.py +21 -0
- fuzzy_dl_owl2/fuzzydl/parser/dl_parser.py +48 -7
- fuzzy_dl_owl2/fuzzydl/primitive_concept_definition.py +7 -0
- fuzzy_dl_owl2/fuzzydl/query/__init__.py +1 -0
- fuzzy_dl_owl2/fuzzydl/query/all_instances_query.py +80 -1
- fuzzy_dl_owl2/fuzzydl/query/bnp_query.py +2 -0
- fuzzy_dl_owl2/fuzzydl/query/classification_query.py +26 -0
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/defuzzify_query.py +2 -1
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/lom_defuzzify_query.py +4 -0
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/mom_defuzzify_query.py +6 -2
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/som_defuzzify_query.py +2 -0
- fuzzy_dl_owl2/fuzzydl/query/instance_query.py +5 -0
- fuzzy_dl_owl2/fuzzydl/query/kb_satisfiable_query.py +12 -2
- fuzzy_dl_owl2/fuzzydl/query/max/max_instance_query.py +6 -1
- fuzzy_dl_owl2/fuzzydl/query/max/max_query.py +7 -1
- fuzzy_dl_owl2/fuzzydl/query/max/max_related_query.py +6 -1
- fuzzy_dl_owl2/fuzzydl/query/max/max_satisfiable_query.py +15 -1
- fuzzy_dl_owl2/fuzzydl/query/max/max_subsumes_query.py +4 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_instance_query.py +6 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_query.py +7 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_related_query.py +5 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_satisfiable_query.py +17 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_subsumes_query.py +47 -7
- fuzzy_dl_owl2/fuzzydl/query/query.py +5 -2
- fuzzy_dl_owl2/fuzzydl/query/related_query.py +8 -1
- fuzzy_dl_owl2/fuzzydl/query/satisfiable_query.py +17 -0
- fuzzy_dl_owl2/fuzzydl/query/subsumption_query.py +5 -0
- fuzzy_dl_owl2/fuzzydl/range_axiom.py +4 -0
- fuzzy_dl_owl2/fuzzydl/relation.py +5 -0
- fuzzy_dl_owl2/fuzzydl/restriction/has_value_restriction.py +2 -0
- fuzzy_dl_owl2/fuzzydl/restriction/restriction.py +3 -0
- fuzzy_dl_owl2/fuzzydl/role_parent_with_degree.py +6 -1
- fuzzy_dl_owl2/fuzzydl/util/config_reader.py +17 -27
- fuzzy_dl_owl2/fuzzydl/util/constants.py +100 -0
- fuzzy_dl_owl2-1.0.9.dist-info/METADATA +848 -0
- {fuzzy_dl_owl2-1.0.7.dist-info → fuzzy_dl_owl2-1.0.9.dist-info}/RECORD +83 -79
- fuzzy_dl_owl2-1.0.7.dist-info/METADATA +0 -408
- {fuzzy_dl_owl2-1.0.7.dist-info → fuzzy_dl_owl2-1.0.9.dist-info}/LICENSE +0 -0
- {fuzzy_dl_owl2-1.0.7.dist-info → fuzzy_dl_owl2-1.0.9.dist-info}/WHEEL +0 -0
fuzzy_dl_owl2/fuzzydl/label.py
CHANGED
|
@@ -6,10 +6,28 @@ from fuzzy_dl_owl2.fuzzydl.degree.degree_numeric import DegreeNumeric
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class Label:
|
|
9
|
+
"""
|
|
10
|
+
Label (weighted concept used in created individuals)
|
|
11
|
+
"""
|
|
12
|
+
|
|
9
13
|
def __init__(self, concept: Concept, weight: Degree) -> None:
|
|
10
14
|
self.concept: Concept = concept
|
|
15
|
+
# Weight in [0,1]
|
|
11
16
|
self.weight: Degree = weight
|
|
12
17
|
|
|
18
|
+
@staticmethod
|
|
19
|
+
def weights_equal(w1: Degree, w2: Degree) -> bool:
|
|
20
|
+
"""
|
|
21
|
+
Checks if two degrees are equal
|
|
22
|
+
"""
|
|
23
|
+
if not w1.__class__ == w2.__class__:
|
|
24
|
+
return False
|
|
25
|
+
return (
|
|
26
|
+
not w1.is_numeric()
|
|
27
|
+
or typing.cast(DegreeNumeric, w1).get_numerical_value()
|
|
28
|
+
== typing.cast(DegreeNumeric, w2).get_numerical_value()
|
|
29
|
+
)
|
|
30
|
+
|
|
13
31
|
def __str__(self) -> str:
|
|
14
32
|
return f"{self.concept} {self.weight}"
|
|
15
33
|
|
|
@@ -20,13 +38,3 @@ class Label:
|
|
|
20
38
|
|
|
21
39
|
def __ne__(self, cw: typing.Self) -> bool:
|
|
22
40
|
return not (self == cw)
|
|
23
|
-
|
|
24
|
-
@staticmethod
|
|
25
|
-
def weights_equal(w1: Degree, w2: Degree) -> bool:
|
|
26
|
-
if not w1.__class__ == w2.__class__:
|
|
27
|
-
return False
|
|
28
|
-
return (
|
|
29
|
-
not w1.is_numeric()
|
|
30
|
-
or typing.cast(DegreeNumeric, w1).get_numerical_value()
|
|
31
|
-
== typing.cast(DegreeNumeric, w2).get_numerical_value()
|
|
32
|
-
)
|
|
@@ -8,12 +8,13 @@ from fuzzy_dl_owl2.fuzzydl.util import constants
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class Expression:
|
|
11
|
+
"""Linear expression of the form c + c1 * x1 + c2 * x2 + ... + cN * xN"""
|
|
11
12
|
|
|
12
13
|
@typing.overload
|
|
13
|
-
def __init__(self, constant:
|
|
14
|
+
def __init__(self, constant: constants.NUMBER) -> None: ...
|
|
14
15
|
|
|
15
16
|
@typing.overload
|
|
16
|
-
def __init__(self, constant:
|
|
17
|
+
def __init__(self, constant: constants.NUMBER, *terms: Term) -> None: ...
|
|
17
18
|
|
|
18
19
|
@typing.overload
|
|
19
20
|
def __init__(self, *terms: Term) -> None: ...
|
|
@@ -48,16 +49,17 @@ class Expression:
|
|
|
48
49
|
else:
|
|
49
50
|
raise ValueError
|
|
50
51
|
|
|
51
|
-
def __expression_init_1(self, constant:
|
|
52
|
+
def __expression_init_1(self, constant: constants.NUMBER) -> None:
|
|
52
53
|
assert isinstance(constant, constants.NUMBER)
|
|
53
|
-
|
|
54
|
+
# oefficient c
|
|
55
|
+
self.constant: constants.NUMBER = constant
|
|
56
|
+
# Terms c1 * x1 + c2 * x2 + ...
|
|
54
57
|
self.terms: list[Term] = []
|
|
55
58
|
|
|
56
|
-
def __expression_init_2(
|
|
57
|
-
self, constant: typing.Union[int, float], *terms: Term
|
|
58
|
-
) -> None:
|
|
59
|
+
def __expression_init_2(self, constant: constants.NUMBER, *terms: Term) -> None:
|
|
59
60
|
assert len(terms) > 0
|
|
60
61
|
self.__expression_init_1(constant)
|
|
62
|
+
# Terms c1 * x1 + c2 * x2 + ...
|
|
61
63
|
self.terms: list[Term] = [t for t in terms]
|
|
62
64
|
|
|
63
65
|
def __expression_init_3(self, *terms: Term) -> None:
|
|
@@ -74,10 +76,10 @@ class Expression:
|
|
|
74
76
|
def get_terms(self) -> list[Term]:
|
|
75
77
|
return self.terms
|
|
76
78
|
|
|
77
|
-
def get_constant(self) ->
|
|
79
|
+
def get_constant(self) -> constants.NUMBER:
|
|
78
80
|
return self.constant
|
|
79
81
|
|
|
80
|
-
def set_constant(self, constant:
|
|
82
|
+
def set_constant(self, constant: constants.NUMBER) -> None:
|
|
81
83
|
self.constant = constant
|
|
82
84
|
|
|
83
85
|
def clone(self) -> typing.Self:
|
|
@@ -85,18 +87,20 @@ class Expression:
|
|
|
85
87
|
|
|
86
88
|
@staticmethod
|
|
87
89
|
def negate_expression(expr: typing.Self) -> typing.Self:
|
|
90
|
+
"""Changes the sign of all the elements of an expression."""
|
|
88
91
|
return -expr
|
|
89
92
|
|
|
90
93
|
@staticmethod
|
|
91
|
-
def add_constant(
|
|
92
|
-
|
|
93
|
-
) -> typing.Self:
|
|
94
|
+
def add_constant(expr: typing.Self, constant: constants.NUMBER) -> typing.Self:
|
|
95
|
+
"""Adds a constant to an expression."""
|
|
94
96
|
return constant + expr
|
|
95
97
|
|
|
96
98
|
def increment_constant(self) -> None:
|
|
99
|
+
"""Increments the constant in one."""
|
|
97
100
|
self.constant += 1
|
|
98
101
|
|
|
99
102
|
def add_term(self, term: Term) -> None:
|
|
103
|
+
"""Adds a term to an expression."""
|
|
100
104
|
for idx, t in enumerate(self.terms):
|
|
101
105
|
if t.get_var() == term.get_var():
|
|
102
106
|
self.terms[idx] = t + term
|
|
@@ -106,25 +110,28 @@ class Expression:
|
|
|
106
110
|
|
|
107
111
|
@staticmethod
|
|
108
112
|
def add_term_(exp: typing.Self, term: Term) -> typing.Self:
|
|
109
|
-
|
|
113
|
+
"""Adds a term to an expression."""
|
|
114
|
+
curr_expr: Expression = Expression(exp)
|
|
110
115
|
curr_expr.add_term(term)
|
|
111
116
|
return curr_expr
|
|
112
117
|
|
|
113
118
|
@staticmethod
|
|
114
119
|
def add_expressions(expr1: typing.Self, expr2: typing.Self) -> typing.Self:
|
|
120
|
+
"""Adds two expressions."""
|
|
115
121
|
return expr1 + expr2
|
|
116
122
|
|
|
117
123
|
@staticmethod
|
|
118
124
|
def subtract_expressions(expr1: typing.Self, expr2: typing.Self) -> typing.Self:
|
|
125
|
+
"""Substracts two expressions."""
|
|
119
126
|
return expr1 - expr2
|
|
120
127
|
|
|
121
128
|
@staticmethod
|
|
122
|
-
def multiply_constant(
|
|
123
|
-
|
|
124
|
-
) -> typing.Self:
|
|
129
|
+
def multiply_constant(expr: typing.Self, constant: constants.NUMBER) -> typing.Self:
|
|
130
|
+
"""Multiplies a constant and an expression."""
|
|
125
131
|
return expr * constant
|
|
126
132
|
|
|
127
|
-
def get_constant_term(self, var: Variable) ->
|
|
133
|
+
def get_constant_term(self, var: Variable) -> constants.NUMBER:
|
|
134
|
+
"""Given a variable, gets its coefficient in the expression."""
|
|
128
135
|
for term in self.terms:
|
|
129
136
|
if term.get_var() == var:
|
|
130
137
|
return term.get_coeff()
|
|
@@ -148,25 +155,25 @@ class Expression:
|
|
|
148
155
|
result.constant += value.get_constant()
|
|
149
156
|
return result
|
|
150
157
|
|
|
151
|
-
def __radd__(self, scalar:
|
|
158
|
+
def __radd__(self, scalar: constants.NUMBER) -> typing.Self:
|
|
152
159
|
return self + scalar
|
|
153
160
|
|
|
154
161
|
def __sub__(self, expr: typing.Union[int, float, typing.Self, Term]) -> typing.Self:
|
|
155
162
|
return self + (-expr)
|
|
156
163
|
|
|
157
|
-
def __rsub__(self, scalar:
|
|
164
|
+
def __rsub__(self, scalar: constants.NUMBER) -> typing.Self:
|
|
158
165
|
return -self + scalar
|
|
159
166
|
|
|
160
|
-
def __mul__(self, scalar:
|
|
167
|
+
def __mul__(self, scalar: constants.NUMBER) -> typing.Self:
|
|
161
168
|
return Expression(
|
|
162
169
|
self.get_constant() * scalar,
|
|
163
170
|
*[t * scalar for t in self.get_terms()],
|
|
164
171
|
)
|
|
165
172
|
|
|
166
|
-
def __rmul__(self, scalar:
|
|
173
|
+
def __rmul__(self, scalar: constants.NUMBER) -> typing.Self:
|
|
167
174
|
return self * scalar
|
|
168
175
|
|
|
169
|
-
def __truediv__(self, scalar:
|
|
176
|
+
def __truediv__(self, scalar: constants.NUMBER) -> typing.Self:
|
|
170
177
|
return self * (1 / scalar)
|
|
171
178
|
|
|
172
179
|
def __hash__(self) -> int:
|
|
@@ -175,7 +182,9 @@ class Expression:
|
|
|
175
182
|
def __eq__(self, value: typing.Self) -> bool:
|
|
176
183
|
if not isinstance(value, Expression):
|
|
177
184
|
return False
|
|
178
|
-
return len(self.terms) == len(value.terms) and all(
|
|
185
|
+
return len(self.terms) == len(value.terms) and all(
|
|
186
|
+
term in value.terms for term in self.terms
|
|
187
|
+
)
|
|
179
188
|
|
|
180
189
|
def __ne__(self, value: typing.Self) -> bool:
|
|
181
190
|
return not (self == value)
|
|
@@ -184,6 +193,7 @@ class Expression:
|
|
|
184
193
|
return str(self)
|
|
185
194
|
|
|
186
195
|
def __str__(self) -> str:
|
|
196
|
+
"""Gets a printable name of the expression."""
|
|
187
197
|
parts: list[str] = []
|
|
188
198
|
if self.constant != 0.0:
|
|
189
199
|
parts.append(str(self.constant))
|
|
@@ -6,9 +6,15 @@ from fuzzy_dl_owl2.fuzzydl.util.constants import InequalityType
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class Inequation:
|
|
9
|
+
"""
|
|
10
|
+
Inequality of the form c + c1 * x1 + c2 * x2 + ... (>= | <= | =) 0.
|
|
11
|
+
"""
|
|
12
|
+
|
|
9
13
|
def __init__(self, exp: Expression, i_type: InequalityType) -> None:
|
|
10
14
|
assert exp is not None and len(exp.get_terms()) > 0
|
|
15
|
+
# Type of the inequality
|
|
11
16
|
self.type: InequalityType = i_type
|
|
17
|
+
# Expression
|
|
12
18
|
self.expr: Expression = exp
|
|
13
19
|
|
|
14
20
|
@staticmethod
|
|
@@ -36,6 +42,7 @@ class Inequation:
|
|
|
36
42
|
return self.type
|
|
37
43
|
|
|
38
44
|
def get_string_type(self) -> str:
|
|
45
|
+
"""Gets a string representation of the type."""
|
|
39
46
|
if self.type == InequalityType.EQUAL:
|
|
40
47
|
return self.type.value
|
|
41
48
|
elif self.type == InequalityType.LESS_THAN:
|
|
@@ -59,6 +66,7 @@ class Inequation:
|
|
|
59
66
|
return str(self)
|
|
60
67
|
|
|
61
68
|
def __str__(self) -> str:
|
|
69
|
+
"""Gets a printable name of the object."""
|
|
62
70
|
return f"{self.expr} {self.get_string_type()} 0"
|
|
63
71
|
|
|
64
72
|
|