示例#1
0
__email__ = "*****@*****.**"

if __name__ == "__main__":
    g = nx.random_geometric_graph(1, 1)
    model = Model(g)

    constants = {'x1': 0, 'x2': 0, 'x3': 0}

    initial_state = {'ishigami': 0}

    def update(constants):
        ishigami_params = np.array([list(constants.values())])
        return {'ishigami': Ishigami.evaluate(ishigami_params)}

    # Model definition
    model.constants = constants
    model.set_states(['ishigami'])
    model.add_update(update, {'constants': model.constants})

    cfg = SAConfiguration({
        'bounds': {
            'x1': (-3.14159265359, 3.14159265359),
            'x2': (-3.14159265359, 3.14159265359),
            'x3': (-3.14159265359, 3.14159265359)
        },
        'iterations': 1,
        'initial_state': initial_state,
        'initial_args': {
            'constants': model.constants
        },
        'n': 1024,
示例#2
0
 def test_model_constants(self):
     g = nx.random_geometric_graph(10, 0.1)
     m = Model(g)
     d = {1: 2}
     m.constants = d
     self.assertEqual(m.constants, d)