52 Things: Number 4: The Complexity Class P

news/发布时间2024/8/25 17:11:27

52 Things: Number 4: The Complexity Class P

52 件事: 数字 4:复杂度等级 P

This is the fourth blog post talking about '52 Things Every PhD Student Should Know' to do Cryptography, and the first on the topic of Theoretical Computer Science. In this post, I've been asked to define the complexity class P. Having recently joined the Cryptography group at Bristol as a Mathematician, I knew very little theoretical computer science when I first started my PhD and I'm sure there will be plenty of others in my situation, so this blog will start right from the beginning and you can skip over parts you know already. First, we'll give an overview of what complexity means and why it matters, then we'll define Turing machines, and finally arrive at the complexity class P, concluding with an example.
这是第四篇关于“每个博士生都应该知道的 52 件事”的博客文章,也是第一篇关于理论计算机科学主题的文章。在这篇文章中,我被要求定义复杂度类 P。我最近以数学家的身份加入了布里斯托尔大学的密码学小组,当我刚开始攻读博士学位时,我对理论计算机科学知之甚少,我相信还有很多其他人和我一样,所以这个博客将从头开始,你可以跳过你已经知道的部分。首先,我们将概述复杂性的含义以及它的重要性,然后我们将定义图灵机,最后得出复杂性等级 P,最后以一个示例结束。
 
Most of the content of this post is a reworking of parts of Introduction to the Theory of Computation by Michael Sipser [1], which I have found hugely helpful.
这篇文章的大部分内容是对 Michael Sipser [1] 的《计算理论导论》部分内容的修改,我发现它非常有帮助。

Section 1: Complexity and Big O Notation

