Skip to main content

Cpp implementation of the lib fca_algorithms

Project description

build

FCA algorithms C++ Implementation

This projects is the version of the fca_algorithms PyPi module implemented in C++.

Purpose

The goal of this project is to eventually replace totally the implementation of the Python library with backend C++, and just leave the Python interface.

So far, the only ported algorithm is inclose.

Performance

Unsurprisingly, this implementation runs much faster than the one done totally in python. In the following, we can see an example of the difference in runtimes using get_concepts method from the Context class of both fca_algorithms<=0.2.x and fca_algorithms_cpp.

test1

test2

After running these tests, I decided to use this library in the Python one so that at least the code can take advantage of the faster implementation of inclose.

Future Work

As said before, the ideal would be to fully implement the CPU-intensive algorithms in C++ and maintain the Python interface. Considering this, the goal would be to eventually replace the python code with full C++ one.

Usage

There are one function and two classes that are exported to Python

from fca_algorithms_cpp import ContextCpp, ConceptCpp, inclose


# inclose: (List[str] -> List[str] -> List[List[int]]) -> List[ConceptCpp]
inclose(['g1', 'g2'], ['m1', 'm2', 'm3'], [[1, 1, 0], [0, 1, 0]])

# ContextCpp: (List[str] -> List[str] -> List[List[int]]) -> List[ConctextCpp]
c = ContextCpp(['g1', 'g2'], ['m1', 'm2', 'm3'], [[1, 1, 0], [0, 1, 0]])
c.G  # ['g1', 'g2']
c.M  # ['m1', 'm2', 'm3']
C.I  # [[1, 1, 0], [0, 1, 0]]

# ConceptCpp: (ContextCpp, List[int], List[int]) -> ConceptCpp
concept = ConceptCpp(c, [0, 1], [1, 2])  # ({g1, g2}, {m2, m3})
concept.X  # [0, 1]
concept.Y  # [1, 2]

Incremental Lattice

By intent

This implementation follows the article: AddIntent

k = ContextCpp([], ['a', 'b'], [])
L = LatticeCpp(k)  # Lattice: { ({ }, { a, b })}
L.add_intent('o1', [1])
# Lattice: { ({ }, { a, b }), ({ o1 }, { b })}
L.add_intent('o2', [1])
# Lattice: { ({ }, { a, b }), ({ o1, o2 }, { b })}
L.add_intent('o3', [0])
# Lattice: { ({ }, { a, b }), ({ o1, o2 }, { b }), ({ o1, o2, o3 }, { }), ({ o3 }, { a })}

By pair

k = ContextCpp([], [], [])
L = LatticeCpp(k)  # Lattice: {  }
L.add_pair('o1', 'a2')
# Lattice: Lattice: { ({ o1 }, { a2 })}
L.add_pair('o2', 'a3')
# Lattice: { ({ o1 }, { a2 }), ({ }, { a2, a3 }), ({ o1, o2 }, { }), ({ o2 }, { a3 })}
L.add_pair('o3', 'a1')
# Lattice: { ({ o1 }, { a2 }), ({ }, { a2, a3, a1 }), ({ o1, o2, o3 }, { }), ({ o2 }, { a3 }), ({ o3 }, { a1 })}
L.add_pair('o3', 'a2')
# Lattice: { ({ o1, o3 }, { a2 }), ({ }, { a2, a3, a1 }), ({ o1, o2, o3 }, { }), ({ o2 }, { a3 }), ({ o3 }, { a1, a2 })}

Delete instance

This implementation follows the article: DeleteInstance

k = ContextCpp(['o1', 'o2', 'o3'], ['a1', 'a2', 'a3'], [[0, 1, 0], [0, 0 , 1], [1, 1, 0]])
L = LatticeCpp(k)
# Lattice: { ({ }, { a1, a2, a3 }), ({ o1, o3 }, { a2 }), ({ o1, o2, o3 }, { }), ({ o2 }, { a3 }), ({ o3 }, { a1, a2 })}
L.delete_instance('o3')
# Lattice: { ({ }, { a1, a2, a3 }), ({ o1 }, { a2 }), ({ o1, o2 }, { }), ({ o2 }, { a3 })}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

fca_algorithms_cpp-0.3.5-pp39-pypy39_pp73-win_amd64.whl (151.7 kB view hashes)

Uploaded PyPy Windows x86-64

fca_algorithms_cpp-0.3.5-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (227.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

fca_algorithms_cpp-0.3.5-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (243.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

fca_algorithms_cpp-0.3.5-pp38-pypy38_pp73-win_amd64.whl (151.6 kB view hashes)

Uploaded PyPy Windows x86-64

fca_algorithms_cpp-0.3.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (227.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

fca_algorithms_cpp-0.3.5-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (243.5 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

fca_algorithms_cpp-0.3.5-pp37-pypy37_pp73-win_amd64.whl (151.3 kB view hashes)

Uploaded PyPy Windows x86-64

fca_algorithms_cpp-0.3.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (228.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

fca_algorithms_cpp-0.3.5-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (243.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

fca_algorithms_cpp-0.3.5-cp311-cp311-win_amd64.whl (152.1 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

fca_algorithms_cpp-0.3.5-cp311-cp311-win32.whl (128.5 kB view hashes)

Uploaded CPython 3.11 Windows x86

fca_algorithms_cpp-0.3.5-cp311-cp311-musllinux_1_1_x86_64.whl (759.4 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

fca_algorithms_cpp-0.3.5-cp311-cp311-musllinux_1_1_i686.whl (827.2 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

fca_algorithms_cpp-0.3.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (242.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

fca_algorithms_cpp-0.3.5-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (257.3 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

fca_algorithms_cpp-0.3.5-cp310-cp310-win_amd64.whl (151.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

fca_algorithms_cpp-0.3.5-cp310-cp310-win32.whl (127.7 kB view hashes)

Uploaded CPython 3.10 Windows x86

fca_algorithms_cpp-0.3.5-cp310-cp310-musllinux_1_1_x86_64.whl (758.2 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

fca_algorithms_cpp-0.3.5-cp310-cp310-musllinux_1_1_i686.whl (826.4 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

fca_algorithms_cpp-0.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (241.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

fca_algorithms_cpp-0.3.5-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (256.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

fca_algorithms_cpp-0.3.5-cp39-cp39-win_amd64.whl (149.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

fca_algorithms_cpp-0.3.5-cp39-cp39-win32.whl (127.8 kB view hashes)

Uploaded CPython 3.9 Windows x86

fca_algorithms_cpp-0.3.5-cp39-cp39-musllinux_1_1_x86_64.whl (758.8 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

fca_algorithms_cpp-0.3.5-cp39-cp39-musllinux_1_1_i686.whl (826.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

fca_algorithms_cpp-0.3.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (244.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

fca_algorithms_cpp-0.3.5-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (257.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

fca_algorithms_cpp-0.3.5-cp38-cp38-win_amd64.whl (151.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

fca_algorithms_cpp-0.3.5-cp38-cp38-win32.whl (127.6 kB view hashes)

Uploaded CPython 3.8 Windows x86

fca_algorithms_cpp-0.3.5-cp38-cp38-musllinux_1_1_x86_64.whl (757.2 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

fca_algorithms_cpp-0.3.5-cp38-cp38-musllinux_1_1_i686.whl (825.2 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

fca_algorithms_cpp-0.3.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (241.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

fca_algorithms_cpp-0.3.5-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (256.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

fca_algorithms_cpp-0.3.5-cp37-cp37m-win_amd64.whl (150.2 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

fca_algorithms_cpp-0.3.5-cp37-cp37m-win32.whl (128.5 kB view hashes)

Uploaded CPython 3.7m Windows x86

fca_algorithms_cpp-0.3.5-cp37-cp37m-musllinux_1_1_x86_64.whl (764.9 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

fca_algorithms_cpp-0.3.5-cp37-cp37m-musllinux_1_1_i686.whl (833.0 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

fca_algorithms_cpp-0.3.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (245.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

fca_algorithms_cpp-0.3.5-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl (260.2 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686

fca_algorithms_cpp-0.3.5-cp36-cp36m-win_amd64.whl (153.9 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

fca_algorithms_cpp-0.3.5-cp36-cp36m-win32.whl (132.3 kB view hashes)

Uploaded CPython 3.6m Windows x86

fca_algorithms_cpp-0.3.5-cp36-cp36m-musllinux_1_1_x86_64.whl (764.3 kB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ x86-64

fca_algorithms_cpp-0.3.5-cp36-cp36m-musllinux_1_1_i686.whl (832.7 kB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ i686

fca_algorithms_cpp-0.3.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (245.4 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

fca_algorithms_cpp-0.3.5-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl (260.8 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page