Library to solve Constraint satisfation problems
Project description
Generic Constraint Satisfaction Problem Solver
CSP Solver is a library designed to provide the functionalities to solve contstraint satisfactions problems without the need of going through the hassle of writing the code to do so. As of now, it supports a variety of methods including but not restricted to Hill Climbing with greedy biasing, Arc Consistent backtracking etc.
Supported Methods!
Depth first serch
solve_dfs(self: CSP, timeout: int)
Backtracking
solve_BackTrack(self: CSP, timeout: int)
Forward Checking
solve_ForwardChecking(self: CSP, timeout: int)
Forward Checking with MRV ordering
solve_ForwardChecking_MRV(self: CSP, timeout: int)
Forward checking with MRV & LCV ordering
solve_ForwardChecking_MRV_LCV(self:CSP, timeout:int)
Classical Hill Climbing (Taking best available option)
solve_HillClimbing_chooseBest(self:CSP, memoization:bool, iterations:int, allowedSideMoves:int, tabuSize:int, timeout:int)
Hill Climbing with random choice biased towards better choices
solve_HillClimbing_greedyBias(self:CSP, memoization:bool, iterations:int, allowedSideMoves:int, tabuSize:int, timeout:int)
Hill Climbing with random choice
solve_HillClimbing_chooseRandom(self:CSP, memoization:bool, iterations:int, allowedSideMoves:int, tabuSize:int, timeout:int)
Genetic Algorithm
solve_GeneticAlgo(self:CSP, populationSize:int, generations:int, timeout:int)
Local beam search
solve_local_beam_search(self:CSP, beams:int, timeout:int)
Simulated Annealing
solve_Simulated_Annealing(self:CSP, iterations:int, initialTemperature:int, cooling_coefficient:int, timeout:int)
Arc consistent Backtracking
solve_ArcConsistent_BackTracking(self: CSP, timeout: int)
Novel Approach
solve_novelAlgorithm(self, split:int, allowedSideMoves:int, tabuSize:int, tries:int, timeout:int)
Run all methods on default parameters
testAllDefaultParams(self: CSP, timeout:int)
Example
- Initializing the class
import CSP_Solver as CS
task = CS.CSP(variables=..., solution_path=..., problem_name=...)
- Adding constraints specifying domains
'''
Make sure that your constraint is python friendly
'''
task.addConstraint('value[1] != value[2]') # Example constraint
# You may use this if the domain is common for all variables
task.commonDomain(domain=[1,2,5,4])
# You may want to add constraints sperately
task.seperateDomain(variable=1,domain=[1,2])
# You may want to set value of some variable
task.setValue(variable=1, value=2)
task.testAllDefaultParams(timeout=10)
Reports
Installation
Install package from Pypi
$ pip install CSP-Solver
To test examples
$ git clone https://github.com/LezendarySandwich/Generic-CSP-Solver.git
$ cd Generic-CSP-Solver/Examples
$ python3 [Example]
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 CSP_Solver-0.1.2-py3-none-any.whl.
File metadata
- Download URL: CSP_Solver-0.1.2-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00b0689815f25da7fa075305985cd5061fb89579cd03211238872b867ec22bb9
|
|
| MD5 |
bd125645494f17352d69e5f6b116bf41
|
|
| BLAKE2b-256 |
50fe68f8cb84d023d98273920071acebed3cfbe05a74e463ce890bb2dfdd928c
|