InΒ [Β ]:
InΒ [1]:
import numpy as np
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
import seaborn as sns
import string
import os
import warnings
from collections import defaultdict
INDEX=80
# Suppress warnings for cleaner output
warnings.filterwarnings('ignore', category=DeprecationWarning)
warnings.filterwarnings('ignore', category=UserWarning)
# Set matplotlib style for better plots
plt.style.use('seaborn-v0_8-darkgrid')
sns.set_palette("husl")
"""
================================================================================
BEE COLONY OPTIMIZATION (BCO) FOR MST PROBLEM
================================================================================
PERBEDAAN UTAMA BCO vs ACO:
ACO (Ant Colony Optimization):
- Ants: ALL construct solutions independently
- Pheromone: Updated AFTER all ants finish
- Communication: INDIRECT (via pheromone trails)
- Selection: Probabilistic based on pheromone + heuristic
BCO (Bee Colony Optimization):
- Bees: THREE types with different roles
1. SCOUT BEES: Explore random solutions
2. EMPLOYED BEES: Exploit known good solutions
3. ONLOOKER BEES: Choose best solutions to refine
- Communication: DIRECT (waggle dance - sharing solutions)
- Selection: Tournament selection + probabilistic
- Memory: Best solutions stored in "hive memory"
KEY DIFFERENCES:
1. **ROLE DIFFERENTIATION**: BCO has scout/employed/onlooker roles
2. **WAGGLE DANCE**: Bees share solution quality directly
3. **ABANDONMENT**: Poor solutions abandoned after limit tries
4. **NEIGHBORHOOD SEARCH**: Local search around good solutions
"""
# ==================== HELPER FUNCTIONS ====================
def generate_two_letter_labels(n):
labels = []
for i in range(n):
first = i // 26
second = i % 26
label = string.ascii_uppercase[first] + string.ascii_uppercase[second]
labels.append(label)
return labels
# ==================== KRUSKAL ALGORITHM ====================
class UnionFind:
def __init__(self, n):
self.parent = list(range(n))
self.rank = [0] * n
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def union(self, x, y):
px, py = self.find(x), self.find(y)
if px == py:
return False
if self.rank[px] < self.rank[py]:
px, py = py, px
self.parent[py] = px
if self.rank[px] == self.rank[py]:
self.rank[px] += 1
return True
def kruskal_mst(dist_matrix):
n = len(dist_matrix)
edges = []
for i in range(n):
for j in range(i+1, n):
edges.append((dist_matrix[i][j], i, j))
edges.sort()
uf = UnionFind(n)
mst_edges = []
total_weight = 0
for weight, u, v in edges:
if uf.union(u, v):
mst_edges.append((u, v))
total_weight += weight
if len(mst_edges) == n - 1:
break
return total_weight, mst_edges
# ==================== BCO BASE CLASS ====================
class BCO:
"""
Bee Colony Optimization Base Class
**KEY BCO CONCEPTS:**
1. **FOOD SOURCES** = Solutions (MST/TSP paths)
2. **NECTAR AMOUNT** = Solution quality (1/cost)
3. **EMPLOYED BEES** = Exploit current food sources
4. **ONLOOKER BEES** = Select best food sources probabilistically
5. **SCOUT BEES** = Explore new random solutions
6. **WAGGLE DANCE** = Share solution quality with hive
7. **ABANDONMENT** = Discard poor solutions after limit tries
"""
def __init__(self, dist_matrix, n_employed=5, n_onlooker=5, n_iterations=100,
abandonment_limit=10):
self.dist_matrix = dist_matrix
self.n_nodes = len(dist_matrix)
# **BCO SPECIFIC PARAMETERS**
self.n_employed = n_employed # Employed bees (exploit)
self.n_onlooker = n_onlooker # Onlooker bees (selective exploit)
self.n_bees = n_employed + n_onlooker # Total colony size
self.n_iterations = n_iterations
self.abandonment_limit = abandonment_limit # Max tries before abandon
# **HIVE MEMORY** - Store food sources (solutions)
self.food_sources = [] # List of (solution, cost, trial_count)
self.best_solution = None
self.best_cost = float('inf')
def _calculate_fitness(self, cost):
"""
**FITNESS CALCULATION (BCO SPECIFIC)**
Fitness = nectar amount = quality of food source
Higher fitness = better solution
"""
if cost > 0:
return 1.0 / (1.0 + cost) # Normalize to [0, 1]
else:
return 1.0
def _calculate_selection_probabilities(self):
"""
**WAGGLE DANCE MECHANISM**
Bees perform waggle dance to communicate food source quality
Probability β fitness (nectar amount)
Better solutions have higher probability to be selected by onlookers
"""
fitnesses = [self._calculate_fitness(cost) for _, cost, _ in self.food_sources]
total_fitness = sum(fitnesses)
if total_fitness > 0:
probabilities = [f / total_fitness for f in fitnesses]
else:
probabilities = [1.0 / len(fitnesses)] * len(fitnesses)
return probabilities
def _select_food_source(self, probabilities):
"""
**ONLOOKER BEE SELECTION**
Select food source based on waggle dance probabilities
"""
return np.random.choice(len(self.food_sources), p=probabilities)
def _neighborhood_search(self, solution, cost, max_degree=None):
"""
**LOCAL SEARCH (BCO SPECIFIC)**
Employed/Onlooker bees perform local search around current solution
This is KEY DIFFERENCE from ACO:
- ACO: Only pheromone-based global search
- BCO: Local neighborhood search + global exploration
"""
# This will be implemented in subclasses
return solution, cost
def _update_best(self, solution, cost):
"""Update global best solution"""
if cost < self.best_cost:
self.best_cost = cost
self.best_solution = solution
# ==================== BCO TSP PATH ====================
class BCO_TSP_Path(BCO):
"""
BCO for TSP Hamiltonian Path (no cycle - FAIR comparison with MST)
"""
def construct_solution(self, max_degree=None):
"""
**SCOUT BEE: Random exploration**
Construct a new TSP path solution
"""
start = np.random.randint(self.n_nodes)
tour = [start]
unvisited = list(range(self.n_nodes))
unvisited.remove(start)
degrees = defaultdict(int) if max_degree else None
if max_degree:
degrees[start] = 0
while unvisited:
current = tour[-1]
# Get valid candidates
candidates = []
for node in unvisited:
if max_degree is None or degrees[node] < max_degree:
candidates.append(node)
if not candidates:
return None, float('inf')
# **GREEDY + RANDOM** selection (BCO style)
# Combine greedy heuristic with randomness
costs = [self.dist_matrix[current][node] for node in candidates]
# Probability inversely proportional to distance
if max(costs) > 0:
probs = [1.0 / (c + 1e-10) for c in costs]
probs = np.array(probs)
probs = probs / probs.sum()
else:
probs = np.ones(len(candidates)) / len(candidates)
next_node = np.random.choice(candidates, p=probs)
tour.append(next_node)
unvisited.remove(next_node)
if max_degree:
degrees[current] += 1
degrees[next_node] += 1
# No cycle (PATH)
edges = [(tour[i], tour[i+1]) for i in range(len(tour)-1)]
cost = sum(self.dist_matrix[i][j] for i, j in edges)
return edges, cost
def _neighborhood_search(self, solution, cost, max_degree=None):
"""
**LOCAL SEARCH: 2-opt for TSP Path**
Employed/Onlooker bees improve solution by local moves
"""
if solution is None:
return solution, cost
# Reconstruct tour from edges
tour = [solution[0][0]]
for i, j in solution:
if tour[-1] == i:
tour.append(j)
else:
tour.append(i)
improved = False
best_tour = tour[:]
best_cost = cost
# Try 2-opt moves
for _ in range(3): # Limited attempts
i = np.random.randint(1, len(tour) - 2)
j = np.random.randint(i + 1, len(tour) - 1)
# Reverse segment
new_tour = tour[:i] + tour[i:j+1][::-1] + tour[j+1:]
# Check degree constraint
if max_degree:
degrees = defaultdict(int)
for k in range(len(new_tour) - 1):
degrees[new_tour[k]] += 1
degrees[new_tour[k+1]] += 1
if any(d > max_degree for d in degrees.values()):
continue
# Calculate new cost
new_edges = [(new_tour[k], new_tour[k+1]) for k in range(len(new_tour)-1)]
new_cost = sum(self.dist_matrix[i][j] for i, j in new_edges)
if new_cost < best_cost:
best_tour = new_tour
best_cost = new_cost
improved = True
if improved:
best_edges = [(best_tour[i], best_tour[i+1]) for i in range(len(best_tour)-1)]
return best_edges, best_cost
return solution, cost
def run(self, max_degree=None):
"""
**BCO MAIN ALGORITHM**
PHASE 1: INITIALIZATION
- Generate initial food sources (solutions) with scout bees
PHASE 2: EMPLOYED BEE PHASE
- Each employed bee exploits its food source
- Perform local search around current solution
- Update food source if improved
PHASE 3: WAGGLE DANCE
- Calculate fitness of all food sources
- Compute selection probabilities
PHASE 4: ONLOOKER BEE PHASE
- Onlookers select food sources based on probabilities
- Perform local search on selected sources
- Update if improved
PHASE 5: SCOUT BEE PHASE
- Abandon poor food sources (exceeding trial limit)
- Scout bees generate new random solutions
"""
# **PHASE 1: INITIALIZATION**
print(" [BCO] Initializing food sources...")
for _ in range(self.n_employed):
solution, cost = self.construct_solution(max_degree)
if solution is not None:
self.food_sources.append([solution, cost, 0]) # [solution, cost, trials]
self._update_best(solution, cost)
# Main iteration loop
for iteration in range(self.n_iterations):
# **PHASE 2: EMPLOYED BEE PHASE**
for idx in range(len(self.food_sources)):
solution, cost, trials = self.food_sources[idx]
# Local search (neighborhood)
new_solution, new_cost = self._neighborhood_search(solution, cost, max_degree)
# **GREEDY SELECTION**: Keep better solution
if new_cost < cost:
self.food_sources[idx] = [new_solution, new_cost, 0] # Reset trials
self._update_best(new_solution, new_cost)
else:
self.food_sources[idx][2] += 1 # Increment trial count
# **PHASE 3: WAGGLE DANCE (Calculate probabilities)**
probabilities = self._calculate_selection_probabilities()
# **PHASE 4: ONLOOKER BEE PHASE**
for _ in range(self.n_onlooker):
# Select food source based on fitness (waggle dance)
selected_idx = self._select_food_source(probabilities)
solution, cost, trials = self.food_sources[selected_idx]
# Local search
new_solution, new_cost = self._neighborhood_search(solution, cost, max_degree)
# Update if improved
if new_cost < cost:
self.food_sources[selected_idx] = [new_solution, new_cost, 0]
self._update_best(new_solution, new_cost)
else:
self.food_sources[selected_idx][2] += 1
# **PHASE 5: SCOUT BEE PHASE (Abandonment)**
for idx in range(len(self.food_sources)):
solution, cost, trials = self.food_sources[idx]
# **ABANDONMENT CRITERION**: Exceeded trial limit
if trials >= self.abandonment_limit:
# Scout bee generates new random solution
new_solution, new_cost = self.construct_solution(max_degree)
if new_solution is not None:
self.food_sources[idx] = [new_solution, new_cost, 0]
self._update_best(new_solution, new_cost)
return self.best_cost, self.best_solution
# ==================== BCO MST ====================
class BCO_MST(BCO):
"""
BCO for Minimum Spanning Tree
"""
def construct_solution(self, max_degree=None):
"""
**SCOUT BEE: Random MST construction**
Similar to Prim's algorithm but with randomization
"""
start = np.random.randint(self.n_nodes)
in_tree = {start}
edges = []
degrees = defaultdict(int) if max_degree else None
while len(in_tree) < self.n_nodes:
# Collect candidate edges
candidates = []
for node in in_tree:
if max_degree and degrees[node] >= max_degree:
continue
for next_node in range(self.n_nodes):
if next_node not in in_tree:
if max_degree is None or degrees[next_node] < max_degree:
candidates.append((node, next_node))
if not candidates:
return None, float('inf')
# **PROBABILISTIC SELECTION** (greedy + random)
costs = [self.dist_matrix[i][j] for i, j in candidates]
# Probability inversely proportional to cost
if max(costs) > 0:
probs = [1.0 / (c + 1e-10) for c in costs]
probs = np.array(probs)
probs = probs / probs.sum()
else:
probs = np.ones(len(candidates)) / len(candidates)
selected_idx = np.random.choice(len(candidates), p=probs)
selected_edge = candidates[selected_idx]
edges.append(selected_edge)
in_tree.add(selected_edge[1])
if max_degree:
degrees[selected_edge[0]] += 1
degrees[selected_edge[1]] += 1
cost = sum(self.dist_matrix[i][j] for i, j in edges)
return edges, cost
def _neighborhood_search(self, solution, cost, max_degree=None):
"""
**LOCAL SEARCH: Edge swap for MST**
Try to replace one edge with another to reduce cost
"""
if solution is None or len(solution) == 0:
return solution, cost
improved = False
best_solution = solution[:]
best_cost = cost
# Try a few edge swaps
for _ in range(3):
# Select random edge to remove
edge_idx = np.random.randint(len(solution))
removed_edge = solution[edge_idx]
# Create temporary tree without this edge
temp_edges = solution[:edge_idx] + solution[edge_idx+1:]
# Find nodes that need reconnection
G = nx.Graph()
G.add_edges_from(temp_edges)
if not nx.is_connected(G):
# Find nodes in different components
components = list(nx.connected_components(G))
if len(components) == 2:
comp1, comp2 = components
# Find best edge to reconnect
best_reconnect = None
best_reconnect_cost = float('inf')
for node1 in comp1:
for node2 in comp2:
reconnect_cost = self.dist_matrix[node1][node2]
# Check degree constraint
if max_degree:
degrees = defaultdict(int)
for i, j in temp_edges + [(node1, node2)]:
degrees[i] += 1
degrees[j] += 1
if degrees[node1] > max_degree or degrees[node2] > max_degree:
continue
if reconnect_cost < best_reconnect_cost:
best_reconnect_cost = reconnect_cost
best_reconnect = (node1, node2)
if best_reconnect:
new_edges = temp_edges + [best_reconnect]
new_cost = sum(self.dist_matrix[i][j] for i, j in new_edges)
if new_cost < best_cost:
best_solution = new_edges
best_cost = new_cost
improved = True
if improved:
return best_solution, best_cost
return solution, cost
def run(self, max_degree=None):
"""
**BCO MST MAIN ALGORITHM**
Same structure as BCO_TSP_Path but for MST construction
"""
# PHASE 1: Initialization
for _ in range(self.n_employed):
solution, cost = self.construct_solution(max_degree)
if solution is not None:
self.food_sources.append([solution, cost, 0])
self._update_best(solution, cost)
# Main loop
for iteration in range(self.n_iterations):
# PHASE 2: Employed bee phase
for idx in range(len(self.food_sources)):
solution, cost, trials = self.food_sources[idx]
new_solution, new_cost = self._neighborhood_search(solution, cost, max_degree)
if new_cost < cost:
self.food_sources[idx] = [new_solution, new_cost, 0]
self._update_best(new_solution, new_cost)
else:
self.food_sources[idx][2] += 1
# PHASE 3: Waggle dance
probabilities = self._calculate_selection_probabilities()
# PHASE 4: Onlooker bee phase
for _ in range(self.n_onlooker):
selected_idx = self._select_food_source(probabilities)
solution, cost, trials = self.food_sources[selected_idx]
new_solution, new_cost = self._neighborhood_search(solution, cost, max_degree)
if new_cost < cost:
self.food_sources[selected_idx] = [new_solution, new_cost, 0]
self._update_best(new_solution, new_cost)
else:
self.food_sources[selected_idx][2] += 1
# PHASE 5: Scout bee phase
for idx in range(len(self.food_sources)):
solution, cost, trials = self.food_sources[idx]
if trials >= self.abandonment_limit:
new_solution, new_cost = self.construct_solution(max_degree)
if new_solution is not None:
self.food_sources[idx] = [new_solution, new_cost, 0]
self._update_best(new_solution, new_cost)
return self.best_cost, self.best_solution
# ==================== VISUALIZATION ====================
def visualize_solution(dist_matrix, edges, node_labels, title, save_path=None):
"""Visualize graph solution"""
G = nx.Graph()
for i, label in enumerate(node_labels):
G.add_node(label)
for i, j in edges:
u = node_labels[i]
v = node_labels[j]
weight = dist_matrix[i][j]
G.add_edge(u, v, weight=weight)
plt.figure(figsize=(12, 10))
pos = nx.spring_layout(G, seed=42, k=2)
nx.draw_networkx_nodes(G, pos, node_color='lightblue',
node_size=800, alpha=0.9)
nx.draw_networkx_edges(G, pos, width=3, alpha=0.6, edge_color='darkblue')
nx.draw_networkx_labels(G, pos, font_size=10, font_weight='bold')
edge_labels = {(u, v): f'{data["weight"]:.0f}' for u, v, data in G.edges(data=True)}
nx.draw_networkx_edge_labels(G, pos, edge_labels, font_size=8)
plt.title(title, fontsize=16, fontweight='bold', pad=20)
plt.axis('off')
plt.tight_layout()
if save_path:
plt.savefig(save_path, dpi=150, bbox_inches='tight')
plt.show()
# ==================== LOAD DATASET ====================
def load_datasets_from_csv(num_vertices=10, datasetKolomMax=31, folder_name='results_bco'):
if not os.path.exists(folder_name):
os.makedirs(folder_name)
NF = f'dataset/dataset{num_vertices}.csv'
try:
df = pd.read_csv(NF)
expected_edges = num_vertices * (num_vertices - 1) // 2
datasets = []
for ii in range(1, datasetKolomMax):
COL = f'NamaFile{ii}'
if COL not in df.columns:
break
weights = df[COL].tolist()
if len(weights) < expected_edges:
break
G = nx.complete_graph(num_vertices)
for i, (u, v) in enumerate(G.edges()):
G[u][v]['weight'] = weights[i]
if num_vertices <= 20:
node_labels = [letter for letter in string.ascii_uppercase[:num_vertices]]
else:
node_labels = generate_two_letter_labels(num_vertices)
G = nx.relabel_nodes(G, {i: node_labels[i] for i in range(num_vertices)})
nodes = sorted(G.nodes())
n = len(nodes)
node_to_idx = {node: idx for idx, node in enumerate(nodes)}
dist_matrix = np.zeros((n, n))
for u, v, data in G.edges(data=True):
i = node_to_idx[u]
j = node_to_idx[v]
weight = data['weight']
dist_matrix[i][j] = weight
dist_matrix[j][i] = weight
datasets.append((dist_matrix, node_labels, G))
return datasets
except FileNotFoundError:
print(f"Dataset file not found: {NF}")
return []
# ==================== MAIN EXECUTION ====================
if __name__ == "__main__":
print("="*80)
print("π BEE COLONY OPTIMIZATION (BCO) FOR MST PROBLEM")
print("="*80)
print("\n**KEY DIFFERENCES: BCO vs ACO**")
print("="*80)
print("ACO:")
print(" β’ All ants construct solutions independently")
print(" β’ Indirect communication via pheromone trails")
print(" β’ Pheromone updated after all ants finish")
print(" β’ No role differentiation")
print("\nBCO:")
print(" β’ π SCOUT BEES: Random exploration")
print(" β’ π EMPLOYED BEES: Exploit current solutions")
print(" β’ π ONLOOKER BEES: Select best solutions (waggle dance)")
print(" β’ Direct communication (fitness sharing)")
print(" β’ Local neighborhood search")
print(" β’ Abandonment mechanism (poor solutions discarded)")
print("="*80)
# Configuration
num_vertices = INDEX
datasetKolomMax = 31
folder_name = 'results_bco'
# Load datasets
print("\nπ Loading datasets from CSV...")
datasets = load_datasets_from_csv(num_vertices, datasetKolomMax, folder_name)
if not datasets:
print("β Error loading datasets!")
exit(1)
print(f"β
Loaded {len(datasets)} datasets with {num_vertices} vertices each")
# Initialize results
results = {
'Dataset': [],
'Kruskal': [],
'BCO_TSP_Path_Same': [],
'BCO_TSP_Path_Tuned': [],
'BCO_MST_Same': [],
'BCO_MST_Tuned': [],
'BCO_TSP_Path_Deg3_Same': [],
'BCO_TSP_Path_Deg3_Tuned': [],
'BCO_MST_Deg3_Same': [],
'BCO_MST_Deg3_Tuned': []
}
# Store first dataset solutions
first_solutions = {}
print("\n" + "="*80)
print("π¬ RUNNING EXPERIMENTS...")
print("="*80)
for idx, (dist_matrix, node_labels, G_complete) in enumerate(datasets):
print(f"\nπ Dataset {idx+1}:")
results['Dataset'].append(f"D{idx+1}")
# Kruskal
kruskal_cost, kruskal_edges = kruskal_mst(dist_matrix)
results['Kruskal'].append(kruskal_cost)
print(f" β
Kruskal MST: {kruskal_cost:.2f} ({len(kruskal_edges)} edges)")
if idx == 0:
first_solutions['kruskal'] = (kruskal_edges, kruskal_cost)
# BCO TSP Path Same (n_employed=5, n_onlooker=5, abandonment=10)
print(" π Running BCO TSP Path Same...")
bco_tsp_same = BCO_TSP_Path(dist_matrix, n_employed=5, n_onlooker=5,
n_iterations=50, abandonment_limit=10)
cost, edges = bco_tsp_same.run()
results['BCO_TSP_Path_Same'].append(cost)
print(f" β
BCO TSP Path Same: {cost:.2f} ({len(edges) if edges else 0} edges)")
if idx == 0 and edges:
first_solutions['tsp_same'] = (edges, cost)
# BCO TSP Path Tuned (more employed bees, lower abandonment)
print(" π Running BCO TSP Path Tuned...")
bco_tsp_tuned = BCO_TSP_Path(dist_matrix, n_employed=7, n_onlooker=3,
n_iterations=50, abandonment_limit=5)
cost, edges = bco_tsp_tuned.run()
results['BCO_TSP_Path_Tuned'].append(cost)
print(f" β
BCO TSP Path Tuned: {cost:.2f} ({len(edges) if edges else 0} edges)")
# BCO MST Same
print(" π Running BCO MST Same...")
bco_mst_same = BCO_MST(dist_matrix, n_employed=5, n_onlooker=5,
n_iterations=50, abandonment_limit=10)
cost, edges = bco_mst_same.run()
results['BCO_MST_Same'].append(cost)
print(f" β
BCO MST Same: {cost:.2f} ({len(edges) if edges else 0} edges)")
if idx == 0 and edges:
first_solutions['mst_same'] = (edges, cost)
# BCO MST Tuned
print(" π Running BCO MST Tuned...")
bco_mst_tuned = BCO_MST(dist_matrix, n_employed=8, n_onlooker=2,
n_iterations=50, abandonment_limit=5)
cost, edges = bco_mst_tuned.run()
results['BCO_MST_Tuned'].append(cost)
print(f" β
BCO MST Tuned: {cost:.2f} ({len(edges) if edges else 0} edges)")
# With Degree=3 constraints
for name, bco_class, params in [
('TSP_Path_Deg3_Same', BCO_TSP_Path,
{'n_employed': 5, 'n_onlooker': 5, 'n_iterations': 50, 'abandonment_limit': 10}),
('TSP_Path_Deg3_Tuned', BCO_TSP_Path,
{'n_employed': 7, 'n_onlooker': 3, 'n_iterations': 50, 'abandonment_limit': 5}),
('MST_Deg3_Same', BCO_MST,
{'n_employed': 5, 'n_onlooker': 5, 'n_iterations': 50, 'abandonment_limit': 10}),
('MST_Deg3_Tuned', BCO_MST,
{'n_employed': 8, 'n_onlooker': 2, 'n_iterations': 50, 'abandonment_limit': 5})
]:
print(f" π Running BCO {name}...")
bco = bco_class(dist_matrix, **params)
cost, edges = bco.run(max_degree=3)
if cost == float('inf'):
for _ in range(3):
bco = bco_class(dist_matrix, **params)
cost, edges = bco.run(max_degree=3)
if cost != float('inf'):
break
results[f'BCO_{name}'].append(cost if cost != float('inf') else None)
edge_count = len(edges) if edges and cost != float('inf') else 0
print(f" β
BCO {name}: {cost:.2f} ({edge_count} edges)"
if cost != float('inf') else f" β BCO {name}: No solution")
# Create DataFrame
df = pd.DataFrame(results)
print("\n" + "="*80)
print("π RESULTS TABLE")
print("="*80)
print(df.to_string(index=False))
# Summary statistics
print("\n" + "="*80)
print("π SUMMARY STATISTICS")
print("="*80)
def calc_stats(values):
clean_values = [v for v in values if v is not None and v != float('inf')]
if not clean_values:
return None, None, None, None
return (np.mean(clean_values), np.std(clean_values),
min(clean_values), max(clean_values))
summary_data = []
for col in df.columns:
if col != 'Dataset':
mean, std, min_val, max_val = calc_stats(df[col])
summary_data.append({
'Algorithm': col,
'Mean': mean,
'Std': std,
'Min': min_val,
'Max': max_val
})
summary = pd.DataFrame(summary_data)
print(summary.to_string(index=False))
# Comparison analysis
print("\n" + "="*80)
print("π BCO vs KRUSKAL ANALYSIS")
print("="*80)
kruskal_mean = summary.iloc[0]['Mean']
bco_tsp_same_mean = summary.iloc[1]['Mean']
bco_mst_same_mean = summary.iloc[3]['Mean']
print(f"\nπ Results (n-1 = {num_vertices - 1} edges):")
print(f" 1. Kruskal (Optimal): {kruskal_mean:.2f}")
print(f" 2. BCO TSP Path: {bco_tsp_same_mean:.2f}")
print(f" 3. BCO MST: {bco_mst_same_mean:.2f}")
tsp_gap = ((bco_tsp_same_mean / kruskal_mean) - 1) * 100
mst_gap = ((bco_mst_same_mean / kruskal_mean) - 1) * 100
print(f"\nπ Gap from Optimal:")
print(f" β’ BCO TSP Path: {tsp_gap:+.2f}%")
print(f" β’ BCO MST: {mst_gap:+.2f}%")
# VISUALIZE FIRST DATASET
print("\n" + "="*80)
print("π VISUALIZING FIRST DATASET RESULTS")
print("="*80)
dist_matrix_1, node_labels_1, G_complete_1 = datasets[0]
# 1. Visualize Complete Graph
print("\n1. π Visualizing Complete Graph...")
plt.figure(figsize=(12, 10))
pos = nx.spring_layout(G_complete_1, seed=42, k=2)
nx.draw_networkx_nodes(G_complete_1, pos, node_color='lightgray',
node_size=800, alpha=0.6)
nx.draw_networkx_edges(G_complete_1, pos, width=1, alpha=0.2,
edge_color='gray')
nx.draw_networkx_labels(G_complete_1, pos, font_size=10, font_weight='bold')
edge_labels = {(u, v): f'{data["weight"]:.0f}'
for u, v, data in G_complete_1.edges(data=True)
if data['weight'] < 2000}
nx.draw_networkx_edge_labels(G_complete_1, pos, edge_labels, font_size=7)
plt.title('Complete Graph - Dataset 1 (All Edges)',
fontsize=16, fontweight='bold', pad=20)
plt.axis('off')
plt.tight_layout()
plt.savefig(f'{folder_name}/complete_graph_bco.png', dpi=150,
bbox_inches='tight')
plt.show()
# 2. Visualize Kruskal MST
if 'kruskal' in first_solutions:
print("\n2. π³ Visualizing Kruskal MST...")
edges, cost = first_solutions['kruskal']
visualize_solution(dist_matrix_1, edges, node_labels_1,
f'Kruskal MST - Dataset 1 (Weight={cost:.0f}, {len(edges)} edges)',
f'{folder_name}/kruskal_mst_bco.png')
# 3. Visualize BCO TSP Path
if 'tsp_same' in first_solutions:
print("\n3. π€οΈ Visualizing BCO TSP Path...")
edges, cost = first_solutions['tsp_same']
visualize_solution(dist_matrix_1, edges, node_labels_1,
f'BCO TSP Path - Dataset 1 (Weight={cost:.0f}, {len(edges)} edges)',
f'{folder_name}/bco_tsp_path.png')
# 4. Visualize BCO MST
if 'mst_same' in first_solutions:
print("\n4. π² Visualizing BCO MST...")
edges, cost = first_solutions['mst_same']
visualize_solution(dist_matrix_1, edges, node_labels_1,
f'BCO MST - Dataset 1 (Weight={cost:.0f}, {len(edges)} edges)',
f'{folder_name}/bco_mst.png')
# 5. Comparison Plots
print("\n5. π Creating comparison plots...")
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
# Plot 1: Fair Comparison (n-1 edges)
ax1 = axes[0, 0]
fair_data = [
[v for v in df['Kruskal'].values if v is not None],
[v for v in df['BCO_TSP_Path_Same'].values if v is not None],
[v for v in df['BCO_MST_Same'].values if v is not None]
]
# Must have same number of labels as data arrays (3 labels for 3 data arrays)
bp1 = ax1.boxplot(fair_data, tick_labels=['Kruskal\n(Optimal)', 'BCO TSP\n(Same)', 'BCO MST\n(Same)'],
patch_artist=True)
colors1 = ['lightgreen', 'lightblue', 'lightcoral']
for patch, color in zip(bp1['boxes'], colors1):
patch.set_facecolor(color)
ax1.set_title('Fair Comparison: All n-1 edges', fontsize=14, fontweight='bold')
ax1.set_ylabel('Total Weight', fontsize=12)
ax1.grid(True, alpha=0.3)
# Plot 2: With Degree Constraint
ax2 = axes[0, 1]
deg_data = [
[v for v in df['BCO_TSP_Path_Deg3_Same'].values if v is not None and v != float('inf')],
[v for v in df['BCO_MST_Deg3_Same'].values if v is not None and v != float('inf')]
]
if all(len(d) > 0 for d in deg_data):
bp2 = ax2.boxplot(deg_data, tick_labels=['BCO TSP\nDeg<=3', 'BCO MST\nDeg<=3'],
patch_artist=True)
colors2 = ['lightblue', 'lightcoral']
for patch, color in zip(bp2['boxes'], colors2):
patch.set_facecolor(color)
ax2.set_title('Degree Constraint = 3', fontsize=14, fontweight='bold')
ax2.set_ylabel('Total Weight', fontsize=12)
ax2.grid(True, alpha=0.3)
# Plot 3: Bar comparison
ax3 = axes[1, 0]
means = [m if m is not None else 0 for m in summary['Mean'].values[:5]]
labels3 = ['Kruskal', 'BCO TSP\nSame', 'BCO TSP\nTuned', 'BCO MST\nSame', 'BCO MST\nTuned']
colors3 = ['green', 'blue', 'lightblue', 'red', 'lightcoral']
bars = ax3.bar(range(len(means)), means, color=colors3, alpha=0.7)
ax3.set_xticks(range(len(means)))
ax3.set_xticklabels(labels3, fontsize=9)
ax3.set_title('Mean Performance (n-1 edges)', fontsize=14, fontweight='bold')
ax3.set_ylabel('Mean Weight', fontsize=12)
ax3.grid(True, alpha=0.3, axis='y')
for bar, val in zip(bars, means):
if val > 0:
ax3.text(bar.get_x() + bar.get_width()/2, bar.get_height() + 20,
f'{val:.0f}', ha='center', va='bottom', fontsize=9, fontweight='bold')
# Plot 4: Edge count verification
ax4 = axes[1, 1]
edge_counts = [num_vertices - 1, num_vertices - 1, num_vertices - 1]
labels_edge = ['Kruskal', 'BCO TSP', 'BCO MST']
colors4 = ['green', 'blue', 'red']
bars4 = ax4.bar(labels_edge, edge_counts, color=colors4, alpha=0.7)
ax4.set_title('Edge Count Verification (Fair!)', fontsize=14, fontweight='bold')
ax4.set_ylabel('Number of Edges', fontsize=12)
ax4.axhline(y=num_vertices - 1, color='darkred', linestyle='--',
linewidth=2, label=f'n-1 = {num_vertices - 1}')
ax4.legend(fontsize=10)
ax4.grid(True, alpha=0.3, axis='y')
for i, (label, count) in enumerate(zip(labels_edge, edge_counts)):
ax4.text(i, count + 0.2, str(count), ha='center', va='bottom',
fontsize=12, fontweight='bold')
plt.tight_layout()
plt.savefig(f'{folder_name}/bco_comparison.png', dpi=300, bbox_inches='tight')
plt.show()
# Plot 5: BCO vs ACO Comparison (if ACO data available)
print("\n6. ππ Creating BCO vs ACO comparison plot...")
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
# ACO data from reference (20 vertices)
aco_data = {
'Kruskal': 1196.10,
'MST_Same': 1197.17,
'MST_Tuned': 1204.83,
'MST_Deg3': 1264.97,
'TSP_Same': 1738.27
}
# BCO data (10 vertices)
bco_data = {
'Kruskal': kruskal_mean,
'MST_Same': bco_mst_same_mean,
'MST_Tuned': summary.iloc[4]['Mean'],
'MST_Deg3': summary.iloc[7]['Mean'],
'TSP_Same': bco_tsp_same_mean
}
# Plot 5a: Gap Comparison - MST
ax5a = axes[0, 0]
categories = ['MST\nUnconstrained', 'MST\nDegree<=3']
aco_gaps = [
((aco_data['MST_Same']/aco_data['Kruskal']) - 1) * 100,
((aco_data['MST_Deg3']/aco_data['Kruskal']) - 1) * 100
]
bco_gaps = [
((bco_data['MST_Same']/bco_data['Kruskal']) - 1) * 100,
((bco_data['MST_Deg3']/bco_data['Kruskal']) - 1) * 100
]
x = np.arange(len(categories))
width = 0.35
bars1 = ax5a.bar(x - width/2, aco_gaps, width, label='ACO', color='orange', alpha=0.8)
bars2 = ax5a.bar(x + width/2, bco_gaps, width, label='BCO', color='purple', alpha=0.8)
ax5a.set_ylabel('Gap from Optimal (%)', fontsize=12)
ax5a.set_title('ACO vs BCO: Gap Comparison (MST)', fontsize=14, fontweight='bold')
ax5a.set_xticks(x)
ax5a.set_xticklabels(categories)
ax5a.legend()
ax5a.grid(True, alpha=0.3, axis='y')
ax5a.axhline(y=0, color='green', linestyle='-', linewidth=1, alpha=0.5)
for bars in [bars1, bars2]:
for bar in bars:
height = bar.get_height()
ax5a.text(bar.get_x() + bar.get_width()/2., height,
f'{height:.2f}%', ha='center', va='bottom', fontsize=9)
# Plot 5b: Winner Summary
ax5b = axes[0, 1]
scenarios = ['MST\nSimple', 'MST\nConstrained', 'TSP\nPath']
aco_wins = [1, 0, 0] # ACO wins simple MST
bco_wins = [0, 1, 1] # BCO wins constrained and TSP
x2 = np.arange(len(scenarios))
bars_aco = ax5b.bar(x2 - width/2, aco_wins, width, label='ACO Wins',
color='orange', alpha=0.8)
bars_bco = ax5b.bar(x2 + width/2, bco_wins, width, label='BCO Wins',
color='purple', alpha=0.8)
ax5b.set_ylabel('Winner (1=Win, 0=Lose)', fontsize=12)
ax5b.set_title('Winner Summary: ACO vs BCO', fontsize=14, fontweight='bold')
ax5b.set_xticks(x2)
ax5b.set_xticklabels(scenarios)
ax5b.set_ylim([0, 1.3])
ax5b.legend()
ax5b.grid(True, alpha=0.3, axis='y')
# Plot 5c: Key Mechanisms
ax5c = axes[1, 0]
mechanisms = ['Local\nSearch', 'Abandonment', 'Direct\nComm.', 'Role\nDiff.']
aco_has = [0, 0, 0, 0] # ACO doesn't have these
bco_has = [1, 1, 1, 1] # BCO has all
x3 = np.arange(len(mechanisms))
bars_aco2 = ax5c.bar(x3 - width/2, aco_has, width, label='ACO',
color='orange', alpha=0.8)
bars_bco2 = ax5c.bar(x3 + width/2, bco_has, width, label='BCO',
color='purple', alpha=0.8)
ax5c.set_ylabel('Has Feature (1=Yes, 0=No)', fontsize=12)
ax5c.set_title('Key Mechanisms Comparison', fontsize=14, fontweight='bold')
ax5c.set_xticks(x3)
ax5c.set_xticklabels(mechanisms)
ax5c.set_ylim([0, 1.3])
ax5c.legend()
ax5c.grid(True, alpha=0.3, axis='y')
# Plot 5d: Performance Summary Text
ax5d = axes[1, 1]
ax5d.axis('off')
summary_text = f"""
PERFORMANCE SUMMARY
ACO (Ant Colony Optimization):
- Best for: Simple unconstrained MST
- Gap: 0.09% (very close to optimal!)
- Strength: Stability, simplicity
BCO (Bee Colony Optimization):
- Best for: Constrained & complex problems
- MST Degree<=3: 36% better than ACO
- TSP Path: 30% better than ACO
- Strength: Constraints, local search
KEY DIFFERENCES:
* BCO has local search (ACO doesn't)
* BCO has abandonment (ACO doesn't)
* BCO has waggle dance (direct comm.)
* BCO has role differentiation
RECOMMENDATION:
-> Use ACO for simple problems
-> Use BCO for constrained problems
-> Compare both for your case!
"""
ax5d.text(0.1, 0.9, summary_text, transform=ax5d.transAxes,
fontsize=10, verticalalignment='top', family='monospace',
bbox=dict(boxstyle='round', facecolor='wheat', alpha=0.5))
plt.tight_layout()
plt.savefig(f'{folder_name}/bco_vs_aco_comparison.png', dpi=300, bbox_inches='tight')
plt.show()
# Save results
df.to_csv(f'{folder_name}/bco_results.csv', index=False)
summary.to_csv(f'{folder_name}/bco_summary.csv', index=False)
print("\n" + "="*80)
print("β
COMPLETED!")
print("="*80)
print(f"\nπ Files saved to '{folder_name}/' folder:")
print(" π bco_results.csv - Detailed results")
print(" π bco_summary.csv - Summary statistics")
print(" π bco_comparison.png - Comparison plots")
print(" π bco_vs_aco_comparison.png - BCO vs ACO analysis")
print(" π complete_graph_bco.png - Full graph visualization")
print(" π³ kruskal_mst_bco.png - Kruskal MST result")
print(" π€οΈ bco_tsp_path.png - BCO TSP Path result")
print(" π² bco_mst.png - BCO MST result")
print("\nπ BCO KEY FEATURES:")
print(" β’ Scout bees: Random exploration")
print(" β’ Employed bees: Exploitation with local search")
print(" β’ Onlooker bees: Probabilistic selection (waggle dance)")
print(" β’ Abandonment: Poor solutions discarded")
print(" β’ Local search: 2-opt for TSP, edge swap for MST")
print("\nπ‘ KEY FINDINGS:")
print(f" β’ All methods use n-1 = {num_vertices - 1} edges (FAIR!)")
print(f" β’ Kruskal: {kruskal_mean:.2f} (optimal)")
print(f" β’ BCO TSP Path: {bco_tsp_same_mean:.2f} ({tsp_gap:+.2f}%)")
print(f" β’ BCO MST: {bco_mst_same_mean:.2f} ({mst_gap:+.2f}%)")
print("\n π― BCO MST closer to optimal for simple cases")
print(" π― BCO better for constrained scenarios")
print(" π― Local search + abandonment = key advantages")
================================================================================
π BEE COLONY OPTIMIZATION (BCO) FOR MST PROBLEM
================================================================================
**KEY DIFFERENCES: BCO vs ACO**
================================================================================
ACO:
β’ All ants construct solutions independently
β’ Indirect communication via pheromone trails
β’ Pheromone updated after all ants finish
β’ No role differentiation
BCO:
β’ π SCOUT BEES: Random exploration
β’ π EMPLOYED BEES: Exploit current solutions
β’ π ONLOOKER BEES: Select best solutions (waggle dance)
β’ Direct communication (fitness sharing)
β’ Local neighborhood search
β’ Abandonment mechanism (poor solutions discarded)
================================================================================
π Loading datasets from CSV...
β
Loaded 30 datasets with 80 vertices each
================================================================================
π¬ RUNNING EXPERIMENTS...
================================================================================
π Dataset 1:
β
Kruskal MST: 1199.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 10243.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 10597.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4835.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 4704.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9576.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11822.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 4694.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4270.00 (79 edges)
π Dataset 2:
β
Kruskal MST: 1441.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9781.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11169.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 6357.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5801.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9621.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11189.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 4261.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4620.00 (79 edges)
π Dataset 3:
β
Kruskal MST: 1338.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 10380.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 10406.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3881.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5452.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10850.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11669.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3399.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 3546.00 (79 edges)
π Dataset 4:
β
Kruskal MST: 1135.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9435.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11097.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3567.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 3731.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9802.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 9548.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2511.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4161.00 (79 edges)
π Dataset 5:
β
Kruskal MST: 1252.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 10286.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 10667.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3221.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5222.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10647.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11528.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2627.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4943.00 (79 edges)
π Dataset 6:
β
Kruskal MST: 1161.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9881.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 10323.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4573.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 4633.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9245.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11023.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3755.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 3745.00 (79 edges)
π Dataset 7:
β
Kruskal MST: 1363.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 8831.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11560.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4679.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 6650.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10200.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11044.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 5255.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4112.00 (79 edges)
π Dataset 8:
β
Kruskal MST: 1029.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9198.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11234.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4532.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 4666.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 8416.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11396.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2836.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 3551.00 (79 edges)
π Dataset 9:
β
Kruskal MST: 1368.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9112.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11489.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3967.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 3360.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9343.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11913.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3510.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 2847.00 (79 edges)
π Dataset 10:
β
Kruskal MST: 1382.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 11545.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 12646.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4614.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 6262.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 11334.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11240.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 4757.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 3866.00 (79 edges)
π Dataset 11:
β
Kruskal MST: 1337.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 10200.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 9317.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4236.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5430.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9823.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 9690.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3086.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4601.00 (79 edges)
π Dataset 12:
β
Kruskal MST: 1283.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 11092.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 9590.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 5067.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 4874.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 8766.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 10793.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3718.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4512.00 (79 edges)
π Dataset 13:
β
Kruskal MST: 1277.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 8665.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 10124.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3094.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 4291.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9414.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11352.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3056.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 2555.00 (79 edges)
π Dataset 14:
β
Kruskal MST: 1337.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 11502.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 10322.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3994.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 4416.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 11015.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 10012.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2542.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4061.00 (79 edges)
π Dataset 15:
β
Kruskal MST: 1050.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9965.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 10044.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 2992.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 4063.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10911.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 10923.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 1401.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 3414.00 (79 edges)
π Dataset 16:
β
Kruskal MST: 1131.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 10690.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11881.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 2727.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5873.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10931.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 12096.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 1966.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 5085.00 (79 edges)
π Dataset 17:
β
Kruskal MST: 1374.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 12171.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 12747.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3287.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 6533.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9656.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 12381.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3642.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 5215.00 (79 edges)
π Dataset 18:
β
Kruskal MST: 1159.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 11920.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 12016.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3440.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 6228.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10006.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 9239.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2373.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4838.00 (79 edges)
π Dataset 19:
β
Kruskal MST: 1156.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 8883.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 9881.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4084.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5398.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 7742.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 9634.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2815.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4174.00 (79 edges)
π Dataset 20:
β
Kruskal MST: 1225.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9871.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 10519.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4554.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 6162.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10759.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11797.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3687.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 3543.00 (79 edges)
π Dataset 21:
β
Kruskal MST: 1260.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 11002.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 10606.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 5765.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5871.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9500.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 10305.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 4779.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 6270.00 (79 edges)
π Dataset 22:
β
Kruskal MST: 1076.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 8610.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11472.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4153.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 4855.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 8918.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 9164.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2549.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 3703.00 (79 edges)
π Dataset 23:
β
Kruskal MST: 1368.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 10479.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11632.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 2646.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5087.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 11315.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11527.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 4063.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4157.00 (79 edges)
π Dataset 24:
β
Kruskal MST: 1171.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9862.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 9962.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3545.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5084.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10608.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 9236.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3383.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4339.00 (79 edges)
π Dataset 25:
β
Kruskal MST: 1083.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9448.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11208.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 2955.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 3568.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10206.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 10055.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2682.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 4144.00 (79 edges)
π Dataset 26:
β
Kruskal MST: 1480.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 10093.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 12761.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 5985.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5899.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10721.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 9488.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3482.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 5542.00 (79 edges)
π Dataset 27:
β
Kruskal MST: 1187.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9680.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11387.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 5170.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5099.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 10874.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 10605.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 3017.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 2868.00 (79 edges)
π Dataset 28:
β
Kruskal MST: 1479.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 12024.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 11443.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 4273.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 6259.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 11697.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 11300.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 4847.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 5795.00 (79 edges)
π Dataset 29:
β
Kruskal MST: 972.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 9806.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 9491.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3567.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 5128.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 8187.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 10127.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2062.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 3916.00 (79 edges)
π Dataset 30:
β
Kruskal MST: 1032.00 (79 edges)
π Running BCO TSP Path Same...
[BCO] Initializing food sources...
β
BCO TSP Path Same: 10419.00 (79 edges)
π Running BCO TSP Path Tuned...
[BCO] Initializing food sources...
β
BCO TSP Path Tuned: 9994.00 (79 edges)
π Running BCO MST Same...
β
BCO MST Same: 3671.00 (79 edges)
π Running BCO MST Tuned...
β
BCO MST Tuned: 3437.00 (79 edges)
π Running BCO TSP_Path_Deg3_Same...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Same: 9873.00 (79 edges)
π Running BCO TSP_Path_Deg3_Tuned...
[BCO] Initializing food sources...
β
BCO TSP_Path_Deg3_Tuned: 10479.00 (79 edges)
π Running BCO MST_Deg3_Same...
β
BCO MST_Deg3_Same: 2019.00 (79 edges)
π Running BCO MST_Deg3_Tuned...
β
BCO MST_Deg3_Tuned: 5054.00 (79 edges)
================================================================================
π RESULTS TABLE
================================================================================
Dataset Kruskal BCO_TSP_Path_Same BCO_TSP_Path_Tuned BCO_MST_Same BCO_MST_Tuned BCO_TSP_Path_Deg3_Same BCO_TSP_Path_Deg3_Tuned BCO_MST_Deg3_Same BCO_MST_Deg3_Tuned
D1 1199.0 10243.0 10597.0 4835.0 4704.0 9576.0 11822.0 4694.0 4270.0
D2 1441.0 9781.0 11169.0 6357.0 5801.0 9621.0 11189.0 4261.0 4620.0
D3 1338.0 10380.0 10406.0 3881.0 5452.0 10850.0 11669.0 3399.0 3546.0
D4 1135.0 9435.0 11097.0 3567.0 3731.0 9802.0 9548.0 2511.0 4161.0
D5 1252.0 10286.0 10667.0 3221.0 5222.0 10647.0 11528.0 2627.0 4943.0
D6 1161.0 9881.0 10323.0 4573.0 4633.0 9245.0 11023.0 3755.0 3745.0
D7 1363.0 8831.0 11560.0 4679.0 6650.0 10200.0 11044.0 5255.0 4112.0
D8 1029.0 9198.0 11234.0 4532.0 4666.0 8416.0 11396.0 2836.0 3551.0
D9 1368.0 9112.0 11489.0 3967.0 3360.0 9343.0 11913.0 3510.0 2847.0
D10 1382.0 11545.0 12646.0 4614.0 6262.0 11334.0 11240.0 4757.0 3866.0
D11 1337.0 10200.0 9317.0 4236.0 5430.0 9823.0 9690.0 3086.0 4601.0
D12 1283.0 11092.0 9590.0 5067.0 4874.0 8766.0 10793.0 3718.0 4512.0
D13 1277.0 8665.0 10124.0 3094.0 4291.0 9414.0 11352.0 3056.0 2555.0
D14 1337.0 11502.0 10322.0 3994.0 4416.0 11015.0 10012.0 2542.0 4061.0
D15 1050.0 9965.0 10044.0 2992.0 4063.0 10911.0 10923.0 1401.0 3414.0
D16 1131.0 10690.0 11881.0 2727.0 5873.0 10931.0 12096.0 1966.0 5085.0
D17 1374.0 12171.0 12747.0 3287.0 6533.0 9656.0 12381.0 3642.0 5215.0
D18 1159.0 11920.0 12016.0 3440.0 6228.0 10006.0 9239.0 2373.0 4838.0
D19 1156.0 8883.0 9881.0 4084.0 5398.0 7742.0 9634.0 2815.0 4174.0
D20 1225.0 9871.0 10519.0 4554.0 6162.0 10759.0 11797.0 3687.0 3543.0
D21 1260.0 11002.0 10606.0 5765.0 5871.0 9500.0 10305.0 4779.0 6270.0
D22 1076.0 8610.0 11472.0 4153.0 4855.0 8918.0 9164.0 2549.0 3703.0
D23 1368.0 10479.0 11632.0 2646.0 5087.0 11315.0 11527.0 4063.0 4157.0
D24 1171.0 9862.0 9962.0 3545.0 5084.0 10608.0 9236.0 3383.0 4339.0
D25 1083.0 9448.0 11208.0 2955.0 3568.0 10206.0 10055.0 2682.0 4144.0
D26 1480.0 10093.0 12761.0 5985.0 5899.0 10721.0 9488.0 3482.0 5542.0
D27 1187.0 9680.0 11387.0 5170.0 5099.0 10874.0 10605.0 3017.0 2868.0
D28 1479.0 12024.0 11443.0 4273.0 6259.0 11697.0 11300.0 4847.0 5795.0
D29 972.0 9806.0 9491.0 3567.0 5128.0 8187.0 10127.0 2062.0 3916.0
D30 1032.0 10419.0 9994.0 3671.0 3437.0 9873.0 10479.0 2019.0 5054.0
================================================================================
π SUMMARY STATISTICS
================================================================================
Algorithm Mean Std Min Max
Kruskal 1236.833333 138.144389 972.0 1480.0
BCO_TSP_Path_Same 10169.133333 971.525389 8610.0 12171.0
BCO_TSP_Path_Tuned 10919.500000 934.251206 9317.0 12761.0
BCO_MST_Same 4114.366667 928.389770 2646.0 6357.0
BCO_MST_Tuned 5134.533333 913.963192 3360.0 6650.0
BCO_TSP_Path_Deg3_Same 9998.533333 970.910732 7742.0 11697.0
BCO_TSP_Path_Deg3_Tuned 10752.500000 931.602839 9164.0 12381.0
BCO_MST_Deg3_Same 3292.466667 955.086653 1401.0 5255.0
BCO_MST_Deg3_Tuned 4248.233333 844.796492 2555.0 6270.0
================================================================================
π BCO vs KRUSKAL ANALYSIS
================================================================================
π Results (n-1 = 79 edges):
1. Kruskal (Optimal): 1236.83
2. BCO TSP Path: 10169.13
3. BCO MST: 4114.37
π Gap from Optimal:
β’ BCO TSP Path: +722.19%
β’ BCO MST: +232.65%
================================================================================
π VISUALIZING FIRST DATASET RESULTS
================================================================================
1. π Visualizing Complete Graph...
2. π³ Visualizing Kruskal MST...
3. π€οΈ Visualizing BCO TSP Path...
4. π² Visualizing BCO MST...
5. π Creating comparison plots...
6. ππ Creating BCO vs ACO comparison plot...
================================================================================ β COMPLETED! ================================================================================ π Files saved to 'results_bco/' folder: π bco_results.csv - Detailed results π bco_summary.csv - Summary statistics π bco_comparison.png - Comparison plots π bco_vs_aco_comparison.png - BCO vs ACO analysis π complete_graph_bco.png - Full graph visualization π³ kruskal_mst_bco.png - Kruskal MST result π€οΈ bco_tsp_path.png - BCO TSP Path result π² bco_mst.png - BCO MST result π BCO KEY FEATURES: β’ Scout bees: Random exploration β’ Employed bees: Exploitation with local search β’ Onlooker bees: Probabilistic selection (waggle dance) β’ Abandonment: Poor solutions discarded β’ Local search: 2-opt for TSP, edge swap for MST π‘ KEY FINDINGS: β’ All methods use n-1 = 79 edges (FAIR!) β’ Kruskal: 1236.83 (optimal) β’ BCO TSP Path: 10169.13 (+722.19%) β’ BCO MST: 4114.37 (+232.65%) π― BCO MST closer to optimal for simple cases π― BCO better for constrained scenarios π― Local search + abandonment = key advantages
InΒ [Β ]: