fuzzy-dl-owl2 1.0.6__py3-none-any.whl → 1.0.8__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.
Files changed (86) hide show
  1. fuzzy_dl_owl2/fuzzydl/__init__.py +2 -1
  2. fuzzy_dl_owl2/fuzzydl/assertion/assertion.py +1 -0
  3. fuzzy_dl_owl2/fuzzydl/assertion/atomic_assertion.py +2 -0
  4. fuzzy_dl_owl2/fuzzydl/classification_node.py +64 -0
  5. fuzzy_dl_owl2/fuzzydl/concept/__init__.py +2 -0
  6. fuzzy_dl_owl2/fuzzydl/concept/atomic_concept.py +1 -1
  7. fuzzy_dl_owl2/fuzzydl/concept/choquet_integral.py +6 -0
  8. fuzzy_dl_owl2/fuzzydl/concept/concept.py +8 -0
  9. fuzzy_dl_owl2/fuzzydl/concept/concrete/crisp_concrete_concept.py +1 -0
  10. fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_concrete_concept.py +1 -0
  11. fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_number/triangular_fuzzy_number.py +12 -0
  12. fuzzy_dl_owl2/fuzzydl/concept/concrete/left_concrete_concept.py +3 -0
  13. fuzzy_dl_owl2/fuzzydl/concept/concrete/linear_concrete_concept.py +3 -0
  14. fuzzy_dl_owl2/fuzzydl/concept/concrete/modified_concrete_concept.py +4 -0
  15. fuzzy_dl_owl2/fuzzydl/concept/concrete/right_concrete_concept.py +2 -0
  16. fuzzy_dl_owl2/fuzzydl/concept/concrete/trapezoidal_concrete_concept.py +1 -0
  17. fuzzy_dl_owl2/fuzzydl/concept/concrete/triangular_concrete_concept.py +2 -0
  18. fuzzy_dl_owl2/fuzzydl/concept/modified/linearly_modified_concept.py +3 -0
  19. fuzzy_dl_owl2/fuzzydl/concept/modified/modified_concept.py +3 -0
  20. fuzzy_dl_owl2/fuzzydl/concept/modified/triangularly_modified_concept.py +3 -0
  21. fuzzy_dl_owl2/fuzzydl/concept/negated_nominal.py +3 -0
  22. fuzzy_dl_owl2/fuzzydl/concept/operator_concept.py +8 -0
  23. fuzzy_dl_owl2/fuzzydl/concept/qowa_concept.py +4 -0
  24. fuzzy_dl_owl2/fuzzydl/concept/quasi_sugeno_integral.py +3 -0
  25. fuzzy_dl_owl2/fuzzydl/concept/sigma_concept.py +71 -0
  26. fuzzy_dl_owl2/fuzzydl/concept/sigma_count.py +56 -0
  27. fuzzy_dl_owl2/fuzzydl/concept/sugeno_integral.py +4 -0
  28. fuzzy_dl_owl2/fuzzydl/concept_equivalence.py +5 -0
  29. fuzzy_dl_owl2/fuzzydl/concrete_feature.py +6 -0
  30. fuzzy_dl_owl2/fuzzydl/domain_axiom.py +3 -0
  31. fuzzy_dl_owl2/fuzzydl/feature_function.py +12 -3
  32. fuzzy_dl_owl2/fuzzydl/fuzzydl_to_owl2.py +3 -1
  33. fuzzy_dl_owl2/fuzzydl/general_concept_inclusion.py +6 -0
  34. fuzzy_dl_owl2/fuzzydl/individual/created_individual.py +41 -2
  35. fuzzy_dl_owl2/fuzzydl/individual/individual.py +14 -0
  36. fuzzy_dl_owl2/fuzzydl/individual/representative_individual.py +9 -0
  37. fuzzy_dl_owl2/fuzzydl/knowledge_base.py +2046 -250
  38. fuzzy_dl_owl2/fuzzydl/label.py +18 -10
  39. fuzzy_dl_owl2/fuzzydl/milp/expression.py +45 -24
  40. fuzzy_dl_owl2/fuzzydl/milp/inequation.py +20 -0
  41. fuzzy_dl_owl2/fuzzydl/milp/milp_helper.py +1398 -60
  42. fuzzy_dl_owl2/fuzzydl/milp/show_variables_helper.py +82 -0
  43. fuzzy_dl_owl2/fuzzydl/milp/solution.py +23 -0
  44. fuzzy_dl_owl2/fuzzydl/milp/term.py +4 -1
  45. fuzzy_dl_owl2/fuzzydl/milp/variable.py +7 -0
  46. fuzzy_dl_owl2/fuzzydl/modifier/linear_modifier.py +3 -0
  47. fuzzy_dl_owl2/fuzzydl/modifier/modifier.py +21 -0
  48. fuzzy_dl_owl2/fuzzydl/parser/dl_parser.py +48 -7
  49. fuzzy_dl_owl2/fuzzydl/primitive_concept_definition.py +7 -0
  50. fuzzy_dl_owl2/fuzzydl/query/__init__.py +1 -0
  51. fuzzy_dl_owl2/fuzzydl/query/all_instances_query.py +80 -1
  52. fuzzy_dl_owl2/fuzzydl/query/bnp_query.py +2 -0
  53. fuzzy_dl_owl2/fuzzydl/query/classification_query.py +26 -0
  54. fuzzy_dl_owl2/fuzzydl/query/defuzzify/defuzzify_query.py +2 -1
  55. fuzzy_dl_owl2/fuzzydl/query/defuzzify/lom_defuzzify_query.py +4 -0
  56. fuzzy_dl_owl2/fuzzydl/query/defuzzify/mom_defuzzify_query.py +6 -2
  57. fuzzy_dl_owl2/fuzzydl/query/defuzzify/som_defuzzify_query.py +2 -0
  58. fuzzy_dl_owl2/fuzzydl/query/instance_query.py +5 -0
  59. fuzzy_dl_owl2/fuzzydl/query/kb_satisfiable_query.py +12 -2
  60. fuzzy_dl_owl2/fuzzydl/query/max/max_instance_query.py +6 -1
  61. fuzzy_dl_owl2/fuzzydl/query/max/max_query.py +7 -1
  62. fuzzy_dl_owl2/fuzzydl/query/max/max_related_query.py +6 -1
  63. fuzzy_dl_owl2/fuzzydl/query/max/max_satisfiable_query.py +15 -1
  64. fuzzy_dl_owl2/fuzzydl/query/max/max_subsumes_query.py +4 -1
  65. fuzzy_dl_owl2/fuzzydl/query/min/min_instance_query.py +6 -1
  66. fuzzy_dl_owl2/fuzzydl/query/min/min_query.py +7 -1
  67. fuzzy_dl_owl2/fuzzydl/query/min/min_related_query.py +5 -1
  68. fuzzy_dl_owl2/fuzzydl/query/min/min_satisfiable_query.py +17 -1
  69. fuzzy_dl_owl2/fuzzydl/query/min/min_subsumes_query.py +47 -7
  70. fuzzy_dl_owl2/fuzzydl/query/query.py +5 -2
  71. fuzzy_dl_owl2/fuzzydl/query/related_query.py +8 -1
  72. fuzzy_dl_owl2/fuzzydl/query/satisfiable_query.py +17 -0
  73. fuzzy_dl_owl2/fuzzydl/query/subsumption_query.py +5 -0
  74. fuzzy_dl_owl2/fuzzydl/range_axiom.py +4 -0
  75. fuzzy_dl_owl2/fuzzydl/relation.py +5 -0
  76. fuzzy_dl_owl2/fuzzydl/restriction/has_value_restriction.py +2 -0
  77. fuzzy_dl_owl2/fuzzydl/restriction/restriction.py +3 -0
  78. fuzzy_dl_owl2/fuzzydl/role_parent_with_degree.py +6 -1
  79. fuzzy_dl_owl2/fuzzydl/util/config_reader.py +34 -2
  80. fuzzy_dl_owl2/fuzzydl/util/constants.py +105 -6
  81. fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2.py +3 -1
  82. fuzzy_dl_owl2-1.0.8.dist-info/METADATA +817 -0
  83. {fuzzy_dl_owl2-1.0.6.dist-info → fuzzy_dl_owl2-1.0.8.dist-info}/RECORD +85 -81
  84. fuzzy_dl_owl2-1.0.6.dist-info/METADATA +0 -340
  85. {fuzzy_dl_owl2-1.0.6.dist-info → fuzzy_dl_owl2-1.0.8.dist-info}/LICENSE +0 -0
  86. {fuzzy_dl_owl2-1.0.6.dist-info → fuzzy_dl_owl2-1.0.8.dist-info}/WHEEL +0 -0
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  import enum
2
4
  import os
3
5
  import re
4
6
  import typing
5
7
 
6
8
  import pyparsing as pp
7
- from gurobipy import GRB
8
9
 
9
10
  SEPARATOR: str = "-" * 25
10
11
  STAR_SEPARATOR: str = "*" * 25
@@ -15,6 +16,25 @@ if not os.path.exists(RESULTS_PATH):
15
16
  os.makedirs(RESULTS_PATH)
16
17
 
17
18
 
19
+ class MILPProvider(enum.StrEnum):
20
+ GUROBI = enum.auto()
21
+ MIP = enum.auto()
22
+ # SCIPY = enum.auto()
23
+ PULP = enum.auto()
24
+ PULP_GLPK = enum.auto()
25
+ PULP_HIGHS = enum.auto()
26
+ PULP_CPLEX = enum.auto()
27
+
28
+ @staticmethod
29
+ def from_str(value: str) -> typing.Self:
30
+ try:
31
+ return MILPProvider(value.lower())
32
+ except ValueError:
33
+ raise ValueError(
34
+ f"Invalid MILP provider: {value}. Valid options are: {list(MILPProvider)}"
35
+ )
36
+
37
+
18
38
  class ConcreteFeatureType(enum.Enum):
19
39
  STRING = 0
20
40
  INTEGER = 1
