Linear programming optimisation function using source XML

Hi all,

I have a query relating to possible strategies for linear programming using source XML. I’m trying to identify whether it is possible to include a least-cost optimisation calculation within one of the apps we have currently.

I’ve found myself coming to a roadblock with how the listed Commcare functions, particularly min and the checklist functions could support this back-end calculation within the hidden values.

At present I have something like:

However I’m unsure how to bring these together within a single function for valid outputs. One suggested possibility is editing the source XML
Has anyone done something similar or used a similar approach previously?
Any guidance or clarification you can give me towards whether such an integration is possible and what robust approaches exist would be very much appreciated.