get role fillers performance after ontology realisation
The example of the problem is shown by using the following script
The last few lines are
start = time.monotonic()
reasoner.realise()
duration = time.monotonic() - start
print('debug:')
# 8, 12 and 15: norwegian smokes kools and lives in house1
is_same('x3', 'x7')
is_same('house1', 'h10')
# ... h11 is next to house1, so h11 is house2
is_same('house2', 'h11')
is_related_to('yellow', 'color of', reasoner.inverse(has_color))
is_related_to('blue', 'color of', reasoner.inverse(has_color))
is_related_to('red', 'color of', reasoner.inverse(has_color))
is_related_to('ivory', 'color of', reasoner.inverse(has_color))
is_related_to('green', 'color of', reasoner.inverse(has_color))
print('\nsolution:')
# norwegian expected
is_related_to('water', 'is drunk by', reasoner.inverse(drinks))
# japanese expected
is_related_to('zebra', 'is owned by', reasoner.inverse(has_pet))
print('\nsolved in {:.2f}s'.format(duration))
On my machine, the reasoner.realise()
call takes about 41s. Seems about the same when using Protege and FaCT++ plugin.
Then there are is_related_to
calls, which use get role fillers method. Each of this call takes about 2s (adding inverse definition of has_color
, has_pet
and drink
properties before the reasoner realisation does not change the timing).
This surprises me because the ontology is fully classified and realised at this stage. After looking into the FaCT++ code it seems for each (individual, role)
pair a cache is created (indeed, 2nd call for the same pair is much faster). Considering that there are a few properties and individuals, the execution time of creating a cache for each pair seems quite high.
Do I miss some call in FaCT++, which could speed up above? If required I can recreate the Zebra puzzle example using C++.