@@ -29,10 +49,15 @@ class ConcreteFeatureType(enum.Enum):
29
49
 
30
50
 
31
51
  class FeatureFunctionType(enum.Enum):
52
+ # Atomic feature
32
53
  ATOMIC = 0
54
+ # Numberic feature
33
55
  NUMBER = 1
56
+ # Sum function
34
57
  SUM = 2
58
+ # Subtraction function
35
59
  SUBTRACTION = 3
60
+ # Product of a number and a feature.
36
61
  PRODUCT = 5
37
62
 
38
63
  def __repr__(self) -> str:
@@ -107,6 +132,8 @@ class KnowledgeBaseRules(enum.Enum):
107
132
  RULE_NOT_HAS_VALUE = 45
108
133
  RULE_ZADEH_IMPLIES = 46
109
134
  RULE_NOT_ZADEH_IMPLIES = 47
135
+ RULE_SIGMA_COUNT = 48
136
+ RULE_NOT_SIGMA_COUNT = 49
110
137
 
111
138
  def __repr__(self) -> str:
112
139
  return str(self)
@@ -129,72 +156,142 @@ class LogicOperatorType(enum.Enum):
129
156
 
130
157
 
131
158
  class ConceptType(enum.Enum):
159
+ # Conjunction
132
160
  AND = 0
161
+ # Goedel conjunction
133
162
  GOEDEL_AND = 1
163
+ # Lukasiewicz conjunction
134
164
  LUKASIEWICZ_AND = 2
165
+ # Disjunction
135
166
  OR = 3
167
+ # Goedel disjunction
136
168
  GOEDEL_OR = 4
169
+ # Lukasiewicz disjunction
137
170
  LUKASIEWICZ_OR = 5
171
+ # Existential restriction
138
172
  SOME = 6
173
+ # Universal restriction
139
174
  ALL = 7
175
+ # Upper fuzzy rough concept
140
176
  UPPER_APPROX = 8
177
+ # Lower fuzzy rough concept
141
178
  LOWER_APPROX = 9
179
+ # Negated fuzzy number
142
180
  FUZZY_NUMBER_COMPLEMENT = 10
181
+ # Tight upper fuzzy rough concept
143
182
  TIGHT_UPPER_APPROX = 11
183
+ # Tight lower fuzzy rough concept
144
184
  TIGHT_LOWER_APPROX = 12
