Cs774 (Prasad)L12CLP1 Constraint Logic Programming

Slides:



Advertisements
Similar presentations
Chapter 5 Mathematics of Finance.
Advertisements

Chapter 3 Mathematics of Finance
50.530: Software Engineering
BU Decision Models Integer_LP1 Integer Optimization Summer 2013.
Introduction. IC-Parc2 ECLiPSe Components Constraint Logic Programming system, consisting of  A runtime core Data-driven computation, backtracking, garbage.
“Real Estate Principles for the New Economy”: Norman G. Miller and David M. Geltner Chapter 18 Real Estate Finance Tools: Present Value and Mortgage Mathematics.
Time Value of Money, Loan Calculations and Analysis Chapter 3.
Chapter 5 Time Value of Money
A second order ordinary differential equation has the general form
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Math443/543 Mathematical Modeling and Optimization
Chapter 3 Time Value of Money Part 2  Learning Objectives  Explain and Illustrate an Annuity  Determine Future Value of an Annuity  Determine Present.
Amortized Loans Section 5.4. Introduction The word amortize comes from the Latin word admoritz which means “bring to death”. What we are saying is that.
Dr Eleni Mangina – COURSE: LOGIC PROGRAMMING (during a joint degree with Fudan University in Software Engineering) DEPT. OF COMPUTER SCIENCE UCD LOGIC.
LINEAR EQUATION IN TWO VARIABLES. System of equations or simultaneous equations – System of equations or simultaneous equations – A pair of linear equations.
Solving System of Equations Using Graphing
Linear Equations in One Variable Objective: To find solutions of linear equations.
3-3 Solving Multiplication Equations. Solve Solution GOAL Find the value of the variable that makes the equation TRUE. The value that makes the equation.
Copyright © 2011 Pearson Prentice Hall. All rights reserved. The Time Value of Money: Annuities and Other Topics Chapter 6.
259 Lecture 3 Spring 2015 Finance Applications with Excel – Annuities an Amortization.
Chapter 9 Time Value of Money © 2000 John Wiley & Sons, Inc.
How to Play Sudoku & Win Integer Programming Formulation of a Popular Game Sven LeyfferSven Leyffer, Argonne, Feb. 15, 2005 (windoze powerpoint sumi painting.
5.3 Systems of Linear Equations in Three Variables
Chapter 1 Overview What is: Finance? Financial Management? Financial Intermediary Function (the cycle of money)?
Section 1.1, Slide 1 Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 8.5, Slide 1 Consumer Mathematics The Mathematics of Everyday Life 8.
THE TIME VALUE OF MONEY TVOM is considered the most Important concept in finance because we use it in nearly every financial decision.
A GAMS TUTORIAL. WHAT IS GAMS ? General Algebraic Modeling System Modeling linear, nonlinear and mixed integer optimization problems Useful with large,
9/11/20151 HFT 4464 Chapter 5 Time Value of Money.
1 Chapter 4 Constraint Logic Programming. 2 Outline Introduction The constraint logic programming scheme CLP languages and applications  CLP(R)  CHIP.
Q1 The following expression matches the interest factor of continuous compounding and m compounding. Plug r=0.2, m=4 to get x=0.205.
THE TIME VALUE OF MONEY TVOM is considered the most Important concept in finance because we use it in nearly every financial decision.
Chapter 3 Mathematics of Finance
CDAE Class 07 Sept. 18 Last class: Result of Quiz 1 2. Review of economic and business concepts Today: 2. Review of economic and business concepts.
CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.
Annuity investments demand regular equal deposits into an investment.
6-1 Chapter 6 The Time Value of Money Future Value Present Value Rates of Return Amortization.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
Teaching LP: A Perspective Gopal Gupta Department of Computer Science University of Texas at Dallas.
Mathe III Lecture 3 Mathe III Lecture 3 Mathe III Lecture 3 Mathe III Lecture 3.
CSC 423 ARTIFICIAL INTELLIGENCE Constraint Satisfaction Problems.
Comp763: Modern Computer Games Using Constraint Logic Programming to Analyze the Chronology in a William Faulkner Story Jennifer BurgSheau-Dong Lang Irwin.
Annuity investments demand regular equal deposits into an investment.
Chapter 2 Risk, Return, and Decision Making 4 Characteristics of RE Investments Speculation vs. Investment No Clear Distinction Uniqueness of Real Estate.
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Chapter 3 Review Important Terms, Symbols, Concepts 3.1. Simple Interest Interest is the fee paid for the.
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Discounted Cash Flow Valuation Multiple Cash Flows We have dealt with lump sums We have dealt with lump sums What if there is more than one cash flow?
Annuities, Loans, and Mortgages Section 3.6b. Annuities Thus far, we’ve only looked at investments with one initial lump sum (the Principal) – but what.
Systems of Linear Equations in Two Variables. 1. Determine whether the given ordered pair is a solution of the system.
Solving Linear Systems by Substitution
THE COSTS AND METHODS OF OBTAINING CREDIT PG NAME, TEACHER AND DATE.
Paper Presentation Classroom Assignment using Constraint Logic Programming [Slim Abdennadher, Matthias Saft, Sebastian Will] University of Munich Presented.
Logic Programming Lecture 9: Constraint logic programming.
Sullivan Algebra and Trigonometry: Section 12.9 Objectives of this Section Set Up a Linear Programming Problem Solve a Linear Programming Problem.
Chapter 3 – Linear Systems 3-1 Solving Systems Using Tables and Graphs.
An Application of Trigonometry Heights and Distances
CS5205: Foundation in Programming Languages Type Reconstruction
Basic Finance The Time Value of Money
Finance Applications with Excel – Annuities an Amortization
Automatic Test Generation
CHAPTER 2 VALUE: THE CENTRAL IDEA
Chapter 3 Mathematics of Finance
Movable lines class activity.
Chapter 7 – Systems of Linear Equations and Inequalities
Ch 11 Resource Constraints and Linear Programming
6-2 Solving Systems using Substitution
Systems of equations Internal assessment 3.15.
Solve a system of linear equation in two variables
Prolog syntax + Unification
Artificial Intelligence
LESSON 81 – WORKING WITH SYSTEMS OF EQUATIONS
Presentation transcript:

cs774 (Prasad)L12CLP1 Constraint Logic Programming

Ordinary Logic Programming ?- p(a,X) = p(Y,b). Y=a X=b ?- p(X,X) = p(a,b). *fails* Unification solves equality constraints (under unique name hypothesis) cs774 (Prasad)L12CLP2

Constraint Logic Programming ?- X + 2 = 5. *fails in ordinary LP* In CLP, succeeds with: X = 3 Generalizes to constraint satisfaction problem, interpreting “+” as the arithmetic addition operator cs774 (Prasad)L12CLP3

Constraint Satisfaction Problem Given a set of variables, their types (domains of values and applicable operations), and constraints on them, determine assignment of values to variables so that the constraints are satisfied. Benefit: Embodiment of Declarative Programming Challenge: Designing tractable constraint languages cs774 (Prasad)L12CLP4

Applications Scheduling and Resource Management in production and transportation teachers and courses to classes rooms machines to jobs crews to planes Linear and Non-linear programming problems Mortgage Calculations cs774 (Prasad)L12CLP5

CLP : Motivation fib(0,1). fib(1,1). fib(N,X) :- N1 is N-1, N2 is N-2, fib(N1,X1), fib(N2,X2), X is X1 + X2. ?- fib(4,5). Succeeds. ?- fib(X,5). Fails. Treatment of arithmetic expression looks unnatural, as it does not smoothly integrate with the logic programming paradigm (e.g., invertibility destroyed) cs774 (Prasad)L12CLP6

Introducing the Theory of Arithmetic fib(0,1). fib(1,1). fib(N, X1 + X2) :- N > 1, fib(N - 1,X1), fib(N - 2,X2). Interpret arithmetic operators in the domain of reals –improves readability –improves invertibility ?- fib(N, 13). N = 6. ?- fib(N, X), 10 =< X, X =< 25. N = 6. X = 13. N = 7. X = 21. cs774 (Prasad)L12CLP7

Solving Simultaneous Equations ?- X + Y = 12, 2*X + 4*Y = 34. X = 7. Y = 5. Complex Multiplication zmul(c(R1,I1),c(R2,I2),c(R3,I3)) :- R3 = R1 * R2 - I1 * I2, I3 = R1 * I2 + R2 * I1. ?- zmul(c(2,2),Ans,c(0,16)) Unique solution: Ans = C(4,4) ?- zmul(A,B,c(0,16)) *Set of constraints* Infinite solution: *Set of constraints* cs774 (Prasad)L12CLP8

Prolog vs CLP(R) ? = X + Y. X = 5 Y = 2 ? = X + 3. *fail* Equality constraints over terms ? = X + Y. X = 7 - Y ? = X + 3. X = 4 General constraints over arithmetic expressions; Equality constraints over terms cs774 (Prasad)L12CLP9

Prolog vs CLP(R) Uninterpreted function symbols Unification algorithm Backtrack when terms fail to unify Arithmetic operators + uninterpreted term trees General constraint solvers – E.g., Simplex algorithm for linear constraints Backtrack when constraints violated cs774 (Prasad)L12CLP10

CLP : Linear Programming light_meal(A,M,D) :- appetizer(A,I), main_course(M,J), dessert(D,K), I >= 0, J >= 0, K >= 0, I + J + K <= 12. appetizer(soup,1). appetizer(nachos,6). main_course(sphagetti,3). main_course(alfredo,7). dessert(fruit,2). dessert(ice_cream,6). cs774 (Prasad)L12CLP11

?- light_meal(App,Main,Dess). Dess = fruit Main = sphagetti App = soup *** Retry? y Dess = ice_cream Main = sphagetti App = soup *** Retry? y Dess = fruit Main = alfredo App = soup *** Retry? y Dess = fruit Main = sphagetti App = nachos cs774 (Prasad)L12CLP12

CLP : Mortgage Payment Calculator %mortgage(Principal,Time_Months, Interest_Rate,Monthly_Payment, Balance) mortgage(P,0,_,_,P). mortgage(P,1,_,_,B) :- B = P * (1 + (I / 1200)) - MP. mortgage(P, T, I, MP, B) :- mortgage( (P * (1 + I / 1200)) - MP, T – 1, I, MP, B). cs774 (Prasad)L12CLP13

CLP : Mortgage Payment Queries %mortgage(Principal,Time_Months, Interest_Rate,Monthly_Payment, Balance) %Customer: What will be the monthly payment? ?- mortgage(148000,180,8,M,0). M = %Lender: How much loan does one qualify for, given monthly payment limit? ?- mortgage(P,180,8,1200,0). P = cs774 (Prasad)L12CLP14

(cont’d) %mortgage(Principal,Time_Months, Interest_Rate,Monthly_Payment, Balance) %Customer/Lender: What is the remaining balance? ?- mortgage(148000,180,8.375, ,B). B = %Customer: How long will it take to clear the debt? ?- mortgage(148000,L,8.5,1400,0). L = cs774 (Prasad)L12CLP15

(cont’d) %mortgage(Principal,Time_Months, Interest_Rate,Monthly_Payment, Balance) %Customer: What is the contribution to the principal in the first month (in a 15 yr loan at 8 or a 30 yr loan at 8.375)? %Customer: Building equity. ?- mortgage(148000,1,8,1414, CP). CP = 427 ?- mortgage(148000,1,8.375,1124, CP). CP = 92 cs774 (Prasad)L12CLP16

Non-linear constraints : CLP(R) Fails Here %mortgage(Principal,Time_Months, Interest_Rate,Monthly_Payment, Balance) %Customer: What is the maximum interest rate for the given principal and monthly payment? %Customer: Affordability ?- mortgage(148000,180,I,1400,0). *lots of constraints output* cs774 (Prasad)L12CLP17

CLP : Annuity Calculator %annuity(Time_Months, Interest_Rate,Monthly_Payment, Initial_Principal, Total_Value) annuity(0,_,_,IP,IP). annuity(T, I, MP, IP, TV) :- annuity(T-1, I, MP, IP, V), TV = MP + (V * (1 + I / 1200)). cs774 (Prasad)L12CLP18

CLP : Annuity Queries %annuity(Time_Months, Interest_Rate,Monthly_Payment, Initial_Principal, Total_Value) %Customer: What will be the final investment value? ?- annuity(180,5,225,0,FV). FV = %Customer: What is the net gain? ?- annuity(180,5,225,0,225*180 + G). G = cs774 (Prasad)L12CLP19

CLP : Limitations ?- (Cows + Pigs + Sheeps) = 100, (10*Cows + 3*Pigs + Sheeps/2) = 100, Cows >= 1, Pigs >= 1, Sheeps >= 1. Pigs = *Sheeps Cows = *Sheeps Sheeps <= 94 * Lots of constraints * CLP(R) is unable to determine the unique solution: Cows = 5, Pigs = 1, Sheeps = 94 cs774 (Prasad)L12CLP20