What kind of model to optimize the allocation a ressource in the context of time to event outcome? I have a list of N patients that are competing for one treatment at each time. A treatment becomes available at times t=1,...,T.
I want to build a model that can take the time-varying characteristics of all the patients at the time t, when a treatment becomes available,  and select the customer who will maximize the mean survival time of the patients in the list (those treated and those still waiting for another treatment).
What kind of approach or modelling should I use?
Thank you!
 A: Start with a simple situation: covariates, constant in time, related to outcome, and good models of survival as a function of time showing how the covariate values are associated with outcome both with the treatment ($S_{\text{With tx}}(t)$) and without ($S_{\text{No tx}}(t)$). You have a cohort of $N$ patients at time $t$, with known covariate values. Then the mean survival time is simply the total survival added up over all $N$ individuals, divided by $N$. So to maximize the mean survival over the cohort, you provide the treatment to the individual with the greatest predicted increase in survival associated with treatment. The predicted mean increase in survival $\mu_\text{With-No}$ for each individual is just the integral of the survival difference over time:
$$\mu_\text{With-No} = \int_0^{\infty}S_{\text{With tx}}(t)- S_{\text{No tx}}(t)dt. $$
You choose the individual for whom the treatment makes the largest difference in mean survival.
The modeling problem, even with time-constant covariates, is how to build that good model of survival with the type of data that you have. In principle, one could try to use the data you have on patients' outcomes over time together with the responses of the patients who received the treatment. But in your situation the current policies for allocating treatment would tend to confound the analysis; you would have to take those policies and their associations with covariate values and treatment decisions and outcomes into account. I recommend reading the Causal Inference Book by Hernán and Robins to learn about the difficulties you face.
Hernán and Robins use outcomes after heart transplants as an example running through their book. That's very similar to the treatment-allocation situation that you describe, and their book is focused on how to evaluate counterfactual outcomes.
If covariate values change over time, this whole exercise becomes even more fraught with difficulty. You need to work closely with a statistician experienced in these issues. No short answer on a site like this can hope to deal with the specific details of your situation.
You should know, however, that these statistical issues are only one consideration in equitable distribution of rare treatments like transplants. In other words, "maximiz[ing] mean survival time" (even if you could build a reliable model) would not be sufficient for treatment allocation, as that is just the "utility" part of the evaluation. "Justice" and "respect for persons" also need to be considered. If you look at the criterion for how organs are matched you will see that survival benefit per se is only one of the considerations, a consideration with different weighting from organ type to organ type.
