Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Elements Of Chemical Reaction Engineering
Authors: H. Fogler
6th Edition
013548622X, 978-0135486221
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App