Code Monkey home page Code Monkey logo

Comments (4)

jchodera avatar jchodera commented on June 20, 2024

It looks like this will require a change in the interface.

We currently have run_example.py call code like this (which will presumably be moved into a Sampler class):

# Initialization
alchemical_engine = alchemical_engine_library.AlchemicalEliminationEngine(alchemical_metadata)
ncmc_engine = ncmc_switching.NCMCEngine(temperature=temperature, timestep=switching_timestep, nsteps=switching_nsteps, functions=switching_functions)
...
# annihilation of old atoms
old_alchemical_system = alchemical_engine.make_alchemical_system(system, top_proposal, direction='delete')
[ncmc_old_positions, ncmc_elimination_logp] = ncmc_engine.integrate(old_alchemical_system, positions, direction='delete')
...
# creation of new atoms
new_alchemical_system = alchemical_engine.make_alchemical_system(top_proposal.new_system, top_proposal, direction='create')
[ncmc_new_positions, ncmc_introduction_logp] = ncmc_engine.integrate(new_alchemical_system, geometry_proposal.new_positions, direction='create')

Here are some possibilities:

  • Option 1. Have AlchemicalEngine.make_alchemical_system() also return the logP for changing the system from real to alchemical. This would require additional arguments (temperature).
  • Option 2. Have NCMCEngine.integrate() also incorporate the logP for changing the system from real to alchemical. This would require additional arguments (real_system).
  • Option 3. Combine AlchemicalEngine with NCMCEngine and merge these calls into a single call:
# Initialization
ncmc_engine = AlchemicalNCMCEngine(temperature=temperature, timestep=switching_timestep, nsteps=switching_nsteps, functions=switching_functions)
...
# annihilation of old atoms
[ncmc_old_positions, ncmc_elimination_logp] = ncmc_engine.integrate(top_proposal, positions, direction='delete')
...
# creation of new atoms
[ncmc_new_positions, ncmc_introduction_logp] = ncmc_engine.integrate(top_proposal, geometry_proposal.new_positions, direction='create')

I actually like Option 3 even if it means a bit more refactoring, since it reduces the number of arguments that must be specified multiple times and eliminates some intermediate variables (old_alchemical_system, new_alchemical_system) that are never used again. I'm not sure if there are really any disadvantages to this.

from perses.

pgrinaway avatar pgrinaway commented on June 20, 2024

Options 2 and 3 are both fine, IMO.

Re: option 2, I think that now that we have a convenience class for topology proposals that include both new and old systems, requiring real_system is not really a burden at all.

Re: option 3, I think this is probably the best option. Modular code is great, though as you've noted before, the AlchemicalEliminationEngine is just a thin bit of code around AbsoluteAlchemicalFactory anyway, so it might be less error-prone and more straightforward to just combine the two--especially since we'll always be starting and ending at "real" states.

I'm +1 on option 3.

from perses.

jchodera avatar jchodera commented on June 20, 2024

Great. I'll try implementing option 3 and see if I run into any showstoppers.

from perses.

pgrinaway avatar pgrinaway commented on June 20, 2024

Looks like this is resolved.

from perses.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.