旅行商问题

旅行商问题 (Travelling Salesman problem)

This problem can be stated as- "Given n number of cities and a travelling salesman has to visit each city. Then we have to find the shortest tour so that the travelling salesman can visit each and every city only once."

可以说这个问题是: “给n个城市,一个旅行推销员必须访问每个城市。然后我们必须找到最短的游览,以便旅行推销员只能访问每个城市一次。”

This travelling salesman problem is one of the examples of NP-Complete problems.

这个旅行推销员问题是NP-完全问题的例子之一。

In the travelling salesman problem, we are given a complete undirected graph G = (V, E) that has a non-negative integer cost c (u, v) associated with each edge (u, v) belongs to E and we must find a tour of G with minimum cost.

在旅行商问题中,我们得到一个完整的无向图G =(V,E) ,该图具有与每个边(u,v)相关的非负整数成本c(u,v) 属于E ,我们必须找到以最低的费用游览G。

Let C (A) denotes the total cost of the edges in the subset A is the subset E.

C(A)表示子集A中边缘的总成本为子集E。

Travelling Salesman problem

Practically, it is always cheapest to go directly from a place w, going by way of any intermediate stop V can’t be expensive. Or say, cutting out an intermediate stop never increase the cost. This can be formalized that the cost function c satisfies the triangle inequality, if for all vertices u, v, w £ V .

实际上,直接从位置w出发总是最便宜的,通过任何中间停靠点V都不会很昂贵。 或者说,切出一个中间停止点永远不会增加成本。 如果对所有顶点u,v,w£V ,成本函数c可以满足三角形不等式,则可以形式化。

C (u, w) <= c (u, v) + c (v, w)

C(u,w)<= c(u,v)+ c(v,w)

This triangle inequality is natural one, and is many application it is automatically satisfied. In this problem, our tour starts from an initial state and completes after returning to original state passing through all intermediate states.

这个三角形不等式是自然的,并且在许多应用中都可以自动满足。 在这个问题中,我们的游览从初始状态开始,并在经过所有中间状态回到原始状态后完成。

If the graph has n vertices, i.e., |V| = n, then the solution space S is given by S = { 1, π, 1, π: is a permutation of (2, 3, ..., n)}.

如果图具有n个顶点,即| V | = n ,则解空间SS = {1,π,1,π:是(2,3,...,n)}的排列给出

Then |S| = (n-1)!

然后| S | =(n-1)!

The size of S can be reduced by restricting S so that (1, i1,...i2,i(n-1), 1) belongs to S if and only if (ij, ij + 1) £ E, 0 <= j <= n-1, and i0 = in = 1.

可以通过限制S来减小S的大小,使得(1,i1,... i2,i(n-1),1)属于S,当且仅当(ij,ij + 1)£E,0 < = j <= n-1i0 = in = 1

State space tree for this problem, for n = 4 and initial and final states 1.

这个问题的状态空间树,对于n = 4以及初始状态和最终状态1

Travelling Salesman problem

翻译自: https://www.includehelp.com/algorithms/travelling-salesman-problem.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/543972.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

清除元素中的子元素html_HTML中的元素简介

清除元素中的子元素htmlAn element is a fundamental component that is used to develop web pages. Generally an element as two components: a starting tag and a closing tag. The content is added in between the starting and closing tags. The ending tag is the sa…

分页 + 模糊查询竟然有坑?

不知道你有没有使用过Mysql的like语句&#xff0c;进行模糊查询&#xff1f;不知道你有没有将查询结果&#xff0c;进行分页处理&#xff1f;模糊查询&#xff0c;加上分页处理&#xff0c;会有意想不到的坑&#xff0c;不信我们继续往下看。我之前提供过一个品牌查询接口&…

导致事务@Transactional失效的5种场景!

作者 | 磊哥来源 | Java面试真题解析&#xff08;ID&#xff1a;aimianshi666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;一个程序中不可能没有事务&#xff0c;而 Spring 中&#xff0c;事务的实现方式分为两种&#xff1a;编程式事务和声…

操作系统 cpu调度_CPU调度| 操作系统

操作系统 cpu调度调度标准 (Scheduling Criteria) There are many criteria which have been suggested for comparing the CPU scheduling algorithms. The characteristics which are used for comparison and then used to determine the best algorithms, for this some of…

IOS中KVO模式的解析与应用

最近老翁在项目中多处用到了KVO&#xff0c;深感这种模式的好处。现总结如下&#xff1a; 一、概述 KVO,即&#xff1a;Key-Value Observing&#xff0c;它提供一种机制&#xff0c;当指定的对象的属性被修改后&#xff0c;则对象就会接受到通知。简单的说就是每次指定的被观察…

使用 lambda 实现超强的排序功能

我们在系统开发过程中&#xff0c;对数据排序是很常见的场景。一般来说&#xff0c;我们可以采用两种方式&#xff1a;借助存储系统&#xff08;SQL、NoSQL、NewSQL 都支持&#xff09;的排序功能&#xff0c;查询的结果即是排好序的结果查询结果为无序数据&#xff0c;在内存中…

java 的23种设计模式 之单身狗和隔壁老王的故事

2019独角兽企业重金招聘Python工程师标准>>> 觉得代码写的别扭了&#xff0c;回头翻翻java 的23种设计模式。today,额,这么晚了&#xff0c;困了。就弄个最简单的单例模式吧。单例模式&#xff1a;俗称单身狗 package singleton; public class SingleTon { private …

使用python学线性代数_二项式过程| 使用Python的线性代数

使用python学线性代数When we flip a coin, there are two possible outcomes as head or tail. Each outcome has a fixed probability of occurrence. In the case of fair coins, heads and tails each have the same probability of 1/2. In addition, there are cases in …

工作中常见的 6 种设计模式,你用过几种?

前言 哈喽&#xff0c;大家好。平时我们写代码呢&#xff0c;多数情况都是流水线式写代码&#xff0c;基本就可以实现业务逻辑了。如何在写代码中找到乐趣呢&#xff0c;我觉得&#xff0c;最好的方式就是&#xff1a;使用设计模式优化自己的业务代码。今天跟大家聊聊日常工作中…

c#抽象属性_C#中的抽象属性

c#抽象属性C&#xff03;抽象属性 (C# Abstract properties) An abstract may contain some abstract properties. That can be implemented in derived class. Here we use abstract and override keywords. 抽象可能包含一些抽象属性。 可以在派生类中实现 。 在这里&#xf…

这12款idea插件,能让你代码飞起来!

前言基本上每个程序员都会写代码&#xff0c;但写代码的速度不尽相同。为什么有些人&#xff0c;一天只能写几百行代码&#xff1f;而有些人&#xff0c;一天可以写几千行代码&#xff1f;有没有办法&#xff0c;可以提升开发效率&#xff0c;在相同的时间内&#xff0c;写出更…

node js 开发网站_使用Node JS开发网站

node js 开发网站You will have your own fully functional website running on "localhost" after going through this article. 阅读完本文后&#xff0c;您将在“ localhost”上运行自己的功能齐全的网站 。 Basic knowledge of JavaScript and HTML is a prereq…

hdu 1166 敌兵布阵

Problem DescriptionC国的死对头A国这段时间正在进行军事演习&#xff0c;所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段&#xff0c;所以每个工兵营地…

Java:LocalDate / LocalDateTime加减时间

在线API参考&#xff1a;LocalTime (Java Platform SE 8 ) 方法介绍 方法1方法1说明plusYears(long years) minusYears(long years) 返回增加/减少了年数的副本plusMonths(long months) minusMonths(long months)返回增加/减少了月数的副本plusWeeks(long weeks) minusWeeks(…

集合 List 分片的 5 种实现

作者 | 磊哥来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;前些天在实现 MyBatis 批量插入时遇到了一个问题&#xff0c;当批量插入的数据量比较大时&#xff0c;会导致程序执行报错&a…

消失的死锁

问题描述 如果java层面发生了死锁&#xff0c;当我们使用jstack命令的时候其实是可以将死锁的信息给dump出来的&#xff0c;在dump结果的最后会有类似Found one Java-level deadlock:的关键字&#xff0c;接着会把发生死锁的线程的堆栈及对应的同步锁给打印出来&#xff0c;这次…

ruby 新建对象_Ruby中的面向对象编程

ruby 新建对象Before getting into understanding how Object-oriented programming is implemented in Ruby, let us first understand what Object Oriented means. 在了解如何在Ruby中实现面向对象的编程之前&#xff0c;让我们首先了解面向对象的含义。 Object-oriented p…

使用它给 ​xxl-job 添加任务,太爽了

xxl-job是一款非常优秀的任务调度中间件&#xff0c;轻量级、使用简单、支持分布式等优点&#xff0c;让它广泛应用在我们的项目中&#xff0c;解决了不少定时任务的调度问题。我们都知道&#xff0c;在使用过程中需要先到xxl-job的任务调度中心页面上&#xff0c;配置执行器ex…

dubboSPI机制浅谈

2019独角兽企业重金招聘Python工程师标准>>> &#xfeff;&#xfeff;&#xfeff;本文重点讲述SPI机制&#xff0c;从jdk和dubbo 1、jdk spi机制 2、dubbo spi实现 首先spi是什么&#xff1f; SPI是为某个接口寻找服务实现的机制。为了实现在模块装配的时候能不在…