Sunday, February 12, 2012

Tree Searching - Class Presentation

Tree searching is essentially a method of getting from point A to point B. There are two ways to conduct a tree search: one way generates many different results at once while another locates information related to one node first. This seems confusing, but please bear with the text till the end and things may become clearer to you.

Depth-first Searching: this search method basically takes your search through a tree as far in as possible. If there aren't any "priorities", the depth first search will mindlessly delve deeper and deeper until it hits a dead end. In the picture that follows, there is a comparison of the depth-first and breadth-first search method. Take note of how even though Node A branches into several other nodes, the search only returns to it after it has reached a deadend.

Breadth-first Search: contrary to a depth-first search which ignores all other branches from a node and returns them later, a breadth-first search explores all branches from one node before moving on to another, in order of priority if such exists. Again, note the image comparing the two search methods.

(Click to see image in full-size)


A possible application for this would be an automated maze generator/solver. Both work in essentially the same way. The program would simply randomly generate paths in a random direction and if i collides with terrain (computer limits), it will return to its previous starting point and generate in a different direction. For the maze solver, the program would explore the path uniformly until it hits a deadend and returns to the last split-point and explore the other way. In terms of mazes, the optimal search method for a solution would be the breadth-first search. Logically this makes sense because if the program chooses the wrong path, it will return to that node quicker and wind up on the right path than if it had been utilizing a depth-first search, in which case it would end up far deeper in the wrong direcion before it turns around.

This is a relatively interesting way of applying optimization that involves no calculus. In terms of mazes, we usually conduct our own breadth-first seach in our heads, mentally scanning the maze for possible dead ends and avoiding them. So get out those pencils and thinking caps!

Here's a link to an online program that demonstrates the depth-first search being utilized to "solve" a maze:

http://nullprogram.com/RunMaze/

Happy optimizing!

Thursday, February 2, 2012

Optimization: Day IV - V (Lagrange Multipliers)

Today, we continued our unit on optimization problems, and worked with a new method of finding the maxima and minima of functions given a constraint: the Lagrange Multiplier.

The key to Lagrange's method is to picture the level curves of the constraint at every value, c. If the constraint is not tangent to the curve, that means there is still room to either increase or decrease the values of x and y. Naturally, by this reasoning, the maximum or minimum of the function occurs at the point(s) of tangency.

To solve a problem using the Lagrange Multiplier, gradients must be used. Take the gradient of your objective function (the function you are trying to maximize or minimize), as well as the gradient of your constraint, after moving all variables and constants to one side of the equation.

One of the key things to include, now, is the multiplier itself:

The way this is incorporated with the two gradients is the following, assuming f(x) is the objective function and g(x) is the constraint:



The reason for this can be explained by one word: tangent. When dealing with surfaces, two surfaces are considered "tangent" when their gradients are parallel. This is true when the gradient vectors are either the same, or are scalar multiples of each other. And that scalar multiple is exactly what the Lagrange Multiplier is.

The rest is simple. Distribute the multiplier into the gradient of g(x); set the x values of each vector equal to each other and solve for the multipler--do the same for the y-values.

Plug the multiplier back into the constraint, and solve for x and y. To confirm that your point is really either the maximum or minimum, choose any point that satisfies the constraint--other than the point you found--and see whether is greater or less than the function value of the point derived by the Lagrange Multiplier.

Happy optimizing!

Tuesday, January 31, 2012

Optimization - Day III (Quick Note)

As a refresher lesson of optimization after Regents Week, we reverted back to optimization of one variable and solved some sample problems. In one of the problems, we had to deal with the distance formula:


After plugging in x and y, we eventually got a quadratic under a radical, and our task was to minimize that distance. What we gleaned from this problem is that when faced with such an optimization problem, it is not necessary to take the derivative of the function INCLUDING the radical. Rather, to minimize or maximize , simply maximize, or minimize, respectively, .

Happy optimizing!

Tuesday, January 17, 2012

Optimization - Day II

Today, we continued our discussion of simple optimization. In our first encounter with a simple problem, we realized how vital the initial modelling of our problem is. In the end, we came up with 5 simple steps to solving problems involving optimization:

1. Declare your variables.
-They don't have to be clever--as long as you don't mix them up with other variables.

2. Determine (and write down) your objective function.
-Your objective function is simply the function you are trying to optimize the result of. For example, if you are trying to optimize volume, your objective function would be V=xyz, assuming x, y, and z are your variables.

3. Determine your constraints.
-There are always constraints for optimization problems--otherwise, there would be nothing to base your optimization off of, making the entire problem pointless. Recognize these constraints and use them to solve the problem.

4. Take the objective function and find the first partial derivatives, set each
(fx and fy) equal to zero and solve for your critical values.
-Keep an open mind during this step, as you may find minor tricks to make your solution simpler.

5. Take the first partial derivatives and evaluate the second partial
derivatives at the critical point you extracted in Step 4. Using your second
derivative values (fxx, fyy, and fxy), determine d by using formula.


If d > 0 and fxx > 0, then your critical point is at a minimum.
If d > 0 and fxx < 0, then your critical point is at a maximum.
If d < 0, then your critical point is at a saddle point (both max and min, depending on your perspective).
If d = 0, prepare for Armaggedon.

Happy optimizing!

Friday, January 13, 2012

Optimization

Optimizing with a function of multi variables is similar to optimizing with a function of single variable. Instead of using axis, we use planes; instead of finding the maximum area, we find the maximum volume. The process is the same -- we scale down from three variables to two variables.

The Steps to Optimization are as follows:
1) Read and decode the problem
2) Determine the objective function - The thing you are trying to maximize/minimize
3) Identify constraints and relationships
4) Optimize (calculus!!)
5) Answer the question

In the example we did in class, we were asked to find the maximum volume of a prism given that a rectangular prism has a vertex on the origin, faces on the xy-, yz-, xz- plane, and on the plane 5x+4y+2z=20.

The objective function is v(x,y,z) = xyz; by using the plane given we can change 5x+4y+2z=20 into z = 10-5/2x-2y. We can eliminate one variable, leaving us with the function v(x, y) = xy(10-5/2x-2y).

Next, we find the partials in order to find the critical points
Vx = 10y-5xy-2y^2 Vxx = -5y = -25/3
Vy = 10x-5/2x^2-4xy Vyy = -4x = -16/3 Vxy = 10-5x-4y = 100/9

Since d = (-25/3)(-16/3) - 100/9 > 0, (4/3, 5/3) is at a relative maximum.

By solving a system of equations we can determine that the critical point is (4/3, 5/3). Using what we learned about critical points, we can say that there is a relative maximum which occurs at this point.

Be sure to do not only the textbook questions but also the Utexas assignment, and happy optimizing!