|
Orbital library | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorbital.algorithm.template.Greedy
public class Greedy
Framework (template class) for Greedy Algorithms. The greedy algorithm does only perform local decisions.
GreedyProblem,
DynamicProgramming,
HillClimbing| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface orbital.algorithm.template.AlgorithmicTemplate |
|---|
AlgorithmicTemplate.Configuration |
| Constructor Summary | |
|---|---|
Greedy()
|
|
| Method Summary | |
|---|---|
Function |
complexity()
O(n*log n + n*f(n)) for n=|C| candidates. |
java.lang.Object |
solve(AlgorithmicProblem gp)
solves by greedy. |
Function |
spaceComplexity()
Measure for the asymptotic space complexity of the central solution operation in O-notation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Greedy()
| Method Detail |
|---|
public java.lang.Object solve(AlgorithmicProblem gp)
The canonical greedy algorithm for a filtered system of sets (C,U) is
{e1,...,en} := C sorted such that w(e1)>=...>=w(en)
S := Ø
for i = 1 to n do
if S union {ei} in U then
// optionally check that w(ei)>=0 if w has negative values
S := S union {ei}
end if
end for
return S
Observe that the greedy algorithm does only perform local decisions.
Somewhat generalized, with a little more explicit structure, and adapted to the concrete methods in the hook class, the greedy algorithm in SETL looks like this:
Set greedy(Set C) { Set S := Ø; while S is partialSolution and C != Ø do // weight is quality criterium retract x from C such that w(x) is maximal (with regard to S); // nextPartialSolution computes new partial solution S := nextPartialSolution(S,x); // generalized case with changing candidates C := nextCandidates(C); end while; if S is solution then return S; else return Ø; }
solve in interface AlgorithmicTemplategp - algorithmic problem hook class which must fit the concrete
algorithmic template framework implementation.
Function.apply(Object)public Function complexity()
GreedyProblem.isPartialSolution(List)
is f(n).
complexity in interface AlgorithmicTemplateAlgorithmicTemplate.solve(AlgorithmicProblem)public Function spaceComplexity()
AlgorithmicTemplate
spaceComplexity in interface AlgorithmicTemplateAlgorithmicTemplate.solve(AlgorithmicProblem)
|
Orbital library 1.2.0: 23 Apr 2008 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||