I am reading CLRS by myself and I am finding but difficult to understand few concepts.
Compared to Greedy, in Dynamic Programming we make choices globally and end up with optimal solution. I understood these concepts well with examples of Shortest path in Multi Graph and also by Knapsack Problem.
I am unable to understand how we are making choices dynamically in Matrix Chain. I have understood the recurrence relation, but I am not able to standard about dynamic decisions. (I understood that it has optimal substructure property)
How matrix chain algorithm would work if it is solved by Greedy Method ?
Thank you !
This problem can't be solved by greedy method.
for example, a matrix chain [3x2]•[2x3] •[3x4].
The consequence will be (([3x2]•[2x3]) •[3x4]) using greedy method, but the optimal answer is ([3x2]•([2x3] •[3x4])).
More details:https://www.cs.washington.edu/education/courses/421/04su/slides/matrixchain.pdf
Related
I am trying to solve some problems that can be mapped in convex optimisation problem.
In particular is for analysis of quantum state tomography data.
In Matlab there are some tools to help you do this, like SeDuMi or CVX
http://sedumi.ie.lehigh.edu
http://cvxr.com/cvx/
But I could not find anything similar in Mathematica, on the web or in the forums.
Does anybody know if there is an easy way of implementing this kind of algorithm in Mathematica?
I would like to avoid to be forced to switch to Matlab to solve this problem. Nothing against it, but I have most of the programming for this state tomography developed in Mathematica.
Thank you very much.
I had also some troubles with Mathematica in
optimization, exactly on convex problems.
I suggest you export to CVX, which will require
some work because it wants the problem in matrix notation.
Otherwise, to remain with the algebraic formulation,
you could try with Maple, which has, as far
as I can tell, better optimizers than Mathematica.
(check the doc to have an idea)
I am currently working on a support vector machine (SVM) project. The version of SVM that I am working on is Linear SVM in Primal Form and I am having hard time understanding where to start.
In general, I think I understand the theory; basically I need to minimize norm of w under certain constraint. And the Lagrangian function will be my objective function to be minimized (after Lagrange multiplier is applied).
The things that I don't understand is that I was told from my professor that we will be using Quasi-Newton method along with BFGS update. I have tried 2D and 3D case for Newton's method and I think I have good grasp of the algorithm, but I don't see how Quasi-Newton method is applied to find the coefficients alpha. Also, many literature that I read so far tells to apply Quadratic programming to find the coefficients.
How is the iterative algorithm of Quasi-Newton related to finding coefficients of w...? And how is quadratic programming related to Quasi-Newton? Can anyone please walk me through what is going on?
You are cunfusing many things here
"alpha coefficients" are only in the dual form, so you do not find them in your case
"apply Quadratic programming", quadratic programming is a problem, not a solution. you cannot "apply QP", you can only solve a QP, which in your case will be solved using quasi-newton method
"how is (...) related to finding coefficientss of w" exactly the same way, as this optimization technique is related to finding the optimal coefficients of any function. You are going to minimize the function of w, so applying any optimization technique (in particular quasi-netwton) will lead to solution expressed as w coefficients
I have a directed graph which is strongly connected and every node have some price(plus or negative). I would like to find best (highest score) path from node A to node B. My solution is some kind of brutal force so it takes ages to find that path. Is any algorithm for this or any idea how can I do it?
Have you tried the A* algorithm?
It's a fairly popular pathfinding algorithm.
The algorithm itself is not to difficult to implement, but there are plenty of implementations available online.
Dijkstra's algorithm is a special case for the A* (in which the heuristic function h(x) = 0).
There are other algorithms who can outperform it, but they usually require graph pre-processing. If the problem is not to complex and you're looking for a quick solution, give it a try.
EDIT:
For graphs containing negative edges, there's the Bellman–Ford algorithm. Detecting the negative cycles comes at the cost of performance, though (worse than the A*). But it still may be better than what you're currently using.
EDIT 2:
User #templatetypedef is right when he says the Bellman-Ford algorithm may not work in here.
The B-F works with graphs where there are edges with negative weight. However, the algorithm stops upon finding a negative cycle. I believe that is a useful behavior. Optimizing the shortest path in a graph that contains a cycle of negative weights will be like going down a Penrose staircase.
What should happen if there's the possibility of reaching a path with "minus infinity cost" depends on the problem.
This question is related to dynamic programming and specifically rod cutting problem from CLRS Pg 362
The overall optimal solution incorporates optimal solutions to two related subproblems.
The overall optimal solution is obtained by finding optimal solutions to individual subproblems and then somehow clubbing them. I can't understand the intuition and concept. Any links, examples?
thanks
You can compare dynamic programming and greedy approach.
Optimal substructure means that optimal solution can be found by finding optimal solutions to subproblems. If this is not the case, than sum of optimal solution of subproblems doesn't give us optimal global solution.
For example, consider Dijkstra's algorithm. If we know shortest path from node A to node C than we can use this information to find shortest path to another nodes as well.
If this is not the case, we can't compose optimal solutions to subproblems and get global optimal solution, than we can use greedy approach. Look at change making problem for example. Greedy algorithm makes local optimal decisions and find some solution, but this solution is not guaranteed to be optimal.
I am working on a system of optimisation problems. These tasks can be solved by a generic optimization accross all the state space. But some of my equations are independent of the remaining system( imagine a Jacobian Matrix with some blocks full of zero ) and i would like to use this fact to optimize first the joint equations and then taking the previous solution as an input finish to solve the independent components.
The rules that say the relation between the tasks can be represented as an oriented graph, but this graph contains cycle because of the joint equations, which mean that i can't use a topological sort on it.
Does anyone have an idea of how to solve this kind of pb?
Thx
There are a couple of types of frameworks you can look into (instead of inventing it yourself), which might solve your problem. The question is a bit to abstract to tell which one suits your needs, so take a look at these:
Use a solver framework to solve this optimization and look through the search space of. Take a look at Drools Planner, Gurobi, JGap, OpenTS, ...
Use a rules engine to apply the optimization changes. Take a look at Drools Expert, JESS, ...