Skip to content

Instantly share code, notes, and snippets.

View behnambm's full-sized avatar
:electron:
Focusing

Behnam behnambm

:electron:
Focusing
View GitHub Profile
@behnambm
behnambm / tight-loop.go
Created April 13, 2025 19:37
A sample of tight loop in Go
package main
func main() {
counter := 0
for {
counter++
}
}
@behnambm
behnambm / ga-cpu-scheduling.py
Created May 7, 2024 19:10
GA CPU job scheduling
import random
# Define the number of jobs and their processing times
NUM_JOBS = 5
processing_times = [10, 6, 8, 7, 3] # Example processing times for each job
# Genetic Algorithm parameters
POPULATION_SIZE = 50
NUM_GENERATIONS = 100
CROSSOVER_RATE = 0.8
import math
import threading
import tkinter as tk
import numpy as np
from numpy import random
class TravelingSalesmanProblem:
def __init__(self, num_cities):
# Define the number of cities
@behnambm
behnambm / tsp-tabu.py
Created March 2, 2024 18:04
TSP-Tabu Search
import random
import numpy as np
# Define the distance matrix between cities
# In this example, we generate random distances for demonstration purposes
def generate_distance_matrix(num_cities):
distances = np.random.randint(10, 100, size=(num_cities, num_cities))
np.fill_diagonal(distances, 0) # Diagonal elements are zero
return distances