File: TEST_ffitPP2.py

package info (click to toggle)
mystic 0.4.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,656 kB
  • sloc: python: 40,894; makefile: 33; sh: 9
file content (50 lines) | stat: -rwxr-xr-x 1,458 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 1997-2016 California Institute of Technology.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD.  The full license text is available at:
#  - https://github.com/uqfoundation/mystic/blob/master/LICENSE
"""
Testing the polynomial fitting problem of [1] using scipy's Nelder-Mead algorithm.

Reference:

[1] Storn, R. and Price, K. Differential Evolution - A Simple and Efficient
Heuristic for Global Optimization over Continuous Spaces. Journal of Global
Optimization 11: 341-359, 1997.
"""

from test_ffit import Chebyshev8, ChebyshevCost, plot_solution, print_solution

if __name__ == '__main__':
    import random
    from mystic.solvers import fmin
   #from mystic._scipyoptimize import fmin
    from mystic.tools import random_seed
    random_seed(123)

    import pp
    import sys

    if len(sys.argv) > 1:
        tunnelport = sys.argv[1]
        ppservers = ("localhost:%s" % tunnelport,)
    else:
        ppservers = ()

    myserver = pp.Server(ppservers=ppservers)

    trials = []
    for trial in range(8):
        x = tuple([random.uniform(-100,100) + Chebyshev8[i] for i in range(9)])
        trials.append(x)

    results = [myserver.submit(fmin,(ChebyshevCost,x),(),()) for x in trials]

    for solution in results:
        print_solution(solution())

   #plot_solution(solution)

# end of file