k3s + kilo

  1. server部署k3s

curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_CLUSTER_INIT=true INSTALL_K3S_EXEC="--tls-san {{ server_public_ip }} --node-external-ip {{ master_ip }}  --flannel-backend none --kube-proxy-arg metrics-bind-address=0.0.0.0 --kube-apiserver-arg feature-gates=EphemeralContainers=true" sh -s -
  1. 指定 server 拓扑

k3s kubectl annotate node k3s-master kilo.squat.ai/location="93"
k3s kubectl annotate node k3s-master kilo.squat.ai/force-endpoint=x.x.x.x:51820
k3s kubectl annotate node k3s-master kilo.squat.ai/persistent-keepalive=20
  1. 部署kilo

kubectl apply -f https://gitee.com/mirrors/squat/raw/main/manifests/crds.yaml
kubectl apply -f https://gitee.com/mirrors/squat/raw/main/manifests/kilo-k3s.yaml
  1. node部署k3s

curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_TOKEN={{ token }} K3S_URL=https://{{ server_public_ip }}:6443 sh -s - --node-external-ip {{ node_public_ip }} --kube-proxy-arg "metrics-bind-address=0.0.0.0"
  1. 指定node拓扑

k3s kubectl annotate node k3s-node kilo.squat.ai/location="93"
k3s kubectl annotate node k3s-node kilo.squat.ai/force-endpoint=x.x.x.x:51820
k3s kubectl annotate node k3s-node kilo.squat.ai/persistent-keepalive=20

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import deap import random from deap import base, creator, tools, algorithms import numpy as np import pandas as pd # 参数 stations = 30 start_end_stations = [1, 2, 5, 8, 10, 14, 17, 18, 21, 22, 25, 26, 27, 30] min_interval = 108 min_stopping_time = 20 max_stopping_time = 120 passengers_per_train = 1860 min_small_loop_stations = 3 max_small_loop_stations = 24 average_boarding_time = 0.04 # 使用 ExcelFile ,通过将 xls 或者 xlsx 路径传入,生成一个实例 stations_kilo1 = pd.read_excel(r'D:\桌面\附件2:区间运行时间(1).xlsx', sheet_name="Sheet1") stations_kilo2 = pd.read_excel(r'D:\桌面\附件3:OD客流数据(1).xlsx', sheet_name="Sheet1") stations_kilo3 = pd.read_excel(r'D:\桌面\附件4:断面客流数据.xlsx', sheet_name="Sheet1") print(stations_kilo1) print(stations_kilo2) print(stations_kilo3) # 适应度函数 def fitness_function(individual): big_loop_trains, small_loop_trains, small_loop_start, small_loop_end = individual small_loop_length = small_loop_end - small_loop_start if small_loop_length < min_small_loop_stations or small_loop_length > max_small_loop_stations: return 1e9, cost = (big_loop_trains + small_loop_trains) * (stations - 1) * min_interval + average_boarding_time * passengers_per_train * (big_loop_trains + small_loop_trains) return cost, # 创建适应度和个体类 creator.create("FitnessMin", base.Fitness, weights=(-1.0,)) creator.create("Individual", list, fitness=creator.FitnessMin) # 注册初始化函数 toolbox = base.Toolbox() toolbox.register("big_loop_trains", random.randint, 1, 10) toolbox.register("small_loop_trains", random.randint, 1, 10) toolbox.register("small_loop_start", random.choice, start_end_stations) toolbox.register("small_loop_end", random.choice, start_end_stations) toolbox.register("individual", tools.initCycle, creator.Individual, (toolbox.big_loop_trains, toolbox.small_loop_trains, toolbox.small_loop_start, toolbox.small_loop_end), n=1) toolbox.register("population", tools.initRepeat, list, toolbox.individual) # 注册遗传算法操作 toolbox.register("mate", tools.cxTwoPoint) toolbox.register("mutate", tools.mutUniformInt, low=[1, 1, min(start_end_stations), min(start_end_stations)], up=[10, 10, max(start_end_stations), max(start_end_stations)], indpb=0.5) toolbox.register("select", tools.selBest) toolbox.register("evaluate", fitness_function) # 设置遗传算法参数 population_size = 100 crossover_probability = 0.8 mutation_probability = 0.2 num_generations = 100 # 初始化种群 population = toolbox.population(n=population_size) # 进化 for gen in range(num_generations): offspring = algorithms.varAnd(population, toolbox, cxpb=crossover_probability, mutpb=mutation_probability) fits = toolbox.map(toolbox.evaluate, offspring) for fit, ind in zip(fits, offspring): ind.fitness.values = fit population = toolbox.select(offspring, k=len(population)) # 找到最佳个体 best_individual = tools.selBest(population, k=1)[0] # 解码最佳个体 big_loop_trains, small_loop_trains, small_loop_start, small_loop_end = best_individual # 输出结果 print("Big Loop Trains:", big_loop_trains) print("Small Loop Trains:", small_loop_trains) print("Small Loop Start Station:", small_loop_start) print("Small Loop End Station:", small_loop_end)分析代码
04-22

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值