0

This is the first time I ask a question on the site. I am working in R and am looking to optimise the total biomethane production as the sum of that allowed by each substrate I mobilise. However, I have to respect some process constraints. My final mix of substrates must have a total Carbon/Nitrogen ratio of <30. In other words, the average Carbon/Nitrogen ratio weighted by the mobilised quantity of each substrate must be less than 30. Using the lpsolveapi package, I don't know how I can achieve this. Would you have an idea please? The constraint should look like this:

((Amount Substrate A * C/N Substrate A)/(Amount Substrate A + B)) + ((Amount Substrate B * C/N Substrate B)/(Amount Substrate A + B)) < 30

I thank you in advance for your help. Have a nice day

1 Answers1

0

If " C/N Substrate A" and " C/N Substrate B" are constants and the amounts are non-negative variables then

((Amount Substrate A * C/N Substrate A)/(Amount Substrate A + B)) + ((Amount 
Substrate B * C/N Substrate B)/(Amount Substrate A + B)) < 30

can be written as:

Amount Substrate A * C/N Substrate A + Amount 
Substrate B * C/N Substrate B <= 30*(Amount Substrate A + B)

This is now a linear constraint. Note that we can't do < for different reasons. Only <= is allowed in optimization models.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39
  • Thank you very much for your answer. If I use the "lpSolveAPI" package, how can I insert "30*(Amount Substrate A + B)" considering that (Amount Substrate A + B) is the result of the optimization? Below is the concerned line of code: add.constraint(lprec, c( C/N Substrate A, C/N Substrate b), "<=", 30). "C/N Substrate A" and "C/N Substrate B" are both constants. Sorry, but this is the first time I am using an optimization tool. Thank you for your help. – Nicolas MALET Sep 06 '22 at 19:00
  • `a*x+b*y<=c*z <=> a*x+b*y-c*z<=0` – Erwin Kalvelagen Sep 06 '22 at 21:33