You are here

[dev] determine which score_type's enabled in create_energy_method?

4 posts / 0 new
Last post
[dev] determine which score_type's enabled in create_energy_method?
#1

Hey,

I have created an energy method and it works. However, I want to do a check at the time it is created for whether a particular score_type is enabled. Is there any way to know which score_types are enabled from within my create_energy_method function?

Thanks!

- Igor

Category: 
Post Situation: 
Fri, 2017-10-27 15:37
ipetrik_ambry

No, there's no way of determining what the weights are from the EnergyMethodCreator::create_energy_method() object.

The good news is that the create_energy_method() method for your particular EnergyMethod will not be called unless  one of the score types from the score_types_for_method() is enabled in the Scorefunction.  So if your EnergyMethod only controls one score type, you can be confident that the create_energy_method() will only be called if that score_type is enabled.

If your EnergyMethod controls several different score_types, and you want to change how you create the EnergyMethod object based on which one (or both) are enabled, then that's another story. However, you probably don't need/want to do that. If it's completely different EnergyMethod objects that need to get created, then you're better off just making multiple EnergyMethodCreators, one for each EnergyMethod type.  If it's the same EnergyMethod class, just constructed differently, then you're probably better off changing the EnergyMethod constructor to work generally (regardless of what the weights are), and then move the switching logic into the EnergyMethod's functions, where you can get the weights vector.

If that's an unsatisfactory answer, perhaps you can describe in more detail what you hope to do, and I can make more targeted suggestions.

Sat, 2017-10-28 09:41
rmoretti

... If it's the same EnergyMethod class, just constructed differently, then you're probably better off changing the EnergyMethod constructor to work generally (regardless of what the weights are), and then move the switching logic into the EnergyMethod's functions, where you can get the weights vector. ...

Thanks for the very thorough respose. It is the case that most of the computation is the same, so I don't want to create two different energy methods. Some of the score terms require a native structure, but most do not. I guess I'll probably just check in the "setup_for_*" methods.

Mon, 2017-10-30 11:14
ipetrik_ambry

That's how I'd probably do it.

Mon, 2017-10-30 12:02
rmoretti