I know that if I can express a problem as a (weighted) matroid M = (E, S) or a greedoid then I can assure that there is an algorithm which will give me the optimal solution. For example for matroids it goes something like:
T = {} sort(E) increasingly for e in the sorted array if (T union {e}) is an independent set T = T union {e} which gives the minimum solution in $O(n\log(n) + nf(n))$ running time where $f$ is the time that takes to evaluate if its an independent set.
So for example I have the following problem: Given an array $E$ give the maximum value attainable summing up to $k$ elements of it. We can write it as the following matroid:
$ M = (E, S = \{ F \,\lvert\, \#F \leq k \land F \in \mathcal{P}(E) \}) $
It's easy to see that $S$ is an independent set because it follows all the axioms of a matroid:
- $\emptyset \in S$.
- If $A \in S$ and $B \subseteq A$ then $B \in S$.
- If $A, B \in S$ and $\lvert A \rvert > \lvert B \rvert$ then there is an $x \in A - B$ such that $B \cup \{x\} \in S$.
In this particular case our set weight function is $w(F) = \sum_{x \in F} \max(E) - x$. (because our first algorithm is a minimisation)
My problem then comes with a similar problem where we have a car that is travelling through a straight line and it can travel $L$ distance before refuelling, it also has mapped several points where it knows it can refuel, $x_1 \leq x_2 \cdots \leq x_n$.
We want to get the minimum number of stops needed for refuelling that gets us to $x_n$. The greedy strategy here is to move the car as much as possible before stopping each time. But I can't find any formulation to make this a matroid or greedoid.
For example I tried taking sets where all the points follow each other in the original line and they diff between min and max is less than L but that breaks the third axiom.
tl;dr I want to cast the last 3 paragraphs as a matroid but I'm having issues finding the independent set.