第 1 部分:复杂性和大 O 符号
We want to know how difficult a given task is for a computer to do in order to design efficient programs. The trouble is that the processing power of a computer varies massively depending on the hardware (e.g. see last week's '52 Things' blog). So we want a measure of the difficulty of a task that doesn't depend on the specific details of the machine performing the task. One way to do this is to bound the number of operations that a certain model of a computer would take to do it. This is called (time) complexity theory.
我们想知道计算机为了设计有效的程序而完成给定的任务有多困难。问题在于,计算机的处理能力因硬件而异(例如,请参阅上周的“52 Things”博客)。因此,我们想要一个任务难度的度量,它不依赖于执行任务的机器的具体细节。一种方法是限制特定型号的计算机执行此操作所需的操作数。这就是所谓的(时间)复杂性理论。


Typically, though, the number of operations required will depend on the input to the task and may vary even with inputs of the same length. As a pertinent example, say we design a computer program which tells you whether or not an integer you input is prime. If we give as input the number 256, the program will probably output 'not prime' sooner than if we had given it the number 323 (even though they both have length 9 when written as binary integers, for example), since the first integer has a very small prime factor (2) and the second has larger factors (17 and 19). Therefore we usually opt for a worst-case analysis where we record the longest running time of all inputs of a particular length. So we obtain an algebraic expression <span id="MathJax-Span-2" class="mrow"><span id="MathJax-Span-3" class="mi">t<span id="MathJax-Span-4" class="mo">(<span id="MathJax-Span-5" class="mi">n<span id="MathJax-Span-6" class="mo">) that reflects the longest running time of all inputs of length <span id="MathJax-Span-8" class="mrow"><span id="MathJax-Span-9" class="mi">n.
但是,通常情况下,所需的操作数将取决于任务的输入,并且即使输入长度相同,操作数也可能有所不同。举个相关的例子,假设我们设计了一个计算机程序,它告诉你输入的整数是否是素数。如果我们给出数字 256 作为输入,程序可能会比我们给它数字 323 更快地输出“非素数”(即使它们在写成二进制整数时都有 9 的长度),因为第一个整数有一个非常小的质因数 (2),第二个有较大的因数(17 和 19)。因此,我们通常选择最坏情况分析,即记录特定长度的所有输入的最长运行时间。因此,我们得到一个代数表达 <span id="MathJax-Span-2" class="mrow"><span id="MathJax-Span-3" class="mi">t<span id="MathJax-Span-4" class="mo">(<span id="MathJax-Span-5" class="mi">n<span id="MathJax-Span-6" class="mo">)
 式,它反映了所有长度 <span id="MathJax-Span-8" class="mrow"><span id="MathJax-Span-9" class="mi">n 输入的最长运行时间。
 
Furthermore, when the input length <span id="MathJax-Span-11" class="mrow"><span id="MathJax-Span-12" class="mi">n becomes very large, we can neglect all but the most dominant term in the expression and also ignore any constant factors. This is called asymptotic analysis; we assume <span id="MathJax-Span-14" class="mrow"><span id="MathJax-Span-15" class="mi">n is enormous and ask roughly how many steps the model of computation will take to 'finish' when given the worst possible input of length <span id="MathJax-Span-17" class="mrow"><span id="MathJax-Span-18" class="mi">n, writing our answer in the form <span id="MathJax-Span-20" class="mrow"><span id="MathJax-Span-21" class="texatom"><span id="MathJax-Span-22" class="mrow"><span id="MathJax-Span-23" class="mi">O<span id="MathJax-Span-24" class="mrow"><span id="MathJax-Span-25" class="mo">(<span id="MathJax-Span-26" class="mrow"><span id="MathJax-Span-27" class="mi">t<span id="MathJax-Span-28" class="mrow"><span id="MathJax-Span-29" class="mo">(<span id="MathJax-Span-30" class="mi">n<span id="MathJax-Span-31" class="mo">)<span id="MathJax-Span-32" class="mo">). For example, if we find that our process takes <span id="MathJax-Span-34" class="mrow"><span id="MathJax-Span-35" class="mn">6<span id="MathJax-Span-36" class="msubsup"><span id="MathJax-Span-37" class="mi">n<span id="MathJax-Span-38" class="mn">3<span id="MathJax-Span-39" class="mo">&ndash;<span id="MathJax-Span-40" class="msubsup"><span id="MathJax-Span-41" class="mi">n<span id="MathJax-Span-42" class="mn">2<span id="MathJax-Span-43" class="mo">+<span id="MathJax-Span-44" class="mn">1 steps, we write that it is <span id="MathJax-Span-46" class="mrow"><span id="MathJax-Span-47" class="texatom"><span id="MathJax-Span-48" class="mrow"><span id="MathJax-Span-49" class="mi">O<span id="MathJax-Span-50" class="mrow"><span id="MathJax-Span-51" class="mo">(<span id="MathJax-Span-52" class="msubsup"><span id="MathJax-Span-53" class="mi">n<span id="MathJax-Span-54" class="texatom"><span id="MathJax-Span-55" class="mrow"><span id="MathJax-Span-56" class="mn">3<span id="MathJax-Span-57" class="mo">), since all other terms can be ignored for very large <span id="MathJax-Span-59" class="mrow"><span id="MathJax-Span-60" class="mi">n.
此外,当输入长度 <span id="MathJax-Span-11" class="mrow"><span id="MathJax-Span-12" class="mi">n 变得非常大时,我们可以忽略表达式中除最主要项之外的所有项,也可以忽略任何常数因子。这称为渐近分析;我们假设 <span id="MathJax-Span-14" class="mrow"><span id="MathJax-Span-15" class="mi">n 是巨大的,并粗略地询问计算模型在给定最差的长度 <span id="MathJax-Span-17" class="mrow"><span id="MathJax-Span-18" class="mi">n
 输入时需要多少步才能“完成”,以形式 <span id="MathJax-Span-20" class="mrow"><span id="MathJax-Span-21" class="texatom"><span id="MathJax-Span-22" class="mrow"><span id="MathJax-Span-23" class="mi">O<span id="MathJax-Span-24" class="mrow"><span id="MathJax-Span-25" class="mo">(<span id="MathJax-Span-26" class="mrow"><span id="MathJax-Span-27" class="mi">t<span id="MathJax-Span-28" class="mrow"><span id="MathJax-Span-29" class="mo">(<span id="MathJax-Span-30" class="mi">n<span id="MathJax-Span-31" class="mo">)<span id="MathJax-Span-32" class="mo">) 写下我们的答案。例如,如果我们发现我们的过程采取了 <span id="MathJax-Span-34" class="mrow"><span id="MathJax-Span-35" class="mn">6<span id="MathJax-Span-36" class="msubsup"><span id="MathJax-Span-37" class="mi">n<span id="MathJax-Span-38" class="mn">3<span id="MathJax-Span-39" class="mo">&ndash;<span id="MathJax-Span-40" class="msubsup"><span id="MathJax-Span-41" class="mi">n<span id="MathJax-Span-42" class="mn">2<span id="MathJax-Span-43" class="mo">+<span id="MathJax-Span-44" class="mn">1 步骤,我们写它是 <span id="MathJax-Span-46" class="mrow"><span id="MathJax-Span-47" class="texatom"><span id="MathJax-Span-48" class="mrow"><span id="MathJax-Span-49" class="mi">O<span id="MathJax-Span-50" class="mrow"><span id="MathJax-Span-51" class="mo">(<span id="MathJax-Span-52" class="msubsup"><span id="MathJax-Span-53" class="mi">n<span id="MathJax-Span-54" class="texatom"><span id="MathJax-Span-55" class="mrow"><span id="MathJax-Span-56" class="mn">3<span id="MathJax-Span-57" class="mo">) ,因为对于非常大 <span id="MathJax-Span-59" class="mrow"><span id="MathJax-Span-60" class="mi">n 的所有其他项都可以忽略。

Section 2: Turing Machines

第 2 部分:图灵机
Now we give the model that is most often used in the kind of calculations performed in Section 1. First, recall that an alphabet is a non-empty finite set and a string is a finite sequence of elements (symbols) from an alphabet. A language is simply a set of strings.
现在我们给出在第 1 节中执行的计算类型中最常用的模型。首先,回想一下,字母表是一个非空的有限集合,而字符串是字母表中元素(符号)的有限序列。语言只是一组字符串。
 
Turing machine models what real computers can do. Its 'memory' is an infinitely long tape. At any time, each square of the tape is either blank or contains a symbol from some specified alphabet. The machine has a tape head that can move left or right along the tape, one square at a time, and read from and write to that square. At first, the tape is all blank except for the leftmost <span id="MathJax-Span-62" class="mrow"><span id="MathJax-Span-63" class="mi">n squares which constitute the input (none of which can be blank so that it is clear where the input ends). The tape head starts at the leftmost square, reads the first input symbol and then decides what to do next according to a transition function. The transition function depends on what it reads at the square it is currently on and the state that the machine is currently in (like a record of what it has done so far) and returns
图灵机模拟真实计算机可以做什么。它的“记忆”是一盘无限长的磁带。在任何时候,磁带的每个方块要么是空白的,要么包含来自某个指定字母表的符号。机器有一个磁带头,可以沿着磁带向左或向右移动,一次一个方块,并读取和写入该方块。起初,磁带都是空白的,除了构成输入的最 <span id="MathJax-Span-62" class="mrow"><span id="MathJax-Span-63" class="mi">n 左边的方块(它们都不能是空白的,以便清楚地知道输入的结束位置)。磁带头从最左边的方格开始,读取第一个输入符号,然后根据转换函数决定下一步要做什么。转换函数取决于它在当前所在的方格上读取的内容以及机器当前所处的状态(例如到目前为止它所做的事情的记录)并返回
  1. a new state 一个新状态
  2. another symbol to write to the square it is on (though this symbol might be the same as what was already written there)
    另一个要写到它所在的方块的符号(尽管这个符号可能与那里已经写的符号相同)
  3. a direction to move in: left or right. 
    向内移动的方向:向左或向右。
The machine will continue to move one square at a time, read a symbol, evaluate the transition function, write a symbol and move again, until its state becomes some specified accept state or reject state.
机器将继续一次移动一个方格,读取一个符号,评估转换函数,写入一个符号并再次移动,直到其状态变成某个指定的接受状态或拒绝状态。
 
If the machine ends up in the accept state, we say it accepts its input. Similarly it may reject its input. In either case we say the machine halts on its input. But note that it may enter a loop without accepting or rejecting i.e. it may never halt. If a Turing machine accepts every string in some language and rejects all other strings, then we say the machine decides that language. We can think of this as the machine testing whether or not the input string is a member of the language. Given a language, if there is a Turing machine that decides it, we say the language is decidable.
如果机器最终处于接受状态,我们说它接受其输入。同样,它可能会拒绝其输入。在任何一种情况下,我们都说机器在其输入时停止。但请注意,它可能会在不接受或拒绝的情况下进入循环,即它可能永远不会停止。如果图灵机接受某种语言的每个字符串并拒绝所有其他字符串,那么我们说机器决定了该语言。我们可以将其视为机器测试输入字符串是否是语言的成员。给定一种语言,如果有一个图灵机来决定它,我们说该语言是可判定的。
 
The power of this model comes from the fact that a Turing machine can do everything that a real computer can do (this is called the Church-Turing thesis [2]). We define the time complexity class <span id="MathJax-Span-65" class="mrow"><span id="MathJax-Span-66" class="texatom"><span id="MathJax-Span-67" class="mrow"><span id="MathJax-Span-68" class="mi">T<span id="MathJax-Span-69" class="mi">I<span id="MathJax-Span-70" class="mi">M<span id="MathJax-Span-71" class="mi">E<span id="MathJax-Span-72" class="mrow"><span id="MathJax-Span-73" class="mo">(<span id="MathJax-Span-74" class="mrow"><span id="MathJax-Span-75" class="mi">t<span id="MathJax-Span-76" class="mrow"><span id="MathJax-Span-77" class="mo">(<span id="MathJax-Span-78" class="mi">n<span id="MathJax-Span-79" class="mo">)<span id="MathJax-Span-80" class="mo">) to be the collection of all languages that are decidable by an <span id="MathJax-Span-82" class="mrow"><span id="MathJax-Span-83" class="texatom"><span id="MathJax-Span-84" class="mrow"><span id="MathJax-Span-85" class="mi">O<span id="MathJax-Span-86" class="mrow"><span id="MathJax-Span-87" class="mo">(<span id="MathJax-Span-88" class="mrow"><span id="MathJax-Span-89" class="mi">t<span id="MathJax-Span-90" class="mrow"><span id="MathJax-Span-91" class="mo">(<span id="MathJax-Span-92" class="mi">n<span id="MathJax-Span-93" class="mo">)<span id="MathJax-Span-94" class="mo">) time Turing machine, then we turn computational problems into questions about language membership (is an input string a member of a certain language? e.g. does this string representing an integer belong to the language of strings representing prime integers?) and can partition computational problems into time complexity classes.
这个模型的力量来自于这样一个事实,即图灵机可以做真实计算机可以做的所有事情(这被称为丘奇-图灵论文[2])。我们将时间复杂度类 <span id="MathJax-Span-65" class="mrow"><span id="MathJax-Span-66" class="texatom"><span id="MathJax-Span-67" class="mrow"><span id="MathJax-Span-68" class="mi">T<span id="MathJax-Span-69" class="mi">I<span id="MathJax-Span-70" class="mi">M<span id="MathJax-Span-71" class="mi">E<span id="MathJax-Span-72" class="mrow"><span id="MathJax-Span-73" class="mo">(<span id="MathJax-Span-74" class="mrow"><span id="MathJax-Span-75" class="mi">t<span id="MathJax-Span-76" class="mrow"><span id="MathJax-Span-77" class="mo">(<span id="MathJax-Span-78" class="mi">n<span id="MathJax-Span-79" class="mo">)<span id="MathJax-Span-80" class="mo">)
 定义为 <span id="MathJax-Span-82" class="mrow"><span id="MathJax-Span-83" class="texatom"><span id="MathJax-Span-84" class="mrow"><span id="MathJax-Span-85" class="mi">O<span id="MathJax-Span-86" class="mrow"><span id="MathJax-Span-87" class="mo">(<span id="MathJax-Span-88" class="mrow"><span id="MathJax-Span-89" class="mi">t<span id="MathJax-Span-90" class="mrow"><span id="MathJax-Span-91" class="mo">(<span id="MathJax-Span-92" class="mi">n<span id="MathJax-Span-93" class="mo">)<span id="MathJax-Span-94" class="mo">) 时间图灵机可判定的所有语言的集合,然后我们将计算问题转换为有关语言隶属度的问题(输入字符串是某种语言的成员吗?例如,这个表示整数的字符串是否属于表示质整数的字符串的语言?),并且可以将计算问题划分为时间复杂度类。

Section 3: The Complexity Class P

第 3 部分:复杂度等级 P
Finally, we arrive at the purpose of this blog! If <span id="MathJax-Span-96" class="mrow"><span id="MathJax-Span-97" class="mi">t<span id="MathJax-Span-98" class="mo">(<span id="MathJax-Span-99" class="mi">n<span id="MathJax-Span-100" class="mo">)<span id="MathJax-Span-101" class="mo">=<span id="MathJax-Span-102" class="msubsup"><span id="MathJax-Span-103" class="mi">n<span id="MathJax-Span-104" class="mi">k for some <span id="MathJax-Span-106" class="mrow"><span id="MathJax-Span-107" class="mi">k<span id="MathJax-Span-108" class="mo">&gt;<span id="MathJax-Span-109" class="mn">0 then <span id="MathJax-Span-111" class="mrow"><span id="MathJax-Span-112" class="texatom"><span id="MathJax-Span-113" class="mrow"><span id="MathJax-Span-114" class="mi">O<span id="MathJax-Span-115" class="mrow"><span id="MathJax-Span-116" class="mo">(<span id="MathJax-Span-117" class="mrow"><span id="MathJax-Span-118" class="mi">t<span id="MathJax-Span-119" class="mrow"><span id="MathJax-Span-120" class="mo">(<span id="MathJax-Span-121" class="mi">n<span id="MathJax-Span-122" class="mo">)<span id="MathJax-Span-123" class="mo">) is called polynomial time. The complexity class P is the class of all languages that are decidable in polynomial time by a Turing machine. Since <span id="MathJax-Span-125" class="mrow"><span id="MathJax-Span-126" class="mi">k could be very large, such Turing machines are not necessarily all practical, (let alone 'fast'!), but this class is a rough model for what can be realistically achieved by a computer. Note that the class P is fundamentally different to those languages where <span id="MathJax-Span-128" class="mrow"><span id="MathJax-Span-129" class="mi">t<span id="MathJax-Span-130" class="mo">(<span id="MathJax-Span-131" class="mi">n<span id="MathJax-Span-132" class="mo">) has <span id="MathJax-Span-134" class="mrow"><span id="MathJax-Span-135" class="mi">n in an exponent, such as <span id="MathJax-Span-137" class="mrow"><span id="MathJax-Span-138" class="msubsup"><span id="MathJax-Span-139" class="mn">2<span id="MathJax-Span-140" class="mi">n, which grow much, much faster as <span id="MathJax-Span-142" class="mrow"><span id="MathJax-Span-143" class="mi">n increases – so fast that even if you have a decider for some language, you may find that the universe ends before it halts on your input!
最后,我们到达了这个博客的目的!如果 <span id="MathJax-Span-96" class="mrow"><span id="MathJax-Span-97" class="mi">t<span id="MathJax-Span-98" class="mo">(<span id="MathJax-Span-99" class="mi">n<span id="MathJax-Span-100" class="mo">)<span id="MathJax-Span-101" class="mo">=<span id="MathJax-Span-102" class="msubsup"><span id="MathJax-Span-103" class="mi">n<span id="MathJax-Span-104" class="mi">k
 对于某些 <span id="MathJax-Span-106" class="mrow"><span id="MathJax-Span-107" class="mi">k<span id="MathJax-Span-108" class="mo">&gt;<span id="MathJax-Span-109" class="mn">0 人来说,则 <span id="MathJax-Span-111" class="mrow"><span id="MathJax-Span-112" class="texatom"><span id="MathJax-Span-113" class="mrow"><span id="MathJax-Span-114" class="mi">O<span id="MathJax-Span-115" class="mrow"><span id="MathJax-Span-116" class="mo">(<span id="MathJax-Span-117" class="mrow"><span id="MathJax-Span-118" class="mi">t<span id="MathJax-Span-119" class="mrow"><span id="MathJax-Span-120" class="mo">(<span id="MathJax-Span-121" class="mi">n<span id="MathJax-Span-122" class="mo">)<span id="MathJax-Span-123" class="mo">) 称为多项式时间。复杂度类 P 是图灵机在多项式时间内可判定的所有语言的类。由于 <span id="MathJax-Span-125" class="mrow"><span id="MathJax-Span-126" class="mi">k 图灵机可能非常大,因此不一定都是实用的(更不用说“快速”了!),但这个类是计算机可以实际实现的粗略模型。请注意,类 P 与那些 <span id="MathJax-Span-134" class="mrow"><span id="MathJax-Span-135" class="mi">n 指数中有 的语言 <span id="MathJax-Span-128" class="mrow"><span id="MathJax-Span-129" class="mi">t<span id="MathJax-Span-130" class="mo">(<span id="MathJax-Span-131" class="mi">n<span id="MathJax-Span-132" class="mo">) 有根本的不同,比如 <span id="MathJax-Span-137" class="mrow"><span id="MathJax-Span-138" class="msubsup"><span id="MathJax-Span-139" class="mn">2<span id="MathJax-Span-140" class="mi">n ,随着 <span id="MathJax-Span-142" class="mrow"><span id="MathJax-Span-143" class="mi">n 指数的增加,它们的增长速度要快得多——如此之快,以至于即使你对某种语言有一个决定因素,你也可能会发现宇宙在它停止你的输入之前就结束了!
 
We conclude with an example of a polynomial time problem. Suppose you have a directed graph (a set of nodes and edges where there is at most one edge between any pair of nodes and each edge has an arrow indicating a direction). Then if we encode the graph and the two nodes as a single string, we can form a language consisting of those strings representing a graph and two nodes such that it is possible to follow the edges from the first node and eventually arrive at the second. So a decider for this language will effectively answer the question of whether there is a path from the first node A to the second B, called the path problem, by accepting or rejecting the graph and nodes you input. We give a decider for this language and show that it decides in polynomial time. 
我们以多项式时间问题为例结束。假设您有一个有向图(一组节点和边,其中任意一对节点之间最多有一个边,并且每条边都有一个指示方向的箭头)。然后,如果我们将图形和两个节点编码为单个字符串,我们可以形成一种由代表图形和两个节点的字符串组成的语言,这样就可以从第一个节点开始跟踪边缘并最终到达第二个节点。因此,这种语言的判定器将通过接受或拒绝您输入的图形和节点来有效地回答从第一个节点 A 到第二个 B 是否存在路径的问题,称为路径问题。我们给出了这种语言的决定性语言,并表明它在多项式时间内决定。
  1. First put a mark on A. 
    首先在 A 上做一个标记。
  2. Scan all the edges of the graph. If you find an edge from a marked node to an unmarked node, mark the unmarked node.
    扫描图形的所有边缘。如果找到从已标记节点到未标记节点的边,请标记未标记的节点。
  3. Repeat the above until you mark no new nodes.
    重复上述操作,直到没有标记新节点。
  4. If B is marked, accept. Otherwise, reject. 
    如果标记为 B,则接受。否则,请拒绝。
This process successively marks the nodes that are reachable from A by a path of length 1, then a path of length 2, and so on. So it is clear that a Turing machine implementing the above is a decider for our language. Now we consider the time complexity of this algorithm. If we couldn't do steps 1 and 4 in polynomial time, our machine would be terrible! So we focus on steps 2 and 3. Step 2 involves searching the input and placing a mark on one square, which is clearly polynomial time in the size of the input. Step 3 repeats step 2 no more times than the number of nodes, which is necessarily less than the size of the input (since the input must encode all the nodes of the graph) and is hence polynomial (in particular, linear) in the size of the input. Therefore the whole algorithm is polynomial time and so we say the path problem is in P.
此过程通过长度为 1 的路径,然后通过长度为 2 的路径依此类推,依此类推,标记可从 A 访问的节点。因此,很明显,实现上述内容的图灵机是我们语言的决定因素。现在我们考虑这个算法的时间复杂度。如果我们不能在多项式时间内完成步骤 1 和 4,我们的机器会很糟糕!因此,我们专注于第 2 步和第 3 步。第 2 步涉及搜索输入并在一个方块上放置标记,这显然是输入大小的多项式时间。步骤 3 重复步骤 2 的次数不超过节点数,节点数必然小于输入的大小(因为输入必须对图形的所有节点进行编码),因此输入的大小是多项式(特别是线性)。因此,整个算法是多项式时间,因此我们说路径问题在 P 中。

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

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

相关文章

linux下tcpdump的抓包

tcpdump****中最常见的几个参数 首先查看网卡名称 ifconfig: 最常用的配置和查看网络接口信息的命令 -i 指定要抓取数据包的网卡名称 tcpdump -i eth0 -c 10 # 抓取eth0网卡的数据包 ,不设数量10,会一直监听下去 -w 把抓取到的数据存放到文件中使用wireshark查看,保存在roo…

数据结构之图(java语言版)

图是比树更复杂的结构,树是一对多的关系,图是多对多的关系。一、基本概念 1、定义:图(graph)是由一些点(vertex)和这些点之间的连线(edge)所组成的;其中,点通常被成为"顶点(vertex)",而点与点之间的连线则被成为"边或弧"(edege)。通常记为,G=(V,E)。…

在远程windows上调试Cmake项目 C++

记录一下CMake项目MSVC编译器远程调试方法 参考资料 教程:在远程 Windows 计算机上调试 CMake 项目 | Microsoft Learn 1.使用VS打开cmake项目 2.右键main.cpp文件,添加调试配置 选择C++ 3.会打开一个 launch.vs.json文件 配置一下 注意:远程机器那里写需要运行的机器号 …

mysql查询某条记录所在的行号

有时候我们想知道某条记录在表中的多少行,这样我们就可以开始继续上一次的任务了。 下面是SQL,可以直接执行,把表名改成自己真实的表名就好了,还得注意下子查询的排序,也得按自己真实需求来即可:SET @row_number = 0; SELECT index_position FROM ( SELECT author_id, @r…

echarts X轴类目名太长时隐藏,hover时显示全部

echarts图表X轴 在柱状图中,X轴类目名如果数据太长; echarts会默认进行隐藏部分字段; 如果我们想让每一个类目名都显示出来,需要进行额外的处理X轴类目名太长时,默认只显示一部分类目名 <!DOCTYPE html> <html lang="en"> <head><meta char…

IREE HLO与MLIR编译器

IREE HLO与MLIR编译器 MLIR(Multi-Level Intermediate Representation)是谷歌团队开发的开源编译器框架,提供了一套灵活的软件基础设施,以便规范中间表达式(IR)及其相互之间的转换,建立了一个友好的编译器开发平台,一些比较好的对MLIR框架解读可以参考。IREE项目也是谷歌…

【EF Core】Code first

简介 前期环境 Visual Studio 2022 .net framework 4.7.2 Sqlite3 Navicat 15 CodeFirst的三种方式使用新数据库 使用现有数据库 迁移一、使用新数据库的CodeFirst 查看:https://learn.microsoft.com/zh-cn/ef/ef6/modeling/code-first/workflows/existing-database 查看:htt…

【Azure Storage Account /ADLS】可用性指标降低的警告和是否会发生故障转移

问题描述使用存储位于Azure的存储账号和ADLS Gen2,为存储账号的可用性配置了告警。 想了解: 1) 可用性报警对业务依赖并使用存储账号的业务程序是否会产生影响,比如是否会导致依赖存储账号的程序不能正常工作,报错等 2) 当可用性降低后,存储账号是否会产生故障转移?或者是…

