Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import ipdb;
- import numpy as np
- from my_optimization import *
- def tb_simple(x):
- f = np.sum(np.abs(x[1:]))+x[0]
- return f
- # OPTIMIZATION
- size_x = 3
- bound_i = (-5.12,5.12)
- bounds = []
- for i in range (0, size_x):
- bounds.append(bound_i)
- x0 = 5*np.ones(size_x)
- maxiter = 2000
- step = 0.1
- args = []
- res = my_hillclimbing(tb_simple, x0, bounds, maxiter, step, args)
- print("Final x: [",)
- print("%f" % res.x[0],)
- for i in range(1,len(res.x)):
- print(", %f" % res.x[i],)
- print("]\n",)
- #print res.x
- print("Final cost: %f \n" % res.cost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement