3434 RiskObjective ,
3535 DiversificationObjective ,
3636)
37- from src .portfolio .metrics import calculate_igd , calculate_spacing
37+ from src .portfolio .metrics import calculate_igd , calculate_spacing , calculate_spread
3838
3939
4040def run_awa_experiment ():
@@ -75,8 +75,8 @@ def run_awa_experiment():
7575 )
7676 ref_front = np .column_stack ([ref_metrics ["Return" ], ref_metrics ["Risk" ]])
7777
78- # ── Experiment 1: Distribution Uniformity (Spacing) ──────────────── ──────
79- print ("Running Experiment 1: Distribution Uniformity ..." )
78+ # ── Experiment 1 & 3 Combined : Distribution and Quality Comparison ──────
79+ print ("Running Quality Comparison (IGD, Spacing, Spread) ..." )
8080 pop_size = NUM_PARETO_POINTS
8181 gens = MOEAD_GENERATIONS
8282
@@ -91,7 +91,12 @@ def run_awa_experiment():
9191 ** data_kwargs ,
9292 )
9393 front1 = np .column_stack ([metrics1 ["Return" ], metrics1 ["Risk" ]])
94- spacing1 = calculate_spacing (front1 )
94+
95+ m_dict1 = {
96+ "IGD" : calculate_igd (front1 , ref_front ),
97+ "Spacing" : calculate_spacing (front1 ),
98+ "Spread" : calculate_spread (front1 , ref_front ),
99+ }
95100
96101 # MOEA/D-AWA
97102 print (" Evaluating MOEA/D-AWA..." )
@@ -105,33 +110,33 @@ def run_awa_experiment():
105110 ** data_kwargs ,
106111 )
107112 front2 = np .column_stack ([metrics2 ["Return" ], metrics2 ["Risk" ]])
108- spacing2 = calculate_spacing (front2 )
109113
110- print (f" Spacing - MOEA/D: { spacing1 :.6f} " )
111- print (f" Spacing - MOEA/D-AWA: { spacing2 :.6f} " )
114+ m_dict2 = {
115+ "IGD" : calculate_igd (front2 , ref_front ),
116+ "Spacing" : calculate_spacing (front2 ),
117+ "Spread" : calculate_spread (front2 , ref_front ),
118+ }
112119
113- # Plot Comparison
114- plt .figure (figsize = (10 , 6 ))
115- plt .scatter (
116- front1 [:, 1 ],
117- front1 [:, 0 ],
118- label = f"Standard MOEA/D (Spacing: { spacing1 :.6f} )" ,
119- alpha = 0.6 ,
120+ print (
121+ f" MOEA/D - IGD: { m_dict1 ['IGD' ]:.6f} , Spacing: { m_dict1 ['Spacing' ]:.6f} , Spread: { m_dict1 ['Spread' ]:.6f} "
120122 )
121- plt .scatter (
122- front2 [:, 1 ],
123- front2 [:, 0 ],
124- label = f"MOEA/D-AWA (Spacing: { spacing2 :.6f} )" ,
125- alpha = 0.6 ,
123+ print (
124+ f" MOEA/D-AWA - IGD: { m_dict2 ['IGD' ]:.6f} , Spacing: { m_dict2 ['Spacing' ]:.6f} , Spread: { m_dict2 ['Spread' ]:.6f} "
126125 )
127- plt .xlabel ("Risk (Standard Deviation)" )
128- plt .ylabel ("Return" )
129- plt .title ("Experiment 1: Pareto Front Distribution Quality" )
130- plt .legend ()
131- plt .grid (True )
132- plt .savefig (os .path .join (run_folder , "exp1_uniformity.png" ))
133- plt .close ()
134126
127+ # Plot Comparison (Consolidated)
128+ from src .visualization import plot_two_variants_comparison_2d
129+
130+ plot_two_variants_comparison_2d (
131+ ref_metrics ,
132+ metrics1 ,
133+ metrics2 ,
134+ name1 = "Standard MOEA/D" ,
135+ name2 = "MOEA/D-AWA" ,
136+ metrics_dict1 = m_dict1 ,
137+ metrics_dict2 = m_dict2 ,
138+ save_path = os .path .join (run_folder , "awa_comparison_2d.png" ),
139+ )
135140 # ── Experiment 2: Performance vs Generations (Adaptive Progress) ──────────
136141 print ("Running Experiment 2: Convergence Progress..." )
137142 # Compare IGD history
@@ -160,29 +165,16 @@ def run_awa_experiment():
160165 gens_list = np .arange (0 , gens + 1 , 20 )
161166
162167 plt .figure (figsize = (10 , 6 ))
163- plt .plot (gens_list , igd1 , "o-" , label = "Standard MOEA/D" )
164- plt .plot (gens_list , igd2 , "s-" , label = "MOEA/D-AWA" )
168+ plt .plot (gens_list , igd1 , "o-" , label = "Standard MOEA/D" , color = "#1f77b4" )
169+ plt .plot (gens_list , igd2 , "s-" , label = "MOEA/D-AWA" , color = "#ff7f0e" )
165170 plt .xlabel ("Generations" )
166171 plt .ylabel ("IGD" )
167- plt .title ("Experiment 2: Convergence Progress with Weight Adaptation" )
172+ plt .title ("Convergence Progress with Weight Adaptation" , fontsize = 14 )
168173 plt .legend ()
169- plt .grid (True )
170- plt .savefig (os .path .join (run_folder , "exp2_convergence .png" ))
174+ plt .grid (True , linestyle = "--" , alpha = 0.6 )
175+ plt .savefig (os .path .join (run_folder , "awa_convergence_progress .png" ), dpi = 150 )
171176 plt .close ()
172177
173- # ── Experiment 3: 2D Pareto Comparison ──────────────────────────────────
174- print ("Running Experiment 3: 2D Pareto Comparison..." )
175- from src .visualization import plot_two_variants_comparison_2d
176-
177- plot_two_variants_comparison_2d (
178- ref_metrics ,
179- metrics1 ,
180- metrics2 ,
181- name1 = "Standard MOEA/D" ,
182- name2 = "MOEA/D-AWA" ,
183- save_path = os .path .join (run_folder , "exp3_2d_comparison.png" ),
184- )
185-
186178 # ── Experiment 4: 3D Pareto Comparison ──────────────────────────────────
187179 print ("Running Experiment 4: 3D Pareto Comparison..." )
188180 prob_3d = PortfolioProblem (
0 commit comments