185
+ # Loose upper fuzzy rough concept
145
186
  LOOSE_UPPER_APPROX = 13
187
+ # Loose lower fuzzy rough concept
146
188
  LOOSE_LOWER_APPROX = 14
189
+ # Goedel implication
147
190
  GOEDEL_IMPLIES = 15
191
+ # Negated Goedel implication
148
192
  NOT_GOEDEL_IMPLIES = 16
193
+ # Atomic concept
149
194
  ATOMIC = 17
195
+ # Complement concept
150
196
  COMPLEMENT = 18
197
+ # Top concept
151
198
  TOP = 19
199
+ # Bottom concept
152
200
  BOTTOM = 20
201
+ # At most datatype restriction
153
202
  AT_MOST_VALUE = 21
203
+ # At least datatype restriction
154
204
  AT_LEAST_VALUE = 22
205
+ # Exact datatype restriction
155
206
  EXACT_VALUE = 23
207
+ # Negate at most datatype restriction
156
208
  NOT_AT_MOST_VALUE = 24
209
+ # Negate at least datatype restriction
157
210
  NOT_AT_LEAST_VALUE = 25
211
+ # Negate exact datatype restriction
158
212
  NOT_EXACT_VALUE = 26
213
+ # Weighted concept
159
214
  WEIGHTED = 27
215
+ # NEgated weighted concept
160
216
  NOT_WEIGHTED = 28
217
+ # Weighted sum concept
161
218
  W_SUM = 29
219
+ # Negated weighted sum concept
162
220
  NOT_W_SUM = 30
221
+ # Positive threshold concept
163
222
  POS_THRESHOLD = 31
223
+ # Negated positive threshold concept
164
224
  NOT_POS_THRESHOLD = 32
225
+ # Negative threshold concept
165
226
  NEG_THRESHOLD = 33
227
+ # Negated negative threshold concept
166
228
  NOT_NEG_THRESHOLD = 34
229
+ # Extended positive threshold concept
167
230
  EXT_POS_THRESHOLD = 35
231
+ # Negated extended positive threshold concept
168
232
  NOT_EXT_POS_THRESHOLD = 36
233
+ # Extended negative threshold concept
169
234
  EXT_NEG_THRESHOLD = 37
235
+ # Negated extended negative threshold concept
170
236
  NOT_EXT_NEG_THRESHOLD = 38
237
+ # Concrete concept
171
238
  CONCRETE = 39
239
+ # Negated concrete concept
172
240
  CONCRETE_COMPLEMENT = 40
241
+ # Modified concept
173
242
  MODIFIED = 41
243
+ # Negated modified concept
174
244
  MODIFIED_COMPLEMENT = 42
245
+ # Self reflexivity concept
175
246
  SELF = 43
247
+ # Fuzzy number
176
248
  FUZZY_NUMBER = 44
249
+ # OWA concept
177
250
  OWA = 45
251
+ # Quantified-guided OWA concept
178
252
  QUANTIFIED_OWA = 46
253
+ # Negated OWA concept
179
254
  NOT_OWA = 47
255
+ # Negated quantified-guided OWA concept
180
256
  NOT_QUANTIFIED_OWA = 48
257
+ # Choquet integral concept
181
258
  CHOQUET_INTEGRAL = 49
259
+ # Sugeno integral concept
182
260
  SUGENO_INTEGRAL = 50
261
+ # Quasi-Sugeno integral concept
183
262
  QUASI_SUGENO_INTEGRAL = 51
263
+ # Negated Choquet integral concept
184
264
  NOT_CHOQUET_INTEGRAL = 52
265
+ # Negated Sugeno integral concept
185
266
  NOT_SUGENO_INTEGRAL = 53
267
+ # Negated Quasi-Sugeno integral concept
186
268
  NOT_QUASI_SUGENO_INTEGRAL = 54
269
+ # Weighted maximum concept
187
270
  W_MAX = 55
271
+ # Negated weighted maximum concept
188
272
  NOT_W_MAX = 56
273
+ # Weighted minimum concept
189
274
  W_MIN = 57
275
+ # Negated weighted minimum concept
190
276
  NOT_W_MIN = 58
277
+ # Weighted sum-zero concept
191
278
  W_SUM_ZERO = 59
279
+ # Negated weighted sum-zero concept
192
280
  NOT_W_SUM_ZERO = 60
281
+ # Negated self reflexivity concept
193
282
  NOT_SELF = 61
283
+ # Has value restriction concept
194
284
  HAS_VALUE = 62
285
+ # Negated has value restriction concept
195
286
  NOT_HAS_VALUE = 63
287
+ # Zadeh'set inclusion implication, only used for min-subs queries.
196
288
  ZADEH_IMPLIES = 64
289
+ # Negated Zadeh'set inclusion implication
197
290
  NOT_ZADEH_IMPLIES = 65
291
+ # Sigma-count concept
292
+ SIGMA_CONCEPT = 66
293
+ # Negated sigma-count concept
294
+ NOT_SIGMA_CONCEPT = 67
198
295
 
199
296
  def __repr__(self) -> str:
200
297
  return self.name
@@ -206,6 +303,7 @@ class ConceptType(enum.Enum):
206
303
  class CreatedIndividualBlockingType(enum.Enum):
207
304
  BLOCKED = 0
208
305
  NOT_BLOCKED = 1
306
+ # Unchecked blocking
209
307
  UNCHECKED = 2
210
308
 
211
309
  def __repr__(self) -> str:
@@ -239,10 +337,10 @@ class InequalityType(enum.StrEnum):
239
337
 
240
338
 
241
339
  class VariableType(enum.StrEnum):
242
- BINARY = GRB.BINARY
243
- CONTINUOUS = GRB.CONTINUOUS
244
- INTEGER = GRB.INTEGER
245
- SEMI_CONTINUOUS = GRB.SEMICONT
340
+ BINARY = enum.auto()
341
+ CONTINUOUS = enum.auto()
342
+ INTEGER = enum.auto()
343
+ SEMI_CONTINUOUS = enum.auto()
246
344
 
247
345
  def __repr__(self) -> str:
248
346
  return self.name
@@ -338,6 +436,7 @@ class FuzzyDLKeyword(enum.Enum):
338
436
  FEATURE_SUB = pp.CaselessKeyword("f-")
339
437
  FEATURE_MUL = pp.CaselessKeyword("f*")
340
438
  FEATURE_DIV = pp.CaselessKeyword("f/")
439
+ SIGMA_COUNT = pp.CaselessKeyword("sigma-count")
341
440
  CRISP = pp.CaselessKeyword("crisp")
342
441
  LEFT_SHOULDER = pp.CaselessKeyword("left-shoulder")
343
442
  RIGHT_SHOULDER = pp.CaselessKeyword("right-shoulder")
@@ -421,5 +520,5 @@ class FuzzyLogic(enum.StrEnum):
421
520
 
422
521
 
423
522
  KNOWLEDGE_BASE_SEMANTICS: FuzzyLogic = FuzzyLogic.CLASSICAL
424
- MAXVAL: float = 2.147483647e12
523
+ MAXVAL: float = ((1 << 31) - 1) * 1000 # 2.147483647e12
425
524
  MAXVAL2: float = MAXVAL * 2
@@ -146,6 +146,8 @@ from pyowl2.individual.anonymous_individual import OWLAnonymousIndividual
146
146
  from pyowl2.literal.literal import OWLLiteral
147
147
  from pyowl2.ontology import OWLOntology
148
148
 
149
+ from fuzzy_dl_owl2.fuzzydl.util.config_reader import ConfigReader
150
+
149
151
 
150
152
  class FuzzyOwl2(object):
151
153
  POS_INFINITY: float = 10000.0
@@ -174,7 +176,7 @@ class FuzzyOwl2(object):
174
176
  self.ontology_iri, self.ontology_path, OWL1_annotations=True
175
177
  )
176
178
  self.fuzzy_label: OWLAnnotationProperty = OWLAnnotationProperty(
177
- IRI(self.ontology_iri.namespace, "fuzzyLabel")
179
+ IRI(self.ontology_iri.namespace, ConfigReader.OWL_ANNOTATION_LABEL)
178
180
  )
179
181
  self.ontologies.add(self.ontology)
180
182
  # self.ontologies.update(self.manager.getImportsClosure(self.ontology))