Skip to content

Commit

Permalink
D. Jabs:
Browse files Browse the repository at this point in the history
- Changed name of project to PyCSPSolver
  • Loading branch information
Dennis Jabs committed Oct 12, 2023
1 parent 18589d0 commit 5de989e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/PyCSP.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Build & Test PyCSP
name: Build & Test PyCSPSolver

on:
push:
paths: ["PyCSP/*", "tests/*"]
paths: ["PyCSPSolver/*", "tests/*"]

jobs:
job:
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion PyCSP/csp.py → PyCSPSolver/csp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import TypeVar, Generic, Optional

from PyCSP.constraint import Constraint
from PyCSPSolver.constraint import Constraint

V = TypeVar("V")
D = TypeVar("D")
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# PyCSP
PyCSP is a simple Python Framework for solving Constraint Satisfaction Problems (CSPs).
# PyCSPSolver
PyCSPSolver is a simple Python Framework for solving Constraint Satisfaction Problems (CSPs).
You can find more information about CSPs
[here](https://en.wikipedia.org/wiki/Constraint_satisfaction_problem).

### Solving CSPs with PyCSP
### Solving CSPs with PyCSPSolver
In the following, we want to solve a 2x2 sudoku puzzle with PyCSP.
First we need to define our problem as CSP.
So we have to define variables, domains and constraints before we can solve it.
Expand Down Expand Up @@ -59,8 +59,9 @@ PyCSP has in principal four different types of constraints.
| NotEqualConstraint() | variables should have not an equal value | X1 != X2 |

The following shows how to define the constraints from the example:

```python
from PyCSP.constraint import EqualToConstraint, EqualConstraint, NotEqualToConstraint, NotEqualConstraint
from PyCSPSolver.constraint import EqualToConstraint, EqualConstraint, NotEqualToConstraint, NotEqualConstraint

constraint1 = EqualToConstraint(["X1"], 1)
constraint2 = EqualConstraint(["X1", "X2"])
Expand All @@ -72,8 +73,9 @@ With that in mind, we can now define the constraints of the 2x2 sudoku board, wh
sudoku.
The sudoku rules are that in each row, column or 2x2 square each value should only exist once.
The following shows the constraint of the 2x2 sudoku board:

```python
from PyCSP.constraint import NotEqualConstraint
from PyCSPSolver.constraint import NotEqualConstraint

row1 = NotEqualConstraint(["X1", "X2", "X3", "X4"])
row2 = NotEqualConstraint(["X5", "X6", "X7", "X8"])
Expand All @@ -92,8 +94,9 @@ square4 = NotEqualConstraint(["X11", "X12", "X15", "X16"])
Now we have defined our 2x2 sudoku board as a CSP.
With all combined, we can now solve the CSP with PyCSP.
The following code shows how to solve the CSP with simple backtracking search:

```python
from PyCSP.csp import CSP
from PyCSPSolver.csp import CSP

csp = CSP[str, int](variables=variables, domains=domains)

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
long_description = file.read()

setup(
name="PyCSP",
name="PyCSPSolver",
version="0.0.1",
author=["Dennis J.", "Patrick B."],
url="https://github.com/nobodyPerfecZ/py-csp",
url="https://github.com/nobodyPerfecZ/py-csp-solver",
python_requires=">=3.10",
packages=find_packages(
exclude=[
Expand Down
2 changes: 1 addition & 1 deletion tests/test_constraint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from PyCSP.constraint import EqualToConstraint, EqualConstraint, NotEqualToConstraint, NotEqualConstraint
from PyCSPSolver.constraint import EqualToConstraint, EqualConstraint, NotEqualToConstraint, NotEqualConstraint


class TestEqualToConstraint(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_csp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from PyCSP.csp import CSP
from PyCSP.constraint import NotEqualConstraint
from PyCSPSolver.csp import CSP
from PyCSPSolver.constraint import NotEqualConstraint


class TestCSP(unittest.TestCase):
Expand Down

0 comments on commit 5de989e

Please sign in to comment.