<jupyter_start><jupyter_text><jupyter_code>!pip install ortools
from ortools.sat.python import cp_model
#Crear un CP - CSP
model = cp_model.CpModel()
#varialbes y dominios
x = model.NewIntVar(0,2,'x')
y = model.NewIntVar(0,2,'y')
z = model.NewIntVar(0,2,'z')
#Restricciones
model.Add(x != y)
model.Add(z > y)

#Crear solver
solver = cp_model.CpSolver()
status = solver.Solve(model)
if status == cp_model.OPTIMAL:
  print('x = {}'.format(solver.Value(x)))
  print('y = {}'.format(solver.Value(y)))
  print('z = {}'.format(solver.Value(z)))
class VarArraySolutionPrinter(cp_model.CpSolverSolutionCallback):
    """Print intermediate solutions."""

    def __init__(self, variables):
        cp_model.CpSolverSolutionCallback.__init__(self)
        self.__variables = variables
        self.__solution_count = 0

    def on_solution_callback(self):
        self.__solution_count += 1
        for v in self.__variables:
            print('%s=%i' % (v, self.Value(v)), end=' ')
        print()

    def solution_count(self):
        return self.__solution_count
solver = cp_model.CpSolver()
solution_printer = VarArraySolutionPrinter([x, y, z])
# Enumerate all solutions.
solver.parameters.enumerate_all_solutions = True
# Solve.
status = solver.Solve(model, solution_printer)<jupyter_output>x=2 y=1 z=2 
x=0 y=1 z=2 
x=1 y=0 z=1 
x=2 y=0 z=1 
x=2 y=0 z=2 
x=1 y=0 z=2
{'fraction_non_alphanumeric': 0.1467351430667645, 'fraction_numerical': 0.019075568598679385, 'mean_word_length': 4.226053639846743, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '131170', 'license': 'MIT', 'n_tokens_mistral': 536, 'n_tokens_neox': 510, 'n_words': 104, 'path': 'CP_Ejemplo.ipynb', 'repo_name': 'FKevin24/Auditoria', 'size': '1363'}