Constraint operations: Simplification, Optimization and Implication
description
Transcript of Constraint operations: Simplification, Optimization and Implication
![Page 1: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/1.jpg)
1
Constraint operations: Constraint operations: Simplification, Optimization Simplification, Optimization
and Implicationand Implication
.
![Page 2: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/2.jpg)
2
Simplification, Optimization Simplification, Optimization and Implicationand Implication
Constraint Simplification Projection Constraint Simplifiers Optimization Implication and Equivalence
![Page 3: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/3.jpg)
3
Constraint SimplificationConstraint Simplification
Two equivalent constraints represent the same information, but
One may be simpler than the otherX X Y X
X Y XX X Y
X Y XX Y Y
X Y Y
1 3 23 2
3 22 3
2 3 22 1
Removing redundant constraints, rewriting a primitive constraint, changing order, substituting using an equation all preserve equivalence
![Page 4: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/4.jpg)
4
Redundant ConstraintsRedundant Constraints
One constraint C1 implies another C2 if the solutions of C1 are a subset of those of C2
C2 is said to be redundant wrt C1 It is written C C1 2
X XY X Y X
cons X X cons Z nil Z nil
3 12 4 1
( , ) ( , )
![Page 5: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/5.jpg)
5
Redundant ConstraintsRedundant Constraints
We can remove a primitive constraint which is redundant with respect to the rest of the constraint.
X X X
Y X X Y Y X Y
cons X X cons Z nil Z nil cons X X cons Z nil
1 3 3
2 1 4 2 4
( , ) ( , ) ( , ) ( , )
Definitely produces a simpler constraint
![Page 6: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/6.jpg)
6
Solved Form SolversSolved Form Solvers
Since a solved form solver creates equivalent constraints it can be a simplifier
cons X X cons Z nil Y succ X succ Z Y Z nilX nil Z nil Y succ nil( , ) ( , ) ( ) ( )
( )
For example using the term constraint solver
Or using the Gauss-Jordan solverX Y Y X T Z X Y Z T
X Y Z T
2 2 4 5
3 1 5
![Page 7: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/7.jpg)
7
ProjectionProjection
It becomes even more important to simplify when we are only interested in some variables in the constraint
II1
I2
V+
--3_--
+
--
V1V2
--
V I RV I R
V VV V
V VI I II I I
RR
1 1 12 2 21 02 0
1 2 01 2 01 2 0
1 52 10
Simplified wrt to V and I V I
103
![Page 8: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/8.jpg)
8
ProjectionProjection The projection of a constraint C onto
variables V is a constraint C1 such that C1 only involves variables V Every solution of C is a solution of C1 A solution of C1 can be extended to give a
solution of CX Y Y Z ZX Y ZX Y Z
00 0 04 3 1
{ , , }{ , , }
XXX
004
{ }{ }
![Page 9: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/9.jpg)
9
Fourier’s AlgorithmFourier’s Algorithm
Eliminates variable y from linear ineqs C Write each ineq with y on one side of ineq
For each pair produce a new ineq
The result is all new ineqs and those ineqs in C which do not involve y
t y y t1 2 t y y t1 2
t y y t t t1 2 1 2
![Page 10: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/10.jpg)
10
Fourier’s Algorithm ExampleFourier’s Algorithm Example
Projecting out Y
X
Y+1
+1-1
-1
X-1 +1
X YX Y
Y XY X
11
11
X Y Y X XX Y Y X
X Y Y XX Y Y X X
1 1 11 1 0 2
1 1 0 21 1 1
Result only involving XX X 1 1
![Page 11: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/11.jpg)
11
Projecting Term ConstraintsProjecting Term Constraints
We can also project term constraints
projected onto {X,Z} is But what is X = cons(Y,Z) projected onto X? Answer: there is no such constraint!
cons Y Y cons X Z succ Z succ T( , ) ( , ) ( ) ( )
X Z
![Page 12: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/12.jpg)
12
Constraint SimplifiersConstraint Simplifiers
constraints C1 and C2 are equivalent wrt variables V if taking any solution of one and restricting it to
the variables V, this restricted solution can be extended to be a solution of the other
Example X=succ(Y) and X=succ(Z) wrt {X}X succ Y X X succ Z
X succ a Y a X succ a X succ a Z aX succ nil Y nil X succ nil X succ nil Z nil
( ) { } ( ){ ( ), } { ( )} { ( ), }
{ ( ), } { ( )} { ( ), }
![Page 13: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/13.jpg)
13
Simplifier DefinitionSimplifier Definition
A constraint simplifier is a function simpl which takes a constraint C and set of variables V and returns a constraint C1 that is equivalent to C wrt V
We can make a simplifier for real inequalities from Fourier’s algorithm
![Page 14: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/14.jpg)
14
Tree Constraint SimplifierTree Constraint Simplifier
apply the term solver to C obtaining C1 if C1 is false then return false foreach equation x=t in C1
if x is in V then if t is a variable not in V
substitute x for t throughout C1 and result else add x=t to result
return result
![Page 15: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/15.jpg)
15
Tree Simplification ExampleTree Simplification Example
Tree constraint to be simplified wrt {Y,T}))(),,(),),((())(,),,(( UgXXfXTgfhTgZYXfh
Equivalent constraint from tree solverZ f g U g U X g U Y g U T U ( ( ), ( )) ( ) ( )
Discard the first two equations, keep the third and use the last to substitute for U by T
Y g T ( )
![Page 16: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/16.jpg)
16
Simplifier PropertiesSimplifier Properties
Desirable properties of a simplifier are: projecting: weakly projecting: for all constraints C2 that are
equivalent to C1 wrt V
a weakly projecting solver never uses more variables than is required
Both properties allow a simplifier to be used as a solver (How?)
vars simpl C V V( ( , ))
| ( ( , )) | | ( ) |vars simpl C V V vars C V1 2
![Page 17: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/17.jpg)
17
OptimizationOptimization
Often given some problem which is modelled by constraints we don’t want just any solution, but a “best” solution
This is an optimization problem We need an objective function so that we
can rank solutions, that is a mapping from solutions to a real value
![Page 18: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/18.jpg)
18
Optimization ProblemOptimization Problem
An optimization problem (C,f) consists of a constraint C and objective function f
A valuation v1 is preferred to valuation v2 if f(v1) < f(v2)
An optimal solution is a solution of C such that no other solution of C is preferred to it.
![Page 19: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/19.jpg)
19
Optimization ExampleOptimization Example
0 1 2 3 4
1
2
3
4
Y
X
X+Y=4
An optimization problem
( , )C X Y f X Y 4 2 2
Find the closest point to the origin satisfying the C. Some solutions and f value
{ , }{ , }{ , }
X YX YX Y
0 4 163 3 182 2 8
Optimal solution{ , }X Y 2 2
![Page 20: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/20.jpg)
20
OptimizationOptimization
Some optimization problems have no solution. Constraint has no solution
Problem has no optimum
For any solution there is more preferable one
( , )X X X 2 0 2
( , )X X0
![Page 21: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/21.jpg)
21
Simplex AlgorithmSimplex Algorithm
The most widely used optimization algorithm
Optimizes a linear function wrt to linear constraints
Related to Gauss-Jordan elimination
![Page 22: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/22.jpg)
22
Simplex AlgorithmSimplex Algorithm
A optimization problem (C, f) is in simplex form: C is the conjunction of CE and CI CE is a conjunction of linear equations CI constrains all variables in C to be non-
negative f is a linear expression over variables in C
![Page 23: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/23.jpg)
23
Simplex ExampleSimplex Example
minimize subject to3 2 13
3 2 10 0 0 0
X+ Y-Z+X YX Y Z TX Y Z T
An optimization problem in simplex form
• An arbitrary problem can be put in simplex form by
• replacing unconstrained var X by new vars
• replacing ineq by new var s and
X X
e r e s r
![Page 24: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/24.jpg)
24
Simplex Solved FormSimplex Solved Form
A simplex optimization problem is in basic feasible solved (bfs) form if: The equations are in solved form Each constant on the right hand side is non-negative Only parameters occur in the objective
A basic feasible solution is obtained by setting each parameter to 0 and each non-parameter to the constant in its equation
![Page 25: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/25.jpg)
25
Simplex ExampleSimplex Example
minimize subject to1034 2 2
0 0 0 0
Y ZX YT Y Z
X Y Z T
An equivalent problem to that before in bfs form
We can read off a solution and its objective value{ , , , }X T Y Zf
3 4 0 010
![Page 26: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/26.jpg)
26
Simplex AlgorithmSimplex Algorithm
starting from a problem in bfs form
repeat
Choose a variable y with negative coefficient in the obj. func.
Find the equation x = b + cy + ... where c<0 and -b/c is minimal
Rewrite this equation with y the subject y = -b/c + 1/c x + ...
Substitute -b/c + 1/c x + ... for y in all other eqns and obj. func.
until no such variable y exists or no such equation exists
if no such y exists optimum is found
else there is no optimum solution
![Page 27: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/27.jpg)
27
Simplex ExampleSimplex Exampleminimize subject to10
34 2 2
0 0 0 0
Y ZX YT Y Z
X Y Z T
Choose variable Y, the first eqn is only one with neg. coeff Y X 3
minimize subject to73
10 2 20 0 0 0
X ZY XT X ZX Y Z T
Choose variable Z, the 2nd eqn is only one with neg. coeff Z X T 5 0 5.
minimize subject to2 2 0 535 0 5
0 0 0 0
X TY XZ X T
X Y Z T
.
.
No variable can be chosen, optimal value 2 is found
![Page 28: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/28.jpg)
28
Another exampleAnother example
0 1 2 3 4
1
2
3
4
Y
X
-2 -1 0
1
2
preferredsolutions
minimize subject toX YYXX
Y X
013
2 3
An equivalent simplex form is:
000003231
321
1
3
2
SSSYXSYX
SXSX
An optimization problem showing contours of the objective function
![Page 29: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/29.jpg)
29
Another exampleAnother example
0 1 2 3 4
1
2
3
4
Y
X
-2 -1 0
1
2
Basic feasible solution form: circleminimize subject to0 0 5 0 5
3 0 5 0 523
1 3
1 3
2 3
3
. .. .S S
Y S SS SX S
Choose S3, replace using 2nd eq
2
23
21
21
12
5.05.02subject to 5.05.01 minimize
SXSS
SSYSS
Optimal solution: box
![Page 30: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/30.jpg)
30
The Missing PartThe Missing Part
How do we get the initial basic feasible solution?
Solve a different simplex problem Add artificial variables to make equations in
basic feasible solved form Minimize the sum of the artificial variables If the sum is zero we can construct a bfs for the
original problem
![Page 31: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/31.jpg)
31
The Missing Part ExampleThe Missing Part Example
X SX SX Y S
2
3
1
13
2 3
Original simplex form equations
A X SA X SA X Y S
1 2
2 3
3 1
133 2
With artificial vars in bfs form:
Objective function: minimizeA A A
X Y S S S1 2 3
1 2 37 2
![Page 32: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/32.jpg)
32
Missing Part Example IIMissing Part Example II
minimize subject toA A AY S S A AS S A AX S A
1 2 3
1 3 2 3
2 3 1 2
3 2
3 05 05 0 5 0523
. . . .
Problem after minimization of objective function
Removing the artificial variables, the original problem
Y S SS SX S
3 0 5 0523
1 3
2 3
3
. .
![Page 33: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/33.jpg)
33
Implication and EquivalenceImplication and Equivalence
Other important operations involving constraints are:
implication: test if C1 implies C2 impl(C1, C2) answers true, false or unknown
equivalence: test if C1 and C2 are equivalent equiv(C1, C2) answers true, false or unknown
![Page 34: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/34.jpg)
34
Implication ExampleImplication ExampleB u ild in g a H ou s e
D oors2 d ays
S tag e B
In terio r W alls4 d ays
C h im n ey3 d ays
S tag e D
S tag e E
Tiles3 d ays
R oo f2 d ays
W in d ows3 d ays
S tag e C
E xte rio r W a lls3 d ays
S tag e A
F ou n d ation s7 d ays
S tag e S
For the house constraints CH, will stage B have to be reached after stage C?
CH T TB C
For this question the answer if false, but if we require the house to be finished in 15 days the answer is true
CH T T TE B C 15
![Page 35: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/35.jpg)
35
Implication and EquivalenceImplication and Equivalence
We can use impl to define equiv and vice versa
We can use a solver to do simple impl tests
e.g.
impl C C equiv C C C( , ) ( , )1 2 1 1 2
equiv C C impl C C impl C C( , ) ( , ) ( , )1 2 1 2 2 1
impl C C solv C C( , ) ( )1 2 1 2
impl CH T T solv CH T TB C B C( , ) ( )
![Page 36: Constraint operations: Simplification, Optimization and Implication](https://reader030.fdocuments.us/reader030/viewer/2022020219/56815c31550346895dca151f/html5/thumbnails/36.jpg)
36
Simplification, Optimization Simplification, Optimization and Implication Summaryand Implication Summary
Equivalent constraints can be written in many forms, hence we desire simplification
Particularly if we are only interested in the interaction of some of the variables
Many problems desire a optimal solution, there are algms (simplex) to find them
We may also be interested in asking questions involving implication