optimal polygon triangulation

12
Optimal polygon Optimal polygon triangulation triangulation B98570137 廖廖廖– 廖廖 B96570112 廖廖廖 B98570118 廖廖廖 B98570131 廖廖廖 B98570153 廖廖廖

Upload: gitel

Post on 06-Feb-2016

74 views

Category:

Documents


0 download

DESCRIPTION

Optimal polygon triangulation. B98570137 廖柏翰 – 組長 B96570112 陳裕仁 B98570118 詹燿鴻 B98570131 蔡宗翰 B98570153 林承毅. 刻劃最佳解結構. Characterize the structure of an optimal solution 定義 weighting fuction : w (  v i v j v k ) = ( Vi+Vj +Vk) = P i P j P k - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Optimal polygon triangulation

Optimal polygon Optimal polygon triangulationtriangulation

B98570137 廖柏翰– 組長B96570112 陳裕仁 B98570118 詹燿鴻 B98570131 蔡宗翰 B98570153 林承毅

Page 2: Optimal polygon triangulation

Characterize the structure of an optimal solution定義 weighting fuction : w(vivjvk)= (Vi+Vj +Vk) =PiPjPk

We start with vi-1 rather than vi , to keep the structure as similar as possible to the matrix chain multiplication problem.Ai 對應於邊 Ai+1..j 對應於故 矩陣連乘為最佳三角化之特例q = t[i, k]+ t[k+1, j]+w(vi-1vkvj)

i1i vv

jivv

刻劃最佳解結構

Page 3: Optimal polygon triangulation

Ex:((A1(A2A3))(A4(A5A6))) The associated binary tree has n leaves, and hence n-1 internal nodes. Since each internal node other than the root has one edge entering it, there are n-2 edges between the internal nodes.full binary tree (n-1 leaves) triangulation (n sides)

Binary Tree for Triangulation:

Page 4: Optimal polygon triangulation

A triangulation of a polygon is a set T of chords of the polygonthat divide the polygon into disjoint trianglesT contains v0vkvn. w(T)=w(v0vkvn)+t[1,k]+t[k+1,n]

The two subproblem solutions must be optimal or w(T) would be less.–  Suppose the optimal solution has the first split at position k, we will divide polygon into A1..k (t[i,k]) Ak+1..n (t[k+1,n])

Dynamic ProgrammingDynamic Programming

Page 5: Optimal polygon triangulation

OPTIMAL TRIANGULATION OPTIMAL TRIANGULATION PROBLEMPROBLEM

求邊長數為 (n+2)的多邊形切成多個三角形後 ,內部所有三角形weighting function總和最小值最小。 key: 1.必成 (n+2)-2 = n 個三角形 , ex: ( 3+2 ) - 2 = 3 2. weighting function :W(ΔVi,Vj ,Vk) = Vi+Vj +Vk

V0

V4V1

V3V2

Input:0,6,4,3,2

Page 6: Optimal polygon triangulation

Let t[i,j] is W<Vi-1,Vi,….,Vj> Chose a point k for i≦ k<j W<Vi-1,Vi,..,Vj> = W<Vi-1,Vi,..,Vk> + W<Vk+1,Vi,..,Vj> ??

Vi-1

Vi

Vj

Vk

The weight of the middletriangle is :W(ΔVi-1+Vk+Vj)

Page 7: Optimal polygon triangulation

AN OPTIMAL SOLUTION TO A PROBLEM COTAINS AN OPTIMAL SOLUTION TO A PROBLEM COTAINS WHITIN IT AN OPTIMAL SOLUTION TO WHITIN IT AN OPTIMAL SOLUTION TO SUBPROBLEMSSUBPROBLEMS

Let is a optimal answer to V0-7

The yellow lines is a optimal answer to V0-4,why??

Proof by contradiction

Page 8: Optimal polygon triangulation

用遞迴定義最佳解用遞迴定義最佳解Recursively define the value of an

optimal solution.

j < i if)}(],1[],[{min

j=i if0],[

0. of weight a has <polygon Degenerate

...,<polygon theoftion triangula

optimalan of weight theben j < i 1for j]Let t[i,

11-jki

1-

1-

jki

ii

jii

vvvwjktkitjit

vv

vvvVi-1

Vj

Vk

M

L

R

Page 9: Optimal polygon triangulation

由下往上計算一個最佳解由下往上計算一個最佳解Compute the value of an optimal

solution in a bottom‐up fashion.Example => Input :1 2 3 4 5 6

1 2

3

45

6

Page 10: Optimal polygon triangulation

由下往上計算一個最佳解由下往上計算一個最佳解

i = 1 , j = 3 , find t[1,3] :◦ t[1,1] + t[2,3] + w(v0,v1,v3) = 0 + 9 + (1+2+4) = 16◦ t[1,2] + t[3,3] + w(v0,v2,v3) = 6 + 0 + (1+3+4) = 14

設 W(Vi,Vj,Vk) = Vi + Vj + Vk

Page 11: Optimal polygon triangulation

經由計算的資訊建立最佳解經由計算的資訊建立最佳解

Construct an optimal solution from computed information.

Output :Triangle<0,1,2>Triangle<0,2,3>Triangle<0,3,4>Triangle<0,4,5>

Page 12: Optimal polygon triangulation

程式實作結果程式實作結果int WeightingFunction(int i, int j,

int k){ return i+j+k;}MatrixChain()printTable()OptimalAnswer()

// Polygon Triangulation.c