<p>Consider the following problem:</p>

<p>Let there be a set A of $n$ items $A=\{z_1, ..., z_n\}$, and let $W$ be a strictly positive integer.  Each item $z_i$ has a value $v_i$ and a weight $w_i$. Finding a subset $AS$ of $A$ so that the weight of $AS$ is less than $W$ and the value of $AS$ (the sum of the value of its items) is maximized is the <strong>0/1 Knapsack Problem</strong></p>

<p>Now, consider a deviation from it where the items in $A$ have certain dependency relationships between each other, and these dependencies can be captured by a directed acyclic graph $G(A, E)$.  The value of the set $AS$ is no longer the sum of the value of the items in $AS$. For each item in $AS$,  its value depends on which other items are also in $AS$.  </p>

<p>More formally, this is how we calculate the value of an item $v$ in $AS$.  Let $a$ be <strike>the</strike> a closest ancestor of $v$ in $G$ that is also in $AS$.  Then the contribution of $v$ to the value of $AS$ would be its own value, plus the value of all the ancestors in the path between $v$ and $a$. (Since this is a DAG, there could be many of these ancestors. See formalization below).</p>

<p>This problem has important applications in computational workflow systems where you have limited storage, and you want to optimize the computational time of running a workflow (represented by a DAG) by storing some of the intermediate datasets for future use.</p>

<p><strong>My questions</strong></p>

<p>The problem is obviously NP-Hard because the Knapsack problem can be reduced to it. I have a feeling that it is likely that no pseudo-polynomial algorithm exists for it. Do you know of a problem that I could use to reduce to my problem to confirm those feelings? Or do you think that it is possible to produce a pseudo-polynomial algorithm for this?</p>

<p><strong>EDIT: FORMALIZATION ON HOW TO COMPUTE VALUE OF $AS$</strong></p>

<p>To succinctly define the value of $AS$ I will add to the notation from above a little bit. Let $v(z_i)$ be equivalent to $v_i$ from above. Then $v(z_i|AS)$ reads: value of node $z_i$ given answer set $AS$.</p>

<ul>
<li>If $z_i \in AS$, then $v(z_i|AS)=0$. </li>
<li>Otherwise, if $z_i \not\in AS$, $v(z_i|AS) = v(z_i) + \sum_{z_j \in parents(z_i)}{v(z_j|AS)}$</li>
</ul>

<p>Those two definitions are enough to then say that:</p>

<p>$value(AS) = \sum_{z_i \in AS}{v(z_i|AS-\{z_i\})}$</p>

<p><strong>END OF EDIT</strong></p>

CC BY-SA 3.0
2015-04-22T00:14:55.930Z
In the value calculation, if $v$ has multiple ancestors of maximal distance, do we take the maximum-valued path or all paths from the ancestors to $v$ (or all shortest paths, or the maximum-valued path for each ancestor or something else)? Also, do we include the value of $a$ but not the value of $v$? And, in a diamond DAG, if we get the top and bottom nodes do we score both parents of $v$? Would be helpful if there's a resource describing how this value is calculated, or if we can formalize that a little more.
William Macrae
CC BY-SA 3.0
2015-04-22T03:51:58.937Z
Thanks for pointing that out. Edit added to the question.
ASDF
<np-hardness><time-complexity><reductions>
Complexity of Knapsack-type problem with applications to computational workflows
ASDF
# Complexity of Knapsack-type problem with applications to computational workflows

(Asked by: username_0 on 2015-04-19)

Consider the following problem:

Let there be a set A of $n$ items $A=\{z\_1, ..., z\_n\}$, and let $W$ be a strictly positive integer. Each item $z\_i$ has a value $v\_i$ and a weight $w\_i$. Finding a subset $AS$ of $A$ so that the weight of $AS$ is less than $W$ and the value of $AS$ (the sum of the value of its items) is maximized is the **0/1 Knapsack Problem**

Now, consider a deviation from it where the items in $A$ have certain dependency relationships between each other, and these dependencies can be captured by a directed acyclic graph $G(A, E)$. The value of the set $AS$ is no longer the sum of the value of the items in $AS$. For each item in $AS$, its value depends on which other items are also in $AS$.

More formally, this is how we calculate the value of an item $v$ in $AS$. Let $a$ be the a closest ancestor of $v$ in $G$ that is also in $AS$. Then the contribution of $v$ to the value of $AS$ would be its own value, plus the value of all the ancestors in the path between $v$ and $a$. (Since this is a DAG, there could be many of these ancestors. See formalization below).

This problem has important applications in computational workflow systems where you have limited storage, and you want to optimize the computational time of running a workflow (represented by a DAG) by storing some of the intermediate datasets for future use.

**My questions**

The problem is obviously NP-Hard because the Knapsack problem can be reduced to it. I have a feeling that it is likely that no pseudo-polynomial algorithm exists for it. Do you know of a problem that I could use to reduce to my problem to confirm those feelings? Or do you think that it is possible to produce a pseudo-polynomial algorithm for this?

**EDIT: FORMALIZATION ON HOW TO COMPUTE VALUE OF $AS$**

To succinctly define the value of $AS$ I will add to the notation from above a little bit. Let $v(z\_i)$ be equivalent to $v\_i$ from above. Then $v(z\_i|AS)$ reads: value of node $z\_i$ given answer set $AS$.

* If $z\_i \in AS$, then $v(z\_i|AS)=0$.
* Otherwise, if $z\_i \not\in AS$, $v(z\_i|AS) = v(z\_i) + \sum\_{z\_j \in parents(z\_i)}{v(z\_j|AS)}$

Those two definitions are enough to then say that:

$value(AS) = \sum\_{z\_i \in AS}{v(z\_i|AS-\{z\_i\})}$

**END OF EDIT**

**Tags:** np-hardness, time-complexity, reductions
> **Comments:**
> **username_1**: In the value calculation, if $v$ has multiple ancestors of maximal distance, do we take the maximum-valued path or all paths from the ancestors to $v$ (or all shortest paths, or the maximum-valued path for each ancestor or something else)? Also, do we include the value of $a$ but not the value of $v$? And, in a diamond DAG, if we get the top and bottom nodes do we score both parents of $v$? Would be helpful if there's a resource describing how this value is calculated, or if we can formalize that a little more.  
> **username_0**: Thanks for pointing that out. Edit added to the question.  

---

## 0 answers

