Qaekwy

Constraints-Satisfaction Problems Solving & Optimization

Cloud Instance Status
Checking...

🙀 what is Constraint Programming

At its core, Constraint Programming is a powerful problem-solving paradigm that involves modeling problems with a set of constraints and rules. These constraints define the relationships and limitations among variables in a problem. The goal is to find solutions that satisfy all the constraints, adhering to the specified rules. Constraint Programming is widely used in various fields, from artificial intelligence and operations research to scheduling and optimization.

Constraint Programming shines when faced with intricate problems that involve a multitude of variables, constraints, and possibilities. Unlike traditional programming, which focuses on algorithmic steps, Constraint Programming allows you to define the problem's properties and let the solver handle the intricacies of finding solutions. This makes it especially useful for problems that are difficult to model with explicit algorithms.

🌵 solving Complex Problems

Traditional methods might struggle when faced with a high number of variables, intricate relationships, and intricate rules. However, CP thrives in such scenarios, providing efficient solutions without the need for explicitly defining algorithms.

By formulating problems using constraints, you can express the inherent relationships and restrictions within a problem. This allows CP solvers to explore a solution space guided by these constraints, narrowing down possibilities and ultimately finding feasible solutions. This approach makes it ideal for scenarios like scheduling tasks, optimizing resource allocation, solving puzzles, and more.

🔎 how does Qaekwy Work

Qaekwy modelling requires variables, contraints and objectives of the CSP. The model is submitted to the Qaekwy Cloud Instance, and the solution is sent back.

😾 defining the Problem

You start by defining your optimization problem using the Qaekwy Python library. This involves specifying variables, constraints, and objectives that describe your problem.


class MyRealWorldProblem(Modeller):
    def __init__(self):
        super().__init__()

        # Create integer variables, solution value between 0 and 10
        x = IntegerVariable(var_name="x", domain_low=0, domain_high=10)
        y = IntegerVariable(var_name="y", domain_low=0, domain_high=10)
        z = IntegerVariable(var_name="z", domain_low=0, domain_high=10)

        # Constraints
        constraint_1 = RelationalExpression(y > 2 * x)
        constraint_2 = RelationalExpression(x >= 4)
        constraint_3 = RelationalExpression(z == y - x)

        # Objective: Maximize z
        self.add_objective(
            SpecificMaximum(variable=z)
        )

        # Add variables
        self.add_variable(x)
        self.add_variable(y)
        self.add_variable(z)
        
        # ... and constraints
        self.add_constraint(constraint_1)
        self.add_constraint(constraint_2)
        self.add_constraint(constraint_3)

        # Set the searching strategy
        self.set_searcher(SearcherType.BAB)

🌩 submitting the Problem to the cloud

Once your problem is defined, you send it to Qaekwy's small cloud instance. This is done using the Qaekwy Python Client, which acts as a bridge between your code and Qaekwy's cloud instance.


# Create a Qaekwy engine for interaction
# with the small freely-available Cloud instance
qaekwy_engine = DirectEngine()

# Create the optimization problem instance
my_realworld_problem = MyRealWorldProblem()

# Request the Qaekwy engine to solve the problem
response = qaekwy_engine.model(model=my_realworld_problem)

🚀 solving process

Qaekwy's magic begins as it employs advanced Constraint Solving techniques to explore possible solutions. It considers the constraints and objectives you provided to find the best possible answer.

💡 fetching Solution

After a successful solving and optimization process, Qaekwy sends back the solutions it discovered. These solutions represent the best configurations that meet your solution's criteria.


# Retrieve the list of solutions from the response
list_of_solutions = response.get_solutions()

# Print the solution(s) obtained
for solution in list_of_solutions:
    print(f"Optimal solution: x = {solution.x}")
    print(f"Optimal solution: y = {solution.y}")
    print(f"Optimal solution: z = {solution.z}")

😺 integrating with your code

You can easily integrate the solutions returned by Qaekwy back into your Python code. This empowers you to make informed decisions based on the optimized outcomes.

Qaekwy Python library in your code allows your application to deal with the Qaekwy Cloud Instance.

🪄 solving complex Problems

Whether it's scheduling, resource allocation, or any other complex challenge, Qaekwy simplifies the process of finding optimal solutions, making difficult problems more manageable.