Mathematical Definition
Input Domain
The function can be defined on any input domain but it is usually evaluated on x ∈ [−500,500], and y ∈ [−500,500].
Global Minima
The global minima f(x∗) =1 is located at x∗ = (0, 0).
Characteristics
The function is not convex.
The function is defined on 2-dimensional space.
The function is non-separable.
The function is non-differentiable.
Python Implementation
% Please forward any comments or bug reports in chat
Copyright 2021. INDUSMIC PRIVATE LIMITED.THERE IS NO WARRANTY, EXPRESS OR IMPLIED. WE DO NOT ASSUME ANY LIABILITY FOR THE USE OF THIS PROGRAM. If software is modified to produce derivative works, such modified software should be clearly marked. Additionally, user can redistribute it and/or modify it under the terms of the GNU General Public License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. See the GNU General Public License for more details.
% for any support connect with us on help.indusmic@gmail.com
% Author: SHIVANGI CHANDRA DUBEY
#For n=2
#bartelsConn accepts the values of 2 MxM dimension matrices X, Y
#it returns the computation of the matrices in an MxM matrix Z
#the function is then plotted using (X,Y,Z)
#thus giving us a contour plot
from mpl_toolkits import mplot3d
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
def bartelsConn(x,y):
return abs(x**2+y**2+x*y)+abs(np.sin(x))+abs(np.cos(y))
x=np.linspace(-500,500,1000)
y=np.linspace(-500,500,1000)
X,Y=np.meshgrid(x,y)
Z=bartelsConn(X,Y)
def plotFunction(e,a):
fig=plt.figure(figsize=[12,8])
ax=plt.axes(projection='3d')
surf=ax.plot_surface(X,Y,Z,cmap=cm.coolwarm)
ax.view_init(elev=e,azim=a)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('fx')
ax.set_title('Bartels Conn Function')
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
plt.contour(X,Y,Z)
plt.show()
from ipywidgets import interactive
iplot=interactive(plotFunction,
e=(-90,90,5),
a=(-90,90,5))
iplot
References:
[1] Survajonic, Sonja & Bingham, Derek, “Virtual Library of Simulation Experiments”, sfu.ca,
https://www.sfu.ca/~ssurjano/optimization.html
Comments