代码拉取完成,页面将自动刷新
import codecs
import pathlib
import os
import sys
import tempfile
import time
import traceback
from model.Configuration import Configuration
# from algorithm.GeneticAlgorithm import GeneticAlgorithm
# from algorithm.APNsgaIII import APNsgaIII
from algorithm.Cso import Cso
# from algorithm.GaQpso import GaQpso
# from algorithm.Amga2 import Amga2
from HtmlOutput import HtmlOutput
def main(file_name):
start_time = int(round(time.time() * 1000))
configuration = Configuration()
target_file = str(pathlib.Path().absolute()) + file_name
configuration.parseFile(target_file)
alg = Cso(configuration)
# alg = GaQpso(configuration)
print("GaSchedule Version 1.2.5 . Making a Class Schedule Using", alg, ".\n")
print("Copyright (C) 2022 - 2024 Miller Cy Chan.\n")
alg.run()
html_result = HtmlOutput.getResult(alg.result)
temp_file_path = tempfile.gettempdir() + file_name.replace(".json", ".htm")
writer = codecs.open(temp_file_path, "w", "utf-8")
writer.write(html_result)
writer.close()
seconds = (int(round(time.time() * 1000)) - start_time) / 1000.0
print("\nCompleted in {} secs.\n".format(seconds))
os.startfile(temp_file_path)
if __name__ == "__main__":
file_name = "/GaSchedule.json"
if len(sys.argv) > 1:
file_name = sys.argv[1]
try:
main(file_name)
except:
traceback.print_exc()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。