示例#1
0
    def __init__(self, options, tgt_opts, forcefield):

        super(Objective, self).__init__(options)
        self.set_option(options, 'penalty_type')
        self.set_option(options, 'penalty_additive')
        self.set_option(options, 'penalty_multiplicative')
        self.set_option(options, 'penalty_hyperbolic_b')
        self.set_option(options, 'penalty_alpha')
        self.set_option(options, 'normalize_weights')
        ## Work Queue Port (The specific target itself may or may not actually use this.)
        self.set_option(options, 'wq_port')
        ## Asynchronous objective function evaluation (i.e. execute Work Queue and local objective concurrently.)
        self.set_option(options, 'asynchronous')

        ## The list of fitting targets
        self.Targets = []
        for opts in tgt_opts:
            if opts['type'] not in Implemented_Targets:
                logger.error(
                    'The target type \x1b[1;91m%s\x1b[0m is not implemented!\n'
                    % opts['type'])
                raise RuntimeError
            if opts["remote"]:
                Tgt = forcebalance.target.RemoteTarget(options, opts,
                                                       forcefield)
            else:
                Tgt = Implemented_Targets[opts['type']](options, opts,
                                                        forcefield)
            self.Targets.append(Tgt)
            printcool_dictionary(Tgt.PrintOptionDict,
                                 "Setup for target %s :" % Tgt.name)
        if len(set([Tgt.name for Tgt in self.Targets])) != len(
            [Tgt.name for Tgt in self.Targets]):
            logger.error("The list of target names is not unique!\n")
            raise RuntimeError
        ## The force field (it seems to be everywhere)
        self.FF = forcefield
        ## Initialize the penalty function.
        self.Penalty = Penalty(self.penalty_type, forcefield,
                               self.penalty_additive,
                               self.penalty_multiplicative,
                               self.penalty_hyperbolic_b, self.penalty_alpha)
        ## Obtain the denominator.
        if self.normalize_weights:
            self.WTot = np.sum([i.weight for i in self.Targets])
        else:
            self.WTot = 1.0
        self.ObjDict = OrderedDict()
        self.ObjDict_Last = OrderedDict()

        # Create the work queue here.
        if self.wq_port != 0:
            createWorkQueue(self.wq_port)
            logger.info('Work Queue is listening on %d\n' % self.wq_port)

        printcool_dictionary(self.PrintOptionDict,
                             "Setup for objective function :")
示例#2
0
    def __init__(self, options, tgt_opts, forcefield):

        super(Objective, self).__init__(options)
        self.set_option(options, 'penalty_type')
        self.set_option(options, 'penalty_additive')
        self.set_option(options, 'penalty_multiplicative')
        self.set_option(options, 'penalty_hyperbolic_b')
        self.set_option(options, 'penalty_alpha')
        self.set_option(options, 'penalty_power')
        self.set_option(options, 'normalize_weights')
        ## Work Queue Port (The specific target itself may or may not actually use this.)
        self.set_option(options, 'wq_port')
        ## Asynchronous objective function evaluation (i.e. execute Work Queue and local objective concurrently.)
        self.set_option(options, 'asynchronous')

        ## The list of fitting targets
        self.Targets = []
        for opts in tgt_opts:
            if opts['type'] not in Implemented_Targets:
                logger.error('The target type \x1b[1;91m%s\x1b[0m is not implemented!\n' % opts['type'])
                raise RuntimeError
            # Create a target object.  This is done by looking up the
            # Target class from the Implemented_Targets dictionary
            # using opts['type'] as the key.  The object is created by
            # passing (options, opts, forcefield) to the constructor.
            if opts["remote"] and self.wq_port != 0: Tgt = forcebalance.target.RemoteTarget(options, opts, forcefield)
            else: Tgt = Implemented_Targets[opts['type']](options,opts,forcefield)
            self.Targets.append(Tgt)
            printcool_dictionary(Tgt.PrintOptionDict,"Setup for target %s :" % Tgt.name)
        if len(set([Tgt.name for Tgt in self.Targets])) != len([Tgt.name for Tgt in self.Targets]):
            logger.error("The list of target names is not unique!\n")
            raise RuntimeError
        ## The force field (it seems to be everywhere)
        self.FF = forcefield
        ## Initialize the penalty function.
        self.Penalty = Penalty(self.penalty_type,forcefield,self.penalty_additive,
                               self.penalty_multiplicative,self.penalty_hyperbolic_b,
                               self.penalty_alpha,self.penalty_power)
        ## Obtain the denominator.
        if self.normalize_weights:
            self.WTot = np.sum([i.weight for i in self.Targets])
        else:
            self.WTot = 1.0
        self.ObjDict = OrderedDict()
        self.ObjDict_Last = OrderedDict()

        # Create the work queue here.
        if self.wq_port != 0:
            createWorkQueue(self.wq_port)
            logger.info('Work Queue is listening on %d\n' % self.wq_port)

        printcool_dictionary(self.PrintOptionDict, "Setup for objective function :")
