1212# matplotlib plot of particle location
1313#
1414# Author(s): Lauren Linkous, Jonathan Lundquist
15- # Last update:June 14 , 2024
15+ # Last update:August 18 , 2024
1616##--------------------------------------------------------------------\
1717
1818
2727#import lundquist_3_var.configs_F as func_configs # multi objective function
2828
2929
30-
3130class TestGraph ():
3231def __init__ (self ):
3332
@@ -40,7 +39,6 @@ def __init__(self):
4039# 3 = absorbing, 4 = invisible
4140
4241
43-
4442# Objective function dependent variables
4543LB = func_configs .LB # Lower boundaries, [[0.21, 0, 0.1]]
4644UB = func_configs .UB # Upper boundaries, [[1, 1, 0.5]]
@@ -52,8 +50,7 @@ def __init__(self):
5250func_F = func_configs .OBJECTIVE_FUNC # objective function
5351constr_F = func_configs .CONSTR_FUNC # constraint function
5452
55-
56-
53+
5754# chicken swarm specific
5855RN = 10 # Total number of roosters
5956HN = 20 # Total number of hens
@@ -62,15 +59,6 @@ def __init__(self):
6259G = 70 # Reorganize groups every G steps
6360NO_OF_PARTICLES = RN + HN + MN + CN # Number of particles in swarm
6461
65- # swarm setup
66- parent = self # Optional parent class for swarm
67- # (Used for passing debug messages or
68- # other information that will appear
69- # in GUI panels)
70-
71- detailedWarnings = False # Optional boolean for detailed feedback
72-
73-
7462# Swarm vars
7563self .best_eval = 1 # Starting eval value
7664
@@ -89,7 +77,6 @@ def __init__(self):
8977
9078
9179
92-
9380self .mySwarm = swarm (NO_OF_PARTICLES ,LB ,UB ,
9481OUT_VARS ,TARGETS ,
9582E_TOL ,MAXIT ,BOUNDARY ,func_F ,constr_F ,
@@ -103,16 +90,16 @@ def __init__(self):
10390# position
10491self .ax1 = self .fig .add_subplot (121 ,projection = '3d' )
10592self .ax1 .set_title ("Particle Location, Iteration: " + str (self .ctr ))
106- self .ax1 .set_xlabel ('X ' )
107- self .ax1 .set_ylabel ('Y ' )
108- self .ax1 .set_zlabel ('Z ' )
93+ self .ax1 .set_xlabel ('x_1 ' )
94+ self .ax1 .set_ylabel ('x_2 ' )
95+ self .ax1 .set_zlabel ('x_3 ' )
10996self .scatter1 = None
11097# fitness
11198self .ax2 = self .fig .add_subplot (122 ,projection = '3d' )
11299self .ax2 .set_title ("Fitness Relation to Target" )
113- self .ax2 .set_xlabel ('X ' )
114- self .ax2 .set_ylabel ('Y ' )
115- self .ax2 .set_zlabel ('Z ' )
100+ self .ax2 .set_xlabel ('x_1 ' )
101+ self .ax2 .set_ylabel ('x_2 ' )
102+ self .ax2 .set_zlabel ('x_3 ' )
116103self .scatter2 = None
117104
118105def debug_message_printout (self ,txt ):
@@ -124,12 +111,6 @@ def debug_message_printout(self, txt):
124111print (msg )
125112
126113
127- def record_params (self ):
128- # this function is called from particle_swarm.py to trigger a write to a log file
129- # running in the AntennaCAT GUI to record the parameter iteration that caused an error
130- pass
131-
132-
133114def update_plot (self ,x_coords ,y_coords ,targets ,showTarget = True ,clearAx = True ):
134115
135116# check if any points. first call might not have anythign set yet.
@@ -147,12 +128,14 @@ def update_plot(self, x_coords, y_coords, targets, showTarget=True, clearAx=True
147128self .ax1 .set_title ("Search Locations, Iteration: " + str (self .ctr ))
148129self .ax1 .set_xlabel ("$x_1$" )
149130self .ax1 .set_ylabel ("filler coords" )
131+ self .ax1 .set_zlabel ("filler coords" )
150132self .scatter = self .ax1 .scatter (x_coords ,x_plot_coords ,edgecolors = 'b' )
151133
152134elif np .shape (x_coords )[1 ]== 2 :#2-dim func
153135self .ax1 .set_title ("Search Locations, Iteration: " + str (self .ctr ))
154136self .ax1 .set_xlabel ("$x_1$" )
155137self .ax1 .set_ylabel ("$x_2$" )
138+ self .ax1 .set_zlabel ("filler coords" )
156139self .scatter = self .ax1 .scatter (x_coords [:,0 ],x_coords [:,1 ],edgecolors = 'b' )
157140
158141elif np .shape (x_coords )[1 ]== 3 :#3-dim func
@@ -167,21 +150,23 @@ def update_plot(self, x_coords, y_coords, targets, showTarget=True, clearAx=True
167150if np .shape (y_coords )[1 ]== 1 :#1-dim obj func
168151y_plot_filler = np .array (y_coords [:,0 ])* 0.0
169152self .ax2 .set_title ("Global Best Fitness Relation to Target" )
170- self .ax2 .set_xlabel ("$F_{1}(x,y )$" )
153+ self .ax2 .set_xlabel ("$F_{1}(x_1,x_2 )$" )
171154self .ax2 .set_ylabel ("filler coords" )
155+ self .ax2 .set_zlabel ("filler coords" )
172156self .scatter = self .ax2 .scatter (y_coords ,y_plot_filler ,marker = 'o' ,s = 40 ,facecolor = "none" ,edgecolors = "k" )
173157
174158elif np .shape (y_coords )[1 ]== 2 :#2-dim obj func
175159self .ax2 .set_title ("Global Best Fitness Relation to Target" )
176- self .ax2 .set_xlabel ("$F_{1}(x,y)$" )
177- self .ax2 .set_ylabel ("$F_{2}(x,y)$" )
160+ self .ax2 .set_xlabel ("$F_{1}(x_1,x_2)$" )
161+ self .ax2 .set_ylabel ("$F_{2}(x_1,x_2)$" )
162+ self .ax2 .set_zlabel ("filler coords" )
178163self .scatter = self .ax2 .scatter (y_coords [:,0 ],y_coords [:,1 ],marker = 'o' ,s = 40 ,facecolor = "none" ,edgecolors = "k" )
179164
180165elif np .shape (y_coords )[1 ]== 3 :#3-dim obj fun
181166self .ax2 .set_title ("Global Best Fitness Relation to Target" )
182- self .ax2 .set_xlabel ("$F_{1}(x,y )$" )
183- self .ax2 .set_ylabel ("$F_{2}(x,y )$" )
184- self .ax2 .set_zlabel ("$F_{3}(x,y )$" )
167+ self .ax2 .set_xlabel ("$F_{1}(x_1,x_2 )$" )
168+ self .ax2 .set_ylabel ("$F_{2}(x_1,x_2 )$" )
169+ self .ax2 .set_zlabel ("$F_{3}(x_1,x_2 )$" )
185170self .scatter = self .ax2 .scatter (y_coords [:,0 ],y_coords [:,1 ],y_coords [:,2 ],marker = 'o' ,s = 40 ,facecolor = "none" ,edgecolors = "k" )
186171
187172