1 """Interface between XML Representation and IMP Model."""
9 class Optimization(object):
12 self._children = list()
14 def run(self, restraint, log):
15 for child
in self._children:
16 child.run(restraint, log)
19 class _OptimizationNode(object):
21 def __init__(self, attributes, text):
22 id = attributes.get(
'id')
26 self.id =
'object_%d' % _OptimizationNode.counter
27 _OptimizationNode.counter += 1
28 self._children = list()
31 class _OptimizationConjugateGradients(_OptimizationNode):
32 def __init__(self, attributes, text):
33 _OptimizationNode.__init__(self, attributes, text)
34 self.threshold = float(attributes.get(
'threshold', 0))
35 self.steps = int(attributes.get(
'steps', 1))
37 def run(self, restraint, log):
39 restraint.set_include(include=
True)
40 for child
in self._children:
41 child.run(restraint, log)
42 restraint.add_to_model()
44 o.set_model(restraint._model)
46 o.add_optimizer_state(log)
47 o.optimize(self.steps)
51 class _OptimizationRestraint(_OptimizationNode):
52 def __init__(self, attributes, text):
53 _OptimizationNode.__init__(self, attributes, text)
54 self.name = attributes[
'name']
55 self.weight = float(attributes.get(
'weight', 1.0))
57 def run(self, restraint, log):
58 restraint.set_include(name=self.name, include=
True,