A few comments:
-  don't call set_model on restraints. That method is there so that restraints can override it to take action upon being added to the model. One needs to call model.add_restraint(), otherwise the model won't know what needs to be done in order to accurately evaluate the restraint (and won't include the restraint in its evaluated score).
- the number returned by a call to unprotected_evaluate may not be correct as invariants maintained by ScoreStates or Constraints may not be respected. Call evaluate instead.
- in the example below, I'm not quite sure what self.ass is
- since misres is never added to the model, model.evaluate() and minres.evaluate() wouldn't be expected to produce the same answer. Specifically, E_minres should be less than E_ini as it is taking a subset of the scoring terms.
- Also, you probably want to remove the old restraints from the model so that the only score is the minimumrestraint score (eg for r in res: model.remove_restraint(r))

Does that help?

On Apr 13, 2011, at 2:14 AM, Pia Unverdorben wrote:

Dear all,

I have a question concerning the MinimumRestraint Class.

My problem is, that I don't know exactly how to handle it, so that I can use the modified assembly further, in my case for an optimization with the restraints still switched off. When I read in an assembly (model and restraints), evaluate it before and after I applied MinimumRestraints, I obtain the same value. But with MinimumRestraint.unprotected_evaluate it gives back a smaller score.

Here is the specific part (inactivate_pct is the percentage of restraints I want to inactivate):

E_ini=self.ass.evaluate(False)
res=self.ass.restraints.restraint_sets['rigid_bodies'].get_restraints()
l=len(res)
num=int((1-inactivate_pct)*l)
minres=IMP.core.MinimumRestraint(num, res, 'MinimumRestraint')
minres.set_model(self.ass.model)
E_minres=minres.unprotected_evaluate(IMP.DerivativeAccumulator(1.0))
E_end=self.ass.evaluate(False)

So E_ini = E_end > E_minres. How can I access the changed model??

Thanks a lot in advance!

Pia

_______________________________________________
IMP-dev mailing list
IMP-dev@salilab.org
https://salilab.org/mailman/listinfo/imp-dev