简体   繁体   中英

LPSolve with R - Constraint : weighted average by the amount of substrates < a value

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM