Summary of tree-based dynamic planning exercises

Source: Internet
Author: User

Type 1: Multi-tree to binary tree Resource Allocation

 

For example:

* Example 1. course Selection: one course may be selected first, that is, some courses must be selected after another course is selected. The credits for each course are different and the maximum credits are obtained.

* Example 2. Key to freedom: You can open one room to multiple other rooms. The cost of each room varies, and the value is also different. You can get the maximum value with the minimum cost.

 

This type of question is characterized by the need to allocate resources on the Multi-tree and allocate different resources to different sub-trees for maximum value. It can be solved directly by using a backpack on a multi-Forks tree, but the more common method is to useExpression of the Left Child's Right brotherConvert to binary tree.

The general state transition equation after conversion:

F (I, j) indicates that resources with a total of J are allocated to the subtree where I is the root node.

F (I, j) = max {f (I. left, k) + f (I. right, J-cost (I)-k) + value (I), F (I. right, j)}, where K (0, J-cost (I ))

Explain the above equation. Each node I has two types of decisions:

1. consume resources in node I and obtain corresponding values, and then make decisions in the subnode and sibling node of node I;

2. Ignore node I and make a decision in I's sibling node (I. Right.

The state transition equation Writing Method for the above two examples is similar to this general writing method.

 

Type 2: different statuses of a node

(This type does not know how to call it)

For example:

* Example 1. guard arrangement: a guard on a node can ensure the security of its adjacent nodes. Each node has different security policies at different costs. The minimum cost is used to ensure the security of the entire tree.

* Example 2. A party without a superior: the employee and his direct supervisor will not appear at the same time. Each employee may have different levels of happiness at the party, so please be happy to the greatest extent possible.

 

This type of question features that each node has a different state. For example, each node in the guard arrangement has three states: 1. self-built guard; 2. the parent node has guards. 3. sub-nodes are equipped with guards. In Example 2, each node (employee) has two statuses: 1. participate; 2. not participate.

You can transfer the status of each node.

Example 2:

F (I, 0) indicates that I will not attend the party, and f (I, 1) indicates that I will attend the party.

F (I, 0) = sum {max {f (J, 0), F (J, 1 )}}

F (I, 1) = sum {max {f (J, 0 )}}

(J is the subnode of I)

The above two equations are explained:

When I attend the party, I's subordinates will not attend the party;

When I does not attend a party, I's subordinates can attend or not.

Example 1 is similar.

 

Type 3: resource allocation on Binary Trees

Is a simplified version of Type 1. The model of the question is a binary tree, which can be directly solved without conversion.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.