蓝桥杯STM32G431RBT6-各个外设的配置过程

LED,按键配置LED点亮,按键采集按键值前期准备:通过Cubemx生成一个源文件方便后续直接使用。 源文件准备完毕以后开始进行按键和LED的配置 LED  对比芯片引脚连接图可以知道8个LED分别连接在GPIOC的如下8个引脚中  Cubemx中对该8个引脚进行配置,分别配置为推挽输出模式…

高级项目管理

4、六西格玛认为业务流程改进遵循5步循环改进法,即 DMAIC模式:定义、度量、分析、改进、控制。(1)定义(Define):识别需要改进的产品或过程,确定改进项目所需的资源。(2)度量(Measure):定义缺陷,收集产品或过程的表现作为工作基准,建立改进目标。(3)分析(Analy…

python爬虫—学习笔记-3

python爬虫—学习笔记-3 ps:因为本人近一个月住院,文章为队友所著。 此次学习内容为如何搭建服务器 1.打开pycharm,创建目录server在设置中的Python解释器中安装Flask2.在创建的server1中输入本节课所学代码在网页中输入ip 端口号 子目录 本机访问127.0.0.1:5000/子目录 外…

python 使用waitress替代flask自带的web服务器

首席引入依赖安装waitrss pip intsll waitress然后在flask程序内引入依赖 使用server()函数代替app.run()函数 启动时,直接python xxx.py即可from waitress import serve from flask import Flask app = Flask(__name__)@app.route(/) def hello_world(): return Hello Wo…

sy3

一、任务详情 密码引擎API的主要标准和规范包括: 1 微软的Crypto API 2 RAS公司的PKCS#11标准 3 中国商用密码标准:GMT 0016-2012 智能密码钥匙密码应用接口规范,GMT 0018-2012密码设备应用接口规范等 研究以上API接口,总结他们的异同,并以龙脉GM3000Key为例,写出调用不同…

发布一个自己的composer包

首先我们创建一个空的目录,并且运行以下命令初始化一个空白的composer包 composer init可以在命令窗口看到有返回提示; 需要输入包名 This command will guide you through creating your composer.json config.` Package name (<vendor>/<name>) :我这里写的是c…

读所罗门的密码笔记15_数据透明度

读所罗门的密码笔记15_数据透明度1. 数据透明度与控制权 1.1. 作为人类,我们会带有偏见,而且往往不知道自己在智力和情感上的盲区 1.2. 精心制作的人工智能机器,即使有自己的缺点,也能帮助我们做出更客观的决定,为提升我们的生活质量和改善社区的生态环境做出贡献 1.3. 美…

QAT量化感知训练

QAT量化感知训练 基本原理 相比训练后量化因为其不是全局最优而导致的精度损失,QAT量化感知训练能做到基于loss优化的全局最优,而尽可能的降低量化精度损失,其基本原理是:在fp32模型训练中就提前引入推理时量化导致的权重与激活的误差,用任务loss在训练集上来优化可学习的…

树状数组快速入门

树状数组、 Fenwick Tree 或 Binary Indexed Tree ,通常用缩写 BIT 代表。 是一种 “一种基于二进制 lowbit ,用于维护(加法、位运算、max、gcd 的)前缀和的树形数组” 。 可以叫做 一个树状数组 或 一棵 Fenwick Tree 。 重要性质:同时满足即是数组又是树的性质。针对定义…

蓝桥杯2020年C组-试题I-数字三角形(简化版-少一个左右路径差不大于1条件)

1. 题目介绍上图给出了一个数字三角形。 从三角形的顶部到底部有很多条不同的路径。 对于每条路径,把路径上面的数加起来可以得到一个和,你的任务就是找到最大的和。 路径上的每一步只能从一个数走到下一层和它最近的左边的那个数或者右边的那个数。 输入格式 输入的第一行包…

e/易语言 按钮界面弹出气泡提示

案例本文来自博客园,作者:__username,转载请注明原文链接:https://www.cnblogs.com/code3/p/18125232

Linux安装JDK详细教程

Linux安装JDK详细教程(图文教程) 这里介绍两种方式:yum安装方式和手动安装1、yum安装 1.1 查看JDK版本,找到你想要安装的JDK版本,这里以 JDK1.8 为例 输入命令:yum -y list java*1.2 安装JDK1.8 输入命令:yum install -y java-1.8.0-openjdk.x86_64 没权限执行这行:sud…
推荐文章