Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement callbacks to make problem modification pretty #53

Merged
merged 21 commits into from
Apr 6, 2021

Conversation

stelmo
Copy link
Collaborator

@stelmo stelmo commented Apr 1, 2021

Problem modification needs to be streamlined

change constraints, solver options, objectives etc. in a nice, extendable way

@exaexa
Copy link
Collaborator

exaexa commented Apr 1, 2021

This depends on the previous PR right? can we mark the target branch accordingly? (so that the changes aren't mixed)

@stelmo
Copy link
Collaborator Author

stelmo commented Apr 1, 2021

This depends on the previous PR right? can we mark the target branch accordingly? (so that the changes aren't mixed)

yes, done!

@stelmo stelmo changed the base branch from master to cherry-49 April 1, 2021 14:31
Base automatically changed from cherry-49 to master April 1, 2021 18:37
@exaexa
Copy link
Collaborator

exaexa commented Apr 1, 2021

@stelmo I rebased this to master (which now also means that this resides correctly on top of #51). Before you start working on anything, please do git fetch -a; git checkout mo-callbacks-fba; git rebase --hard origin/mo-callbacks-fba. If you have any uncommited work, save it before using git stash.

@stelmo
Copy link
Collaborator Author

stelmo commented Apr 1, 2021

Despite you telling me exactly what to do, I think this is going to push my git skills to the next level 😁

@laurentheirendt laurentheirendt changed the title WIP: implement callbacks to make problem modification pretty Draft: implement callbacks to make problem modification pretty Apr 2, 2021
@laurentheirendt laurentheirendt marked this pull request as draft April 2, 2021 06:09
@laurentheirendt laurentheirendt changed the title Draft: implement callbacks to make problem modification pretty implement callbacks to make problem modification pretty Apr 2, 2021
@stelmo
Copy link
Collaborator Author

stelmo commented Apr 2, 2021

So I made many changes in commit cb91565:

  1. CobraModel is now StandardModel
  2. I implemented callbacks on all functions using StandardModel
  3. Doing (2) caused me to simplify A LOT of code
  4. I also created a new file called "utilities.jl" in src/analysis that should house functions that analyse solutions from functions in src/analysis, e.g. flux_balance_analysis
  5. I changed the names of all my functions to fit in with your way of naming them e.g. fba -> flux_balance_analysis
  6. I also made new function that map solutions to vectors and dicts like you guys do e.g. flux_balance_analysis_vec
  7. I changed hit_and_run slightly: now you feed it a JuMP model as opposed to a "normal" model. Basically, I thought it makes more sense to do it this way since the user will almost always be interested in sampling from a solution space AFTER having run fba, this way they can just feed in the output of e.g. flux_balance_analysis and roll from there.
  8. Functions that dispatch on StandardModel now return nothing if things went wrong during solving (like your functions)

@stelmo
Copy link
Collaborator Author

stelmo commented Apr 2, 2021

The next step is to get pretty macros working, currently I am trying to get this to work:

@flux_balance_analysis_vec model Tulip.Optimizer begin
    modify_objective(biomass)
    modify_constraint(glucose, -8.0, -8.0)
end

Unfortunately, I got stuck here trying to get the modification macro working :(

@stelmo stelmo mentioned this pull request Apr 3, 2021
@stelmo
Copy link
Collaborator Author

stelmo commented Apr 3, 2021

The next step is to get pretty macros working, currently I am trying to get this to work:

@flux_balance_analysis_vec model Tulip.Optimizer begin
    modify_objective(biomass)
    modify_constraint(glucose, -8.0, -8.0)
    knockout(gene1)
    ...
end

Unfortunately, I got stuck here trying to get the modification macro working :( Note I have not implemented knockout(...), but the other modification functions are done.

I got this working! However, I stopped adding stuff to this PR since it was getting out of hand. Once it's merged I will make a new one and add more cool macros. Then we will be well on our way to making something amazing even more amazing :)

@stelmo stelmo marked this pull request as ready for review April 3, 2021 16:15
src/analysis/fba.jl Show resolved Hide resolved
src/analysis/fva.jl Outdated Show resolved Hide resolved
src/analysis/fva.jl Outdated Show resolved Hide resolved
src/analysis/pfba.jl Show resolved Hide resolved
src/analysis/pfba.jl Outdated Show resolved Hide resolved
src/sampling/sampling_tools.jl Outdated Show resolved Hide resolved
src/sampling/sampling_tools.jl Outdated Show resolved Hide resolved
test/analysis/fba.jl Outdated Show resolved Hide resolved
test/analysis/fba.jl Outdated Show resolved Hide resolved
test/base/solver.jl Show resolved Hide resolved
Copy link
Collaborator Author

@stelmo stelmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my replies

src/analysis/fba.jl Show resolved Hide resolved
src/analysis/fba.jl Outdated Show resolved Hide resolved
src/analysis/fva.jl Outdated Show resolved Hide resolved
src/analysis/fva.jl Outdated Show resolved Hide resolved
src/analysis/pfba.jl Show resolved Hide resolved
src/analysis/utilities.jl Outdated Show resolved Hide resolved
src/base/solver.jl Outdated Show resolved Hide resolved
src/base/utilities.jl Show resolved Hide resolved
src/sampling/sampling_tools.jl Outdated Show resolved Hide resolved
test/analysis/fba.jl Outdated Show resolved Hide resolved
@laurentheirendt
Copy link
Member

nice work 🎉

@laurentheirendt laurentheirendt merged commit d334082 into master Apr 6, 2021
@laurentheirendt laurentheirendt deleted the mo-callbacks-fba branch April 6, 2021 15:02
exaexa pushed a commit that referenced this pull request Jul 8, 2021
implement callbacks to make problem modification pretty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants