简单易用的python包,用于快速实验经典的旅行推销员问题。

pytspsolver的Python项目详细描述


Pytssolver

简单易用的软件包,用于对经典的旅行推销员问题进行快速实验。包含各种优化算法、酷的可视化工具和插件架构的实现。

Build StatusSay Thanks!MIT license

安装

> pip install pytspsolver

用法

此包旨在提供直观的Python接口;允许您以最小的代码和最大的灵活性进行实验。

以下是如何启动旅行推销员问题实验的方法:

frompytspsolver.entitiesimportTSProblemfrompytspsolver.experimentsimportExperimentfrompytspsolver.solversimport*frompytspsolver.utilitiesimportcreate_random_problem,get_tsp_lib_problem,Visualizerimportmatplotlib.pyplotasplt# Create a few tsp problems (represented as an adjacency matrix)problems=[create_random_problem("UniqueProblemName"+str(i),i)foriinrange(3,12)]# Pass in the location of TSPLIB95 dataset filetsp_prob=get_tsp_lib_problem("gr17.tsp")# Create a new Experimentexperiment=Experiment()# Add the problems to the experiment (single or list of problems)experiment.add_problem(tsp_prob)experiment.add_problems(problems)# Add solvers to use in the experimentexperiment.add_solver(ExhaustiveSearch(time_limit=50))experiment.add_solver(GreedySearch(time_limit=100))# Run the experiment desired number of timesresults=experiment.run(epoch=10)# Set up Visualizer with experiment resultsvisualizer=Visualizer(results)# Show visualizations - automatically averages the results from different epochsvisualizer.plot_n_vs_time_all(plt)# Note: the visualizer has various plots available, they can be called in a similar fashion.

它带有一个插件架构,因此非常可定制。

其他示例

使用jupyter笔记本实现了一些示例;可在examples文件夹中找到。通过从当前conda环境启动jupyter笔记本,可以访问这些笔记本。

> jupyter notebook

启动jupyter notebook时,请确保您处于正确的环境中,否则,jupyter notebook内核将指向另一个未安装pytspsolver包的python版本。

贡献

鼓励贡献和拉动请求!

如果您发现任何问题或希望添加新功能,请在编写代码和提交请求之前在github问题部分进行讨论。

贡献者

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JAXB封送字符串,具有xml值,且不转义该值   java ModelMapper转换器不工作   java像HH000412或HCANN000001这样的前缀是什么意思?   验证日期输入修复java。lang.numberformatexception错误   当表具有外键时,java Telosys代码生成失败   如何使所有派生类一起只能实例化一个实例的单例抽象基类?(爪哇)   java如何在非静态服务类中使用广播接收器   java nutch爬虫相对URL问题   使用Jboss DMR下载/保存java附件   Rest模板:无法提取响应:当我们得到xml响应时,没有找到适合响应类型的HttpMessageConverter,没有绑定到JAVA对象   java如何编写可扩展窗格/面板/卡的代码   java是在ITreeViewerListener的treeExpanded()之前调用ContentProvider的getChildren()吗?   java将JComponent添加到小程序窗格   java混淆:使用简单逻辑的Flames程序