Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want to get a solution for the constraint that all variables sum will be 18. It is a simple example for CSP. The code

I want to get a solution for the constraint that all variables sum will be 18.

It is a simple example for CSP.

The code

import constraint

problem = constraint.Problem()

problem.addVariables("a", range(9))

problem.addVariables("b", range(8))

problem.addVariables("c", range(7))

problem.addVariables("d", range(3))

problem.addVariables("e", range(2))

problem.addVariables("f", range(2))

problem.addConstraint(constraint.ExactSumConstraint(18, [7,2,2,2,2,2]), ["a", "b", "c","d", "e", "f"])

solution = problem.getSolutions()

print(solution)

Step by Step Solution

3.37 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Elements Of Chemical Reaction Engineering

Authors: H. Fogler

6th Edition

013548622X, 978-0135486221

More Books

Students also viewed these Programming questions

Question

Do I make impulse purchases during my surfing sessions?

Answered: 1 week ago

Question

Solve the following the equation. x- 0.025x=341.25

Answered: 1 week ago

Question

Solve the following the equation. 12x-4(2x-1)=6(x+1)-3

Answered: 1 week ago