How can I finish formulating this problem?

48 Views Asked by At

I'm a software engineer with a very limited background in maths, and I'm trying to teach myself to think more mathematically as I try to learn more about maths. I'm currently trying to formulate a solution to a (programming) problem as practice.

The problem, generally, is one of ordering some list of items by their relevance, for some definition of relevance. More specifically, relevance is defined as having one or more children whose distance between two dates is smaller than some fixed amount, and does not have some marker set (which I might express as (!set && (a-b < c)) in code)

So far, my formulation (is that what this would be called?) goes thus:

Let $r(\alpha)$ be the relevance function of $\alpha%$. Let $\Delta(\beta)$ be the function measuring the distance (the domain term) of $\beta$, where $\beta$ is some child of $\alpha$.

We can calculate the relevance of $\alpha$ as $r(\alpha) = \sum\Delta(\beta)$.

Now I'm stuck on how to write $\Delta(\beta)$. I know it needs to have the following properties, but I don't know how to represent that mathematically, or even if that's the right approach:

  1. $\Delta(\beta)$ should always be 0 if the flag is set on the child
  2. $\Delta(\beta)$ should always be 0 if the distance between its two dates is greater than the fixed amount.
  3. $\Delta(\beta)$ should return a value greater than 0 when the conditions are met. This value should be greater the smaller the distance between the two dates (including negative distance)

My current thought is to ignore point 1 (that seems like a programming implementation detail) and write $\Delta(\beta)$ as the square of the difference between dates $\Delta(\beta) = (D{_1}-D{_2})^2$ (where $D{_1}$ and $D{_2}$ are the first and second dates of $\beta$).

Is this a correct/good formulation of the problem?