# Copyright (c) 1997-2016 California Institute of Technology. # Copyright (c) 2016-2017 The Uncertainty Quantification Foundation. # License: 3-clause BSD. The full license text is available at: # - http://trac.mystic.cacr.caltech.edu/project/mystic/browser/mystic/LICENSE from g01 import objective, bounds, xs, ys from g01_alt import penalty1, penalty2, penalty3, penalty4, penalty5, \ penalty6, penalty7, penalty8, penalty9 from mystic.constraints import as_constraint, combined from mystic.penalty import linear_inequality penalties = (penalty1,penalty2,penalty3,penalty4,penalty5,\ penalty6,penalty7,penalty8,penalty9) penalty = combined(*[linear_inequality(pi)(lambda x: 0.) for pi in penalties]) solver = as_constraint(penalty) if __name__ == '__main__': x = [0] * len(xs) from mystic.solvers import fmin_powell, diffev from mystic.math import almostEqual result = fmin_powell(objective, x0=x, bounds=bounds, penalty=penalty, disp=False, full_output=True)
# Copyright (c) 1997-2016 California Institute of Technology. # Copyright (c) 2016-2017 The Uncertainty Quantification Foundation. # License: 3-clause BSD. The full license text is available at: # - http://trac.mystic.cacr.caltech.edu/project/mystic/browser/mystic/LICENSE from g01 import objective, bounds, xs, ys from g01_alt import penalty1, penalty2, penalty3, penalty4, penalty5, \ penalty6, penalty7, penalty8, penalty9 from mystic.constraints import as_constraint, combined from mystic.penalty import linear_inequality penalties = (penalty1,penalty2,penalty3,penalty4,penalty5,\ penalty6,penalty7,penalty8,penalty9) penalty = combined(*[linear_inequality(pi)(lambda x:0.) for pi in penalties]) solver = as_constraint(penalty) if __name__ == '__main__': x = [0]*len(xs) from mystic.solvers import fmin_powell, diffev from mystic.math import almostEqual result = fmin_powell(objective, x0=x, bounds=bounds, penalty=penalty, disp=False, full_output=True) assert almostEqual(result[0], xs, tol=1e-2) assert almostEqual(result[1], ys, tol=1e-2)