Skip to main content

A small package for the language free acquisition of a constraint network

Project description

Language-Free Acq

Learning constraint networks over unknown constraint languages

Action of build, test, and deploy on PyPI

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 all to run the program on all the datasets of the paper.
  • main.py dataset_name to run the program on a specific dataset.
  • main.py custom to run the program on the custom dataset. You can configure this by modifying the experiments/xp_custom.py file.

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

languagefreeacq-0.0.5.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

languageFreeAcq-0.0.5-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file languagefreeacq-0.0.5.tar.gz.

File metadata

  • Download URL: languagefreeacq-0.0.5.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for languagefreeacq-0.0.5.tar.gz
Algorithm Hash digest
SHA256 8245be713200539bc9bc6753567f42ddd9ad7c561193432be1fa5633c2c3c274
MD5 8cdd44b8a80255b47bae308b42a209f2
BLAKE2b-256 0e0630656492f1c02d77270b825bff9be93bb7ed9fda78291bcb7a1d569d2698

See more details on using hashes here.

Provenance

The following attestation bundles were made for languagefreeacq-0.0.5.tar.gz:

Publisher: build_test_deploy.yml on Hareski/language-free-acq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file languageFreeAcq-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for languageFreeAcq-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b21de4d5652ae4ea4ec51e043e0567c168226ef7558e4ed1ea01d93758d05a4d
MD5 e052dc10b15d1816a4e79613281d101e
BLAKE2b-256 7775dc9b7a72b987f490e194a75646057eeee44aee1d13b81ac91beb5a273d48

See more details on using hashes here.

Provenance

The following attestation bundles were made for languageFreeAcq-0.0.5-py3-none-any.whl:

Publisher: build_test_deploy.yml on Hareski/language-free-acq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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