A small package for the language free acquisition of a constraint network
Project description
Language-Free Acq
Learning constraint networks over unknown constraint languages
We propose a method to efficiently solve the Language-Free Acq optimisation problem by giving an optimal consistent constraint network, if it exists. We have implemented our method in the Python programming language. Our program take as input a training set in the form of a file with one assignment by line completed by the classification for this assignment (solution or non-solution). We compute the vocabulary and generate the corresponding Partial Max-Sat instance and solve it using the OR-Tools library.
Requirements
tqdm~=4.66.3
ortools~=9.10.4067
Tqdm is a progress bar library, used to display the progress of the algorithm.
Installation
pip install -r requirements.txt
Usage
In this new version of the program, the solver is OR-Tools. You don't have to specify the solver anymore.
Use the program in your own code
Install the program with pip:
pip install languageFreeAcq
You can now use it in your own code:
from src.languageFreeAcq import Acquisition, CspScopesRelations
lfa = Acquisition()
csp: CspScopesRelations = lfa.learn(
file_train=_examples_file_path_, max_examples=_maximum_number_examples_, timeout=_timeout_)
problem_variables = list(range(0, lfa.get_variables_numbers()))
problem_domain = lfa.get_domains()
relations_learned = csp.get_relations(0) # The first learned relation
tuples_learned = csp.get_scope(0) # The scope where the first learned relation is applied to form
# the constraint network
Edit this program
You can use the script main.py with the following commands:
main.py allto run the program on all the datasets of the paper.main.py dataset_nameto run the program on a specific dataset.main.py customto run the program on the custom dataset. You can configure this by modifying theexperiments/xp_custom.pyfile.
Reproduce the experiments of the paper
The paper associated with this program is:
Christian Bessiere, Clément Carbonnel, Areski Himeur:
Learning Constraint Networks over Unknown Constraint Languages. IJCAI 2023
Because the program now use a new solver, the results may be slightly different from the ones in the paper. Moreover, there is some difference between the program in this repository and the one used in the paper notably the way indexes are used. In the paper, the indexes are 1-based while in this repository, the indexes are 0-based. This difference is due to the fact that the solver used in the paper was the Max-Sat solver from the Minisat library which uses 1-based indexes.
The original code can be found here: https://gite.lirmm.fr/coconut/language-free-acq
To reproduce the experiments of the paper, you can use the script main.py all which will
run the program on all the datasets of the paper. You can also run the program on a specific
dataset by using the command main.py dataset_name.
The results appear in the console with the following format:
FILE_TRAIN: data/_.csv NB_EXAMPLES: _ FILE_TEST: data/_.csv KR: (_, _) ACCURACY: _ RELATION: _ NETWORK: _ TIME: _
where accuracy is the accuracy of the network on the test set, relation is a boolean indicating if the network obtained has the same relation as the one used to generate the dataset, network indicates if the network is strictly the same as the one used to generate the dataset.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file languagefreeacq-0.0.2.tar.gz.
File metadata
- Download URL: languagefreeacq-0.0.2.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad38deb27710f7b26e2daad563262ffc6b9d4b005fbfad83e01209383141b7e4
|
|
| MD5 |
c9303e017dd9237f42959af6af248465
|
|
| BLAKE2b-256 |
646e6febc5736b1401ccdf7e79993d84c0dce4cb1c8d7562dcc39d7ee6cd4640
|
Provenance
The following attestation bundles were made for languagefreeacq-0.0.2.tar.gz:
Publisher:
build_test_deploy.yml on Hareski/language-free-acq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
languagefreeacq-0.0.2.tar.gz -
Subject digest:
ad38deb27710f7b26e2daad563262ffc6b9d4b005fbfad83e01209383141b7e4 - Sigstore transparency entry: 153094306
- Sigstore integration time:
-
Permalink:
Hareski/language-free-acq@a36c9d4066351c9cde8cf412eacbb1a6b8240555 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Hareski
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_test_deploy.yml@a36c9d4066351c9cde8cf412eacbb1a6b8240555 -
Trigger Event:
push
-
Statement type:
File details
Details for the file languageFreeAcq-0.0.2-py3-none-any.whl.
File metadata
- Download URL: languageFreeAcq-0.0.2-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62afcb53cfc8fe347b249b46a4b1e996dc46c74942f87cb72f708860590da9f9
|
|
| MD5 |
e043b621e4ede66f87aaddc2c2022a32
|
|
| BLAKE2b-256 |
63847cd99bed7477b53639cfc1a9bf945622e538cc5751c0bd1e54e4a7496273
|
Provenance
The following attestation bundles were made for languageFreeAcq-0.0.2-py3-none-any.whl:
Publisher:
build_test_deploy.yml on Hareski/language-free-acq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
languagefreeacq-0.0.2-py3-none-any.whl -
Subject digest:
62afcb53cfc8fe347b249b46a4b1e996dc46c74942f87cb72f708860590da9f9 - Sigstore transparency entry: 153094307
- Sigstore integration time:
-
Permalink:
Hareski/language-free-acq@a36c9d4066351c9cde8cf412eacbb1a6b8240555 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Hareski
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_test_deploy.yml@a36c9d4066351c9cde8cf412eacbb1a6b8240555 -
Trigger Event:
push
-
Statement type: