Constraint-based problem solving

Slides:



Advertisements
Similar presentations
Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Advertisements

1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License:
Review: Constraint Satisfaction Problems How is a CSP defined? How do we solve CSPs?
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
Clustering Color/Intensity
Constraint Satisfaction Problems
Sudoku Solver Comparison A comparative analysis of algorithms for solving Sudoku.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Backtracking & Brute Force Optimization Intro2CS – weeks
Week 6 MondayTuesdayWednesdayThursdayFriday Testing III Reading due Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
Optimized SAT Encoding For Sudoku Puzzles Will Klieber and Gi-Hwon Kwon Sept 27, 2007 rev. 2 Changes from v1: Added a new slide after “A Better Encoding.
Various Problem Solving Approaches. Problem solving by analogy Very often problems can be solved by looking at similar problems. For example, consider.
CSC 108H: Introduction to Computer Programming
Implicit Volatility Stefano Grazioli.
Problem Solving: Brute Force Approaches
CS210 Intermediate Computing with Data Structures (Java)
Recursion Topic 5.
Recursive stack-based version of Back-chaining using Propositional Logic
Introduction To Repetition The for loop
Comparative Relational Thinking
Implicit Volatility Stefano Grazioli.
CSCI 104 Backtracking Search
How to show what you know!
Scientific Method notes and flow chart
The Propositional Calculus
Loop Structures.
Lecture 7 Constraint Satisfaction Problems
C ODEBREAKER Class discussion.
PROBLEM-SOLVING Why are some problems just so damn darn hard to solve? 1. We don’t take the time to determine what is relevant and end up focusing on irrelevant.
Local Search Strategies: From N-Queens to Walksat
CSS 161: Fundamentals of Computing
CS 188: Artificial Intelligence
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
CSE 341: Programming Languages Section 1
Course supervisor: Lubna Siddiqui
Problem Solving: Brute Force Approaches
CS B551: Elements of Artificial Intelligence
Chapter 10 Programming Fundamentals with JavaScript
Control Flow.
Functions and Procedures
Introduction to Object-Oriented Programming with Java--Wu
Modeling Sudoku as a CNF Formula
The Scientific Method.
Loops CIS 40 – Introduction to Programming in Python
adapted from Recursive Backtracking by Mike Scott, UT Austin
Flowcharting & Algorithms
Artificial Intelligence
Artificial Intelligence
A General Backtracking Algorithm
Data Analysis, Probability, Stats, and Logic
Artificial Intelligence
NP-Completeness Yin Tat Lee
Constraint satisfaction problems
For loops Taken from notes by Dr. Neil Moore
Artificial Intelligence
FLUENCY WITH INFORMATION TECNOLOGY
Sudoku.
This Lecture Substitution model
Implicit Volatility Stefano Grazioli.
CS 8520: Artificial Intelligence
Implicit Volatility Stefano Grazioli.
Constraint Satisfaction Problems
Chapter 3 Flow of Control Loops in Java.
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
David Kauchak CS51A – Spring 2019
Constraint satisfaction problems
Lecture 6 - Recursion.
Presentation transcript:

Constraint-based problem solving

Basic idea We don’t know how to solve a problem outright. We do know rules that it shouldn’t break when solved The constraints. The reverse of a heuristic? Usually involves some iteration Try a guess. See what constraints are violated => fix them Repeat.

A classic logic problem: SAT Suppose we have a set of variables: A – E for example. Each can be True or False (the domain) Can be combined with these operators: 𝑙𝑜𝑔𝑖𝑐𝑎𝑙−𝐴𝑁𝐷 𝑙𝑜𝑔𝑖𝑐𝑎𝑙−𝑂𝑅 ¬ 𝑙𝑜𝑔𝑖𝑐𝑎𝑙−𝑁𝑂𝑇 SAT is a test to determine (at least one) combination of values to assign to the variables. e.g. ((¬𝐴 𝐷) ¬(𝐶 𝐷) ⋀𝐸) This is an NP-hard problem in general

Connection: Prolog Solving this type of problem is what Prolog is built for. More general than SAT variables can have any values. A few other constraint-based libraries / languages: python-constraint (python package) Google’s OR-tools (python, C++, Java library) Screamer (Lisp library) Wolfram (?)

Some common constraints …of a general constraint-solver ALL_UNIQUE(list) ALL_DIFFERENT(list) AT_LEAST_ONE(list, val) … A huge goal is to avoid back-tracking i.e. don’t do brute-force.

our problem Solve a Sudko puzzle [rules of Sudoku?] Have a set of variables for the missing spots. Initially the domain is 1, 2, 3, …, 9 if that value would vilolate the Sudoku rules, remove it from the domain for that variable. if you get down to just one value, you know that’s the only answer. Use that to eliminate other values from other variables domains. for easy – medium puzzles, repeatedly applying should let you solve. for harder puzzles, you may have to do some trial-and-error (backtracking)

a related (?) problem: VERLET physics Might be a stretch…but it’s cool https://www.youtube.com/watch?v=w88D8-0-Kb4 https://www.youtube.com/watch?v=DWTpjNUbT24 Discovered by Hitman: Codename 47 (2000) http://graphics.cs.cmu.edu/nsp/course/15-869/2006/papers/jakobsen.htm Basic idea: a set of points a set of constraints between points. apply gravity and mouse-drag to points iteratively fix the constraints soft-body physics! ragdoll! cloth-simulators! profit!

position-integration What we usually use (Euler integration): class PointMass{ Position p; Velocity v; } def update(dt, a): v += a * dt p += v * dt Verlet Integration Don’t store velocity! Instead store it’s last position (and current) change update to: x_new = 2x – x + a * dt * dt (chang 2 to 1.99 or so to do friction) x_old = x x = x_new

constraint-satisfaction Define a constraint as: connecting 2 points (p1, p2) a distance (could calculate from p1, p2 initial values) [optional] springiness how aggressive are we at fixing constraints? [optional] tolerance allow this much variation from rest-distance before correcting. Update procedure Every frame (perhaps multiple times?) fix the constraints. That’s it! [demo]