galactic.algebras.convex.strategies.examples.arithmetic.core#
galactic.algebras.convex.strategies.examples.arithmetic.core module
Defines arithmetic strategies.
- class MultipleStrategy(**data)#
Bases:
BasicStrategyGenerates a set of descriptors able to remove some elements.
Inherits from BasicStrategy and implements the _call method to produce a collection of selectors by yielding Multiple instances. The characteristic parameter must be an instance of Integer, defining the nature of the multiples described. It is typically used to specify the integer characteristic in arithmetic contexts.
- Parameters:
space (tuple[Integer]) – A tuple containing a single Integer characteristic that defines the nature of the multiples described by this strategy.
- ALIAS#
The alias of the type in the resource registry.
- Type:
ClassVar[str] = “examples.core.strategy.Multiple”
Examples
>>> from galactic.algebras.concept.core import ItemUniverse >>> from galactic.algebras.convex.characteristics.core import Component, Integer >>> from galactic.algebras.convex.descriptions.core import ( ... PredicateUniverse, ... Context, ... GaloisConnection, ... Concept, ... ) >>> from galactic.algebras.convex.strategies.examples.arithmetic.core import ( ... MultipleStrategy, ... ) >>> from galactic.algebras.convex.descriptions.examples.arithmetic.core import ( ... MultipleDescription, ... DivisorDescription, ... ) >>> dataset = [36, 48, 16] >>> domain = ItemUniverse(dataset) >>> characteristic = Integer(components=(Component(),)) >>> descriptions = ( ... DivisorDescription(space=(characteristic,)), ... MultipleDescription(space=(characteristic,)), ... ) >>> co_domain = PredicateUniverse(descriptions=descriptions) >>> context = Context(domain, co_domain) >>> connection = GaloisConnection(context) >>> concept = Concept(connection) >>> [str(attr) for attr in concept.intent] ['D(int(@),144)', 'M(int(@),4)'] >>> strategy = MultipleStrategy(space=(characteristic,)) >>> [[str(attr) for attr in sub.intent] for sub in strategy(concept)] [['D(int(@),144)', 'M(int(@),4)', 'M(int(@),3)'], ['D(int(@),48)', 'M(int(@),16)']] >>> [[item.key for item in sub.extent] for sub in strategy(concept)] [[0, 1], [1, 2]]
Configuration
If you want to specify a multiple strategy in a TOML file, you can use the following syntax:
[components.my_component] "$type" = "core.Component" expr = "value" [characteristics.my_characteristic] "$type" = "core.characteristic.Integer" components = [ {"$ref" = "components.my_component"} ] name = "my_name" [strategies.my_strategy] "$type" = "examples.core.strategy.Multiple" space = [ {"$ref" = "characteristics.my_characteristic"} ]
- Raises:
TypeError – If the characteristic is not an instance of Integer
ValueError – If the space does not have the required number of elements