示例#3
0
    def __init__(self, options, tgt_opts, forcefield):

        super(Objective, self).__init__(options)
        self.set_option(options, 'penalty_type')
        self.set_option(options, 'penalty_additive')
        self.set_option(options, 'penalty_multiplicative')
        self.set_option(options, 'penalty_hyperbolic_b')
        self.set_option(options, 'penalty_alpha')
        self.set_option(options, 'normalize_weights')
        ## Work Queue Port (The specific target itself may or may not actually use this.)
        self.set_option(options, 'wq_port')
        ## Asynchronous objective function evaluation (i.e. execute Work Queue and local objective concurrently.)
        self.set_option(options, 'asynchronous')

        ## The list of fitting targets
        self.Targets = []
        for opts in tgt_opts:
            if opts['type'] not in Implemented_Targets:
                raise RuntimeError('The target type \x1b[1;91m%s\x1b[0m is not implemented!' % opts['type'])
            Tgt = Implemented_Targets[opts['type']](options,opts,forcefield)
            self.Targets.append(Tgt)
            printcool_dictionary(Tgt.PrintOptionDict,"Setup for target %s :" % Tgt.name)
        if len(set([Tgt.name for Tgt in self.Targets])) != len([Tgt.name for Tgt in self.Targets]):
            raise Exception("The list of target names is not unique!")
        ## The force field (it seems to be everywhere)
        self.FF = forcefield
        ## Initialize the penalty function.
        self.Penalty = Penalty(options['penalty_type'],forcefield,options['penalty_additive'],
                               options['penalty_multiplicative'],options['penalty_hyperbolic_b'],
                               options['penalty_alpha'])
        ## Obtain the denominator.
        if self.normalize_weights:
            self.WTot = sum([i.weight for i in self.Targets])
        else:
            self.WTot = 1.0
        self.ObjDict = OrderedDict()
        self.ObjDict_Last = OrderedDict()

        # Create the work queue here.
        if self.wq_port != 0:
            createWorkQueue(self.wq_port)
            print('Work Queue is listening on %d' % self.wq_port)

        printcool_dictionary(self.PrintOptionDict, "Setup for objective function :")
示例#4
0
    def __init__(self, options, tgt_opts, forcefield):

        super(Objective, self).__init__(options)
        self.set_option(options, 'penalty_type')
        self.set_option(options, 'penalty_additive')
        self.set_option(options, 'penalty_multiplicative')
        self.set_option(options, 'penalty_hyperbolic_b')
        self.set_option(options, 'penalty_alpha')
        self.set_option(options, 'penalty_power')
        self.set_option(options, 'normalize_weights')
        ## Work Queue Port (The specific target itself may or may not actually use this.)
        self.set_option(options, 'wq_port')
        ## Asynchronous objective function evaluation (i.e. execute Work Queue and local objective concurrently.)
        self.set_option(options, 'asynchronous')

        ## The list of fitting targets
        self.Targets = []
        enable_smirnoff_prints = False  # extra prints for SMIRNOFF forcefield
        for opts in tgt_opts:
            if opts['type'] not in Implemented_Targets:
                logger.error(
                    'The target type \x1b[1;91m%s\x1b[0m is not implemented!\n'
                    % opts['type'])
                raise RuntimeError
            elif opts['type'].endswith("SMIRNOFF"):
                enable_smirnoff_prints = True
            # Create a target object.  This is done by looking up the
            # Target class from the Implemented_Targets dictionary
            # using opts['type'] as the key.  The object is created by
            # passing (options, opts, forcefield) to the constructor.
            if opts["remote"] and self.wq_port != 0:
                Tgt = forcebalance.target.RemoteTarget(options, opts,
                                                       forcefield)
            else:
                Tgt = Implemented_Targets[opts['type']](options, opts,
                                                        forcefield)
            self.Targets.append(Tgt)
            printcool_dictionary(Tgt.PrintOptionDict,
                                 "Setup for target %s :" % Tgt.name)
        if len(set([Tgt.name for Tgt in self.Targets])) != len(
            [Tgt.name for Tgt in self.Targets]):
            logger.error("The list of target names is not unique!\n")
            raise RuntimeError
        if enable_smirnoff_prints:
            smirnoff_analyze_parameter_coverage(forcefield, tgt_opts)
        ## The force field (it seems to be everywhere)
        self.FF = forcefield
        ## Initialize the penalty function.
        self.Penalty = Penalty(self.penalty_type, forcefield,
                               self.penalty_additive,
                               self.penalty_multiplicative,
                               self.penalty_hyperbolic_b, self.penalty_alpha,
                               self.penalty_power)
        ## Obtain the denominator.
        if self.normalize_weights:
            self.WTot = np.sum([i.weight for i in self.Targets])
        else:
            self.WTot = 1.0
        self.ObjDict = OrderedDict()
        self.ObjDict_Last = OrderedDict()

        # Create the work queue here.
        if self.wq_port != 0:
            createWorkQueue(self.wq_port)
            logger.info('Work Queue is listening on %d\n' % self.wq_port)

        printcool_dictionary(self.PrintOptionDict,
                             "Setup for objective function :")