Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill genetic-algorithms명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | genetic-algorithms |
| description | Genetic algorithm optimization |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"machine-learning-engineers","category":"artificial-intelligence"} |
Use me when:
┌──────────────┐
│ Population │◀──────────────┐
│ Generation │ │
└──────┬───────┘ │
│ │
▼ │
┌──────────────┐ ┌─────────┐│
│ Evaluate │ │ Select ││
│ Fitness │───▶│ Parents││
└──────────────┘ └────┬────┘
│
▼
┌─────────────┐
│ Crossover │
│ + Mutate │
└──────┬──────┘
│
▼
┌─────────────┐
│ Replace │
│ Population │
└──────┬──────┘
│
▼
┌──────────────┐
│ Continue? │
└──────────────┘
import random
import numpy as np
class GeneticAlgorithm:
def __init__(self, pop_size=100, mutation_rate=0.1,
crossover_rate=0.8):
self.pop_size = pop_size
self.mutation_rate = mutation_rate
self.crossover_rate = crossover_rate
def init_population(self):
return [self.create_individual() for _ in range(self.pop_size)]
def fitness(self, individual):
raise NotImplemented
def selection(self, population, fitnesses):
# Tournament selection
selected = []
for _ in range(len(population)):
i, j = random.sample(range(len(population)), 2)
if fitnesses[i] > fitnesses[j]:
selected.append(population[i].copy())
else:
selected.append(population[j].copy())
return selected
def crossover(self, parent1, parent2):
random.random() > .crossover_rate:
parent1.copy(), parent2.copy()
point = random.randint(, (parent1) - )
child1 = parent1[:point] + parent2[point:]
child2 = parent2[:point] + parent1[point:]
child1, child2
():
i ((individual)):
random.random() < .mutation_rate:
individual[i] = .random_gene()
individual
():
population = .init_population()
gen (generations):
fitnesses = [.fitness(ind) ind population]
best_idx = np.argmax(fitnesses)
new_pop = [population[best_idx].copy()]
parents = .selection(population, fitnesses)
i (, (parents) - , ):
child1, child2 = .crossover(parents[i], parents[i+])
new_pop.append(.mutate(child1))
new_pop.append(.mutate(child2))
population = new_pop[:.pop_size]
(population, key=.fitness)