I was reading an article and I've found the graph below that represents the algorithm cost, and I was wondering if the values are representing the algorithm cost why they are negative? and what are they referring to ? I also would like to know the algorithm cost is calculated according to what and why the each value has a sort of a min and max value ?
Thank you.
Update:
here is the link for the paper: Real-Time Planning as Decision-Making under Uncertainty
Related
I'm trying to solve a variant of knapsack problem that i haven't seen before.
in this variant we have a vector v consist of values per gram for each item and we also have a limited weight of each item and our goal is to find the maximum value that can be gain if we have a pack of size M.
I tried greedy approached but haven't found any solution. i think the most difficult part is to do it in O(n) because we shouldn't sort anything.
anyone has any idea?
If the value per gram has reasonably narrow bounds, you can counting-sort or radix-sort or bucket-sort it in linear time by the value per gram, and then just fill up the bucket in order of most valuable substances. What do I mean by reasonable limits? Specifically, I mean that there are asymptotically fewer meaningful "values per gram" than there are kinds of substances.
Given n checks, each of arbitrary (integer) monetary value, decide if the checks can be partitioned into two parts that have the same monetary value.
I'm beyond mind blown on how to solve this. Is there an algorithm to solve this in polynomial time or is this NP-Complete?
Yes it's an NP complete problem. It's a variation of the subset sum problem.
Actually you can solve this in O(n*sum/2) using dynamic programming, first sum up all checks into a varaibel sum, then you can perform dp on the checks values (either take it or leave it or take it) and check at the end if that sum is equal to s/2.
I'm trying to use A* to find the optimal path in a Graph.
The context is that a tourist starts at his hotel, visits landmarks and returns to his hotel at the end of the day. The nodes (landmarks) have two values: importance and time spent. Edges have two values: time spent and cost(currency).
I want to minimize cost, maximize importance and make sure total time is under a certain value. I could find a balance between cost, importance and time for the past path-cost. But what about the future cost? I know how to do it with simpler pathfinding, but is there a method I could follow to find the heuristic I need?
You have a multi-dimensional objective (cost and importance) and so your problem is ill-posed because you haven't defined how to trade off cost and importance while you are "minimizing" cost and "maximizing" importance. You'll only get a partial ordering on sites to vist, because some pairs of sites may be incomparable because one site may have a higher cost and higher importance, while the other may have lower cost and lower importance. Look up multi-objective knapsack problem if you want concrete ways to formalize and solve your problem. And beware -- it can get a bit hairy the deeper you go into the literature.
I guess I find a problem on this wiki page:
I think the `
have a cost of at most ε times
in the Weighted A* algorithm part should be
have a cost less than ε times
instead.
Because here it assumes ε > 1. But I am not sure about it, just want to listen anybody's opinion on this..
Thank you for your help in advance :)
I believe the paragraph starting "Weighted A*. If ha(n) is" is correct, and a guarantee that the cost of the path found is at most eta times the cost of the best path is the sort of guarantee you want - since you are looking for the least cost path and trying to reduce cpu time you are settling for a sub-optimal (higher cost) solution but obtaining a guarantee that the cost is not too bad - at most eta times the cost of the best path.
I do think that there is an inconsistency between the use of eta in this paragraph and that in the paragraph above - I don't know whether that is a mistake or whether it derives from an unfortunate difference of conventions between weighted A* and a more general definition of approximate solutions.
The paragraph is consistent with the notes at http://inst.eecs.berkeley.edu/~cs188/sp11/slides/SP11%20cs188%20lecture%204%20--%20CSPs%206PP.pdf - bottom of page 5 on the pdf and with a rough proof. When weighted A* thinks it has a solution with cost g(x) all nodes still in play must have a predicted cost g(y) + eh(y) at least this. To get the largest possible error assume that g(y) is zero and that eh(y) = g(x) for correct solution y and we see that the solution A* thinks it has found is e times as expensive as y - since we presume that the original h() is admissable and therefore an upper bound on cost.
The Hungarian algorithm solves the assignment problem in polynomial time. Given workers and tasks, and an n×n matrix containing the cost of assigning each worker to a task, it can find the cost minimizing assignment.
I want to find the choice for which cost is max? Can I do it using Hungarian or any similar method? Or this can only be done exponentially?
Wikipedia says:
If the goal is to find the assignment that yields the maximum cost,
the problem can be altered to fit the setting by replacing each cost
with the maximum cost subtracted by the cost.
So if I understand correctly: among all the costs you have as input, you find the maximum value. Then you replace each cost x by max - x. This way you still have positive costs and you can run the Hungarian algorithm.
Said differently: Hungarian tries to minimize the assignment cost. So, if you are looking for the maximum, you can reverse the costs: x -> -x. However, some implementations (don't know if all or any) require positive numbers. So the idea is to add a constant value to each cost in order to have positive numbers. This constant value does not change the resulting affectation.
As David said in the comment:
Multiply the cost matrix by -1 for maximization.