Replies: 1 comment 2 replies
-
Could you try importing sum from optlang.symbolics, that might be faster. It's quite likely optlang being slow, as it tries to simplify the expression with each added term. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to have the objective function of my model (iJO1366 - contains ~2600 reactions) to be minimize the sum of all the fluxes and the sum of 37 slack variables (or artificial fluxes) that are weighted.
![obj_func](https://private-user-images.githubusercontent.com/89584516/300278172-665bf0f1-6657-4078-9e36-da77a454cede.PNG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYwODUwNjUsIm5iZiI6MTcyNjA4NDc2NSwicGF0aCI6Ii84OTU4NDUxNi8zMDAyNzgxNzItNjY1YmYwZjEtNjY1Ny00MDc4LTllMzYtZGE3N2E0NTRjZWRlLlBORz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTExVDE5NTkyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMxYjJhNDNiZmYxZjg0ZDRiMDQyZmJkZjdjMGU0YWY0NjM3OTZiYjI3NGQ3ZjU2YWNkZWZmOGNhNzI5NWI1MjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lR9lv5arXr6HLksO41xxOcp6gAnc1PD-WsOTY2FsGPY)
so the v's are all the fluxes, beta is a scalar and the alpha's are the slack variables/artificial fluxes.
When I try to set this as the objective function it takes a very long time to set up (I gave up after 15 minutes). Is there no faster way to do this than what i'm doing now which is:
model.objective = model.problem.Objective(
sum(r.flux_expression for r in real_rxns) + beta * sum(r.flux_expression for r in alphas_rxns),
direction='min')
Thanks to anyone who helps!
Beta Was this translation helpful? Give feedback.
All reactions