Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get minimum value function with anealing in python

import math

def noisy_func(X):
    x, y = X
    return (math.exp(math.sin(50*x)) +
            math.sin(60*math.exp(y)) +
            math.sin(70*math.sin(x)) +
            math.sin(math.sin(80*y)) -
            math.sin(10*(x + y)) +
            0.25*(math.pow(x, 2) +
            math.pow(y, 2)))


import frigidum
import numpy as np
import random

def random_start():
    return np.random.random( 2 ) * 4

def random_small_step(x):
    if np.random.random() < .5:
        return np.clip( x + np.array( [0, 0.02 * (random.random() - .5)] ), -4,4)
    else:
        return np.clip( x + np.array( [0.02 * (random.random() - .5), 0] ), -4,4)


def random_big_step(x):
    if np.random.random() < .5:
        return np.clip( x + np.array( [0, 0.5 * (random.random() - .5)] ), -4,4)
    else:
        return np.clip( x + np.array( [0.5 * (random.random() - .5), 0] ), -4,4)

local_opt = frigidum.sa(random_start=random_start, 
                        neighbours=[random_small_step, random_big_step], 
                        objective_function=noisy_func, 
                        T_start=10**2, 
                        T_stop=0.00001, 
                        repeats=10**4, 
                        copy_state=frigidum.annealing.copy)
Comment

PREVIOUS NEXT
Code Example
Python :: brython sample 
Python :: python text file contains 
Python :: python request port 
Python :: python dictionary examples 
Python :: smile detection 
Python :: Python NumPy asfortranarray Function Tuple to an array 
Python :: Python NumPy require Function Example without requirements attribute 
Python :: Python NumPy dstack Function Example 02 
Python :: inverrt heatmap cmap 
Python :: Python NumPy repeat Function Example Working with 1D array 
Python :: unsupported operand type python 
Python :: python __div__ 
Python :: find max in for scartch python 
Python :: function nbYear(p0, percent, aug, p) { let n = 0; while(p0 < p) { p0 = p0 + Math.round(p0 * (percent/100)) + aug; n ++; } return n; } 
Python :: how to increment date in python 
Python :: NumPy binary_repr Syntax 
Python :: python code to scan paper table to excel 
Python :: Python matplotlib multiple bars 
Python :: xampp python 
Python :: list python !g 
Python :: How to convert an XML file to nice pandas dataframe 
Python :: store dataframes 
Python :: python relative seek 
Python :: django insert data into database without form 
Python :: Determining the Data Type 
Python :: EDA dataframe missing and zero values 
Python :: ring For in Loop 
Python :: can you make a class in a class python 
Python :: Python loop aray 
Python :: OfficeApi 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =