# Optimal command pipelining that maximizes total value in a given time duration

Consider I have two types of commands A and B which can be pipelined. Each of these types have a certain time duration and a value associated with it. For example,

A = <|"time"->180, "value"->5|>;
B = <|"time"->60, "value"->1|>;


Minimum timing allowed of A and B is as follows

tAAsame = 180; (* Cmd_A (same) to Cmd_A (same) *)
tAAdiff = 90; (* Cmd_A (diff) to Cmd_A (diff) *)
tBBsame = 60; (* Cmd_B (same) to Cmd_B (same) *)
tBBdiff = 10; (* Cmd_B (diff) to Cmd_B (diff) *)
tABsame = 180; (* Cmd_A (same) to Cmd_B (same) *)
tABdiff = 10; (* Cmd_A (diff) to Cmd_B (diff) *)


Now, consider I have commands: A0, A1, B0, B1. I would like to fit these commands in time 1000s which maximizes the total value of the commands in that time duration.

Here is an example of how these commands can be spaced. This is not optimal.

I looked into KnapSackSolve function but couldn't clearly think of how to input command to command timing constraint into it. Is there a way to input such information? if not what other ways are there to solve this command pipelining problem.