CN116755866B - A resource scheduling method, device, electronic equipment and readable storage medium - Google Patents
A resource scheduling method, device, electronic equipment and readable storage medium Download PDFInfo
- Publication number
- CN116755866B CN116755866B CN202311028063.3A CN202311028063A CN116755866B CN 116755866 B CN116755866 B CN 116755866B CN 202311028063 A CN202311028063 A CN 202311028063A CN 116755866 B CN116755866 B CN 116755866B
- Authority
- CN
- China
- Prior art keywords
- target
- time
- task
- population
- duration
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 36
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 100
- 230000008569 process Effects 0.000 claims abstract description 13
- 230000006870 function Effects 0.000 claims description 55
- 230000002068 genetic effect Effects 0.000 claims description 48
- 238000012545 processing Methods 0.000 claims description 19
- 238000004364 calculation method Methods 0.000 claims description 17
- 238000004590 computer program Methods 0.000 claims description 9
- 230000035772 mutation Effects 0.000 claims description 7
- 238000012544 monitoring process Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000013507 mapping Methods 0.000 description 3
- 238000010606 normalization Methods 0.000 description 3
- 210000000349 chromosome Anatomy 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000004904 shortening Methods 0.000 description 2
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000001174 ascending effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/12—Computing arrangements based on biological models using genetic models
- G06N3/126—Evolutionary algorithms, e.g. genetic algorithms or genetic programming
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Life Sciences & Earth Sciences (AREA)
- Biophysics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Evolutionary Biology (AREA)
- Physiology (AREA)
- Genetics & Genomics (AREA)
- Artificial Intelligence (AREA)
- Biomedical Technology (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
Description
技术领域Technical field
本发明涉及人工智能技术领域,尤其涉及一种资源调度方法、装置、电子设备及可读存储介质。The present invention relates to the field of artificial intelligence technology, and in particular, to a resource scheduling method, device, electronic equipment and readable storage medium.
背景技术Background technique
随着用户任务数量的持续增多,云计算资源节点完成相应任务的时长也随之显著增加,从而严重影响到用户的服务质量。As the number of user tasks continues to increase, the time it takes for cloud computing resource nodes to complete corresponding tasks also increases significantly, seriously affecting user service quality.
在云计算资源节点尚未完成旧任务,用户又提交了新任务的情况下,现有的资源节点调度方案通常是等待所有的云计算资源节点完成了所有的旧任务之后,才执行新任务的资源节点调度方案,由于旧任务的在云计算资源节点上完成的结束时长不同,因此会存在部分云计算资源节点提前完成了旧任务,而又未分配新任务给该云计算资源节点的情况。When the cloud computing resource node has not completed the old task and the user has submitted a new task, the existing resource node scheduling scheme usually waits for all cloud computing resource nodes to complete all old tasks before executing the new task. In the node scheduling scheme, because the completion time of old tasks on cloud computing resource nodes is different, there may be situations where some cloud computing resource nodes complete old tasks in advance, but no new tasks are assigned to the cloud computing resource nodes.
由于未采用合理的资源节点调度方案充分利用资源节点,导致现有技术中存在资源节点完成任务的总时长较长的问题。Since a reasonable resource node scheduling scheme is not adopted to fully utilize the resource nodes, there is a problem in the existing technology that the total time required for the resource nodes to complete tasks is long.
发明内容Contents of the invention
本发明实施例提供一种资源调度方法、装置、电子设备及可读存储介质,以解决现有技术中存在资源节点完成任务的总时长较长的问题。Embodiments of the present invention provide a resource scheduling method, device, electronic device and readable storage medium to solve the problem in the prior art that the total time required for resource nodes to complete tasks is long.
第一方面,本发明实施例提供了一种资源节点调度方法,包括:In a first aspect, embodiments of the present invention provide a resource node scheduling method, including:
获取目标任务的类型以及资源节点的运行状态信息;Obtain the type of target task and the running status information of the resource node;
在所述目标任务的类型为预设类型的情况下,根据所述目标任务和所述运行状态信息,确定第一函数,其中,所述预设类型表示所述目标任务为N个待完成任务中的第2个待完成任务至第N个待完成任务中的任一个待完成任务,所述N个待完成任务依次排列,N为大于1的整数;When the type of the target task is a preset type, a first function is determined based on the target task and the running status information, wherein the preset type indicates that the target task is N tasks to be completed. Any to-be-completed task from the 2nd to N-th to-be-completed task in , the N to-be-completed tasks are arranged in sequence, and N is an integer greater than 1;
根据目标算法对所述第一函数进行计算,得到目标解;Calculate the first function according to the target algorithm to obtain the target solution;
根据基于所述目标解确定的目标资源调度方案,调度所述资源节点处理所述目标任务。According to the target resource scheduling plan determined based on the target solution, the resource node is scheduled to process the target task.
可选地,所述目标算法包括遗传算法和贪心算法中的至少一项。Optionally, the target algorithm includes at least one of a genetic algorithm and a greedy algorithm.
可选地,在所述目标算法包括遗传算法和贪心算法的情况下,所述根据目标算法对所述第一函数进行计算,得到目标解包括:Optionally, when the target algorithm includes a genetic algorithm and a greedy algorithm, calculating the first function according to the target algorithm to obtain the target solution includes:
根据所述贪心算法和第一个体的需求资源类型,在资源列表中确定所述第一个体的目标资源节点,所述第一个体为不满足预设约束条件的个体,所述个体基于所述遗传算法确定;According to the greedy algorithm and the required resource type of the first individual, the target resource node of the first individual is determined in the resource list. The first individual is an individual that does not meet the preset constraints. The individual Determined based on the genetic algorithm;
根据所述第一个体的目标资源节点,确定第一种群,所述第一种群包括所述第一个体的目标资源节点;Determine a first population according to the target resource node of the first individual, and the first population includes the target resource node of the first individual;
根据所述遗传算法,对所述第一种群进行迭代计算并记录迭代次数;According to the genetic algorithm, iteratively calculate the first population and record the number of iterations;
在所述第一种群的迭代次数达到预设迭代次数的情况下,将当前种群中适应度最高的个体确定为所述第一函数的目标解,所述当前种群为所述第一种群经过预设迭代次数的迭代计算得到的种群。When the number of iterations of the first population reaches the preset number of iterations, the individual with the highest fitness in the current population is determined as the target solution of the first function, and the current population is the preset number of iterations for the first population. Let the number of iterations be the iteratively calculated population.
可选地,所述根据所述遗传算法,对所述第一种群进行迭代计算包括:Optionally, the iterative calculation of the first population according to the genetic algorithm includes:
根据遗传算法,计算所述第一种群内个体的适应度;Calculate the fitness of individuals within the first population according to a genetic algorithm;
根据所述遗传算法、所述第一种群内个体的适应度和预设适应度阈值,确定第二种群并进行迭代计算。According to the genetic algorithm, the fitness of individuals in the first population and the preset fitness threshold, the second population is determined and iteratively calculated.
可选地,所述根据所述遗传算法、所述交叉概率和所述变异概率,对所述第一种群进行迭代计算包括:Optionally, the iterative calculation of the first population according to the genetic algorithm, the crossover probability and the mutation probability includes:
计算所述第一种群的M个个体的适应度和所述M个个体的适应度的总和,M为正整数;Calculate the fitness of the M individuals of the first population and the sum of the fitnesses of the M individuals, where M is a positive integer;
根据目标个体的适应度和所述M个个体的适应度的总和,确定所述目标个体的第一概率,所述目标个体为任一所述M个个体,所述第一概率为所述目标个体被挑选到第二种群内的概率;According to the fitness of the target individual and the sum of the fitnesses of the M individuals, the first probability of the target individual is determined, the target individual is any of the M individuals, and the first probability is the target The probability that an individual is selected into the second population;
根据所述目标个体的第一概率,确定所述第二种群,所述第二种群为所述第一种群经过一次迭代后的种群。The second population is determined according to the first probability of the target individual, and the second population is the population after one iteration of the first population.
可选地,在第一时长小于预设时长的情况下,所述第一函数为:Optionally, when the first duration is less than the preset duration, the first function is:
; ;
其中,表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需 的时间,表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需花费的成 本,的取值范围0到1,的取值范围为0到1,且,所述运行状态信息包括每一所述资 源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完成任务 处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所述第一 时刻中最晚的时刻。 in, Indicates the time required to complete the N to-be-completed tasks when the first duration is less than the preset duration, Indicates the cost required to complete the N to-be-completed tasks when the first duration is less than the preset duration, The value range of is 0 to 1, The value range of is 0 to 1, and , the running status information includes the first time of each resource node, the first time is the time when the resource node completes the processing of the to-be-completed task before the target task, and the first duration is the The difference between the second time and the current time. The second time is the latest time among the first time.
可选地,在第一时长大于预设时长的情况下,所述第一函数为:Optionally, when the first duration is greater than the preset duration, the first function is:
; ;
其中,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需 的时间,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需花费的 成本, 的取值范围0到1,的取值范围为0到1,且,所述运行状态信息包括每一所 述资源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完成 任务处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所述 第一时刻中最晚的时刻。 in, Indicates the time required to complete the N to-be-completed tasks when the first duration is greater than the preset duration, Indicates the cost required to complete the N to-be-completed tasks when the first duration is longer than the preset duration, The value range of is 0 to 1, The value range of is 0 to 1, and , the running status information includes the first time of each resource node, the first time is the time when the resource node completes the processing of the to-be-completed task before the target task, and the first duration is the The difference between the second time and the current time. The second time is the latest time among the first time.
第二方面,本发明实施例还提供一种资源调度装置,所述资源调度装置包括:In a second aspect, an embodiment of the present invention also provides a resource scheduling device, where the resource scheduling device includes:
监测模块,用于获取目标任务的类型以及资源节点的运行状态信息;Monitoring module, used to obtain the type of target tasks and the running status information of resource nodes;
确定模块,用于在所述目标任务的类型为预设类型的情况下,根据所述目标任务和所述运行状态信息,确定第一函数,其中,所述预设类型表示所述目标任务为N个待完成任务中的第2个待完成任务至第N个待完成任务中的任一个待完成任务,所述N个待完成任务依次排列,N为大于1的整数;Determining module, configured to determine a first function according to the target task and the running status information when the type of the target task is a preset type, wherein the preset type indicates that the target task is Any to-be-completed task from the 2nd to N-th to-be-completed tasks among the N to-be-completed tasks, the N to-be-completed tasks are arranged in sequence, and N is an integer greater than 1;
得到模块,用于根据目标算法对所述第一函数进行计算,得到目标解;Get a module, used to calculate the first function according to the target algorithm and obtain the target solution;
调度模块,用于根据基于所述目标解确定的目标资源调度方案,调度所述资源节点处理所述目标任务。A scheduling module, configured to schedule the resource node to process the target task according to the target resource scheduling plan determined based on the target solution.
第三方面,本发明实施例还提供一种电子设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上所述的资源调度方法中的步骤。In a third aspect, embodiments of the present invention further provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the above is implemented. The steps in the resource scheduling method described above.
第四方面,本发明实施例还提供一种计算机可读存储介质,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现如上所述的资源调度方法中的步骤。In a fourth aspect, embodiments of the present invention also provide a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the steps in the resource scheduling method as described above are implemented. .
在本发明实施例中,通过获取目标任务的类型以及资源节点的运行状态信息;在所述目标任务的类型为预设类型的情况下,根据所述目标任务和所述运行状态信息,确定第一函数,其中,所述预设类型表示所述目标任务为N个待完成任务中的第2个待完成任务至第N个待完成任务中的任一个待完成任务,所述N个待完成任务依次排列,N为大于1的整数;根据目标算法对所述第一函数进行计算,得到目标解;根据基于所述目标解确定的目标资源调度方案,调度所述资源节点处理所述目标任务。可以在资源节点上存在尚未完成的任务时,往其他已经完成任务的资源节点上分配任务,从而使得总的任务执行时长缩短。In the embodiment of the present invention, the type of the target task and the running status information of the resource node are obtained; in the case that the type of the target task is a preset type, the first task is determined based on the target task and the running status information. A function, wherein the preset type indicates that the target task is any to-be-completed task from the 2nd to N-th to-be-completed tasks among the N to-be-completed tasks, and the N to-be-completed tasks are The tasks are arranged in order, and N is an integer greater than 1; the first function is calculated according to the target algorithm to obtain the target solution; the resource nodes are scheduled to process the target task according to the target resource scheduling plan determined based on the target solution . When there are unfinished tasks on a resource node, tasks can be assigned to other resource nodes that have completed tasks, thereby shortening the total task execution time.
附图说明Description of the drawings
为了更清楚地说明本发明实施例的技术方案,下面将对本发明实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without exerting any creative effort.
图1是本发明实施例提供的资源调度方法的流程图;Figure 1 is a flow chart of a resource scheduling method provided by an embodiment of the present invention;
图2是本发明实施例提供的资源调度装置的结构示意图;Figure 2 is a schematic structural diagram of a resource scheduling device provided by an embodiment of the present invention;
图3是本发明实施例提供的电子设备的结构示意图。Figure 3 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of the present invention.
本发明实施例提供的资源调度方法的流程图,如图1所示,包括以下步骤:The flow chart of the resource scheduling method provided by the embodiment of the present invention, as shown in Figure 1, includes the following steps:
步骤101、获取目标任务的类型以及资源节点的运行状态信息;Step 101: Obtain the type of target task and the running status information of the resource node;
应理解,上述目标任务的类型可以是第一类型,也可以是第二类型。所述目标任务的类型为第一类型,是指在提交目标任务之前资源节点上不存在尚未执行完毕的任务,此时将所述目标任务的类型确定为所述第一类型;所述目标任务的类型为第二类型,是指在提交目标任务之前资源节点上还存在尚未执行完毕的任务,此时将所述目标任务的类型确定为所述第二类型。It should be understood that the type of the above target task may be the first type or the second type. The type of the target task is the first type, which means that there is no unfinished task on the resource node before the target task is submitted. At this time, the type of the target task is determined to be the first type; the target task The type is the second type, which means that there are still unfinished tasks on the resource node before the target task is submitted. At this time, the type of the target task is determined to be the second type.
应理解,所述资源节点的运行状态信息包括:是否存在正在执行的任务和执行剩余的任务的完成时间。It should be understood that the running status information of the resource node includes: whether there are tasks being executed and the completion time of executing the remaining tasks.
在步骤101中,可以是在用户向资源节点提交目标任务之后每间隔一定周期,获取一次目标任务的类型以及资源节点的运行状态信息;也可以是在用户向资源节点提交目标任务之后实时获取目标任务的类型以及资源节点的运行状态信息。In step 101, the type of the target task and the running status information of the resource node can be obtained every certain period after the user submits the target task to the resource node; it can also be obtained in real time after the user submits the target task to the resource node. The type of task and the running status information of the resource node.
步骤102、在所述目标任务的类型为预设类型的情况下,根据所述目标任务和所述运行状态信息,确定第一函数,其中,所述预设类型表示所述目标任务为N个待完成任务中的第2个待完成任务至第N个待完成任务中的任一个待完成任务,所述N个待完成任务依次排列,N为大于1的整数;Step 102: When the type of the target task is a preset type, determine a first function according to the target task and the running status information, wherein the preset type indicates that there are N target tasks. Any of the 2nd to Nth to-be-completed tasks among the to-be-completed tasks, the N to-be-completed tasks are arranged in sequence, and N is an integer greater than 1;
应理解,上述预设类型为第二类型;所述目标任务具有任务长度。It should be understood that the above-mentioned preset type is the second type; the target task has a task length.
在步骤102中,在所述目标任务的类型为预设类型的情况下,即所述目标任务的类型为第二类型的情况下,根据所述目标任务和所述运行状态信息,确定第一函数。In step 102, when the type of the target task is a preset type, that is, when the type of the target task is the second type, a first value is determined based on the target task and the running status information. function.
需要说明的是,所述第一函数可以为,并满足如下约束条件: 表示任务对资源 节点中资源类型的消耗量,为资源节点中资源的可用量, 表示中央处理 器的资源可用量、表示内存的资源可用量和表示带宽的资源可用量,为取值范 围在0至1之间的权重参数,为取值范围在0至1之间的权重参数,且,n表示任务的 数量,m表示资源节点的数量, ,表示在第一时长小于预设 时长的情况下完成所述N个待完成任务所需的时间,m表示资源节点的数量,,表示任务是否在资源节点执行,的取值为1或0, 表示任务在资源节点上执行,表示任务不在资源节点上执行,为任务的长度, 为资源节点的中央处理器执行速度,;,fcost表示执行任务 运行需要花费的成本,表示任务是否在资源节点执行, 的取值为1或0, 表 示任务在资源节点上执行, 表示任务不在资源节点上执行,为资源节点在单位时长内的资源使用成本,n表示任务的数量,m表示资源节点的数量, 为资源节点中资源的可用量,分别表示中央处 理器、内存和带宽的资源可用量,为任务的长度, 为资源节点的中央处理器执 行速度。 It should be noted that the first function can be , and satisfy the following constraints: represents a task resource node Medium resource type consumption, For resource nodes China resources available amount, Indicates the available resources of the CPU, Represents the available amount of memory resources and Indicates the amount of resource available for bandwidth, is a weight parameter with a value ranging from 0 to 1, is a weight parameter with a value ranging from 0 to 1, and , n represents the number of tasks, m represents the number of resource nodes, , Indicates the time required to complete the N tasks to be completed when the first duration is less than the preset duration, m indicates the number of resource nodes, , represents a task Whether it is in the resource node implement, The value is 1 or 0, represents a task at the resource node executed on represents a task Not in the resource node executed on for task length, For resource nodes CPU execution speed,; , f cost represents the cost of executing the task, represents a task Whether it is in the resource node implement, The value is 1 or 0, represents a task at the resource node executed on represents a task Not in the resource node executed on For resource nodes Resource usage cost per unit time, n represents the number of tasks, m represents the number of resource nodes, For resource nodes China Resources available amount, Represents the available resources of CPU, memory and bandwidth respectively, for task length, For resource nodes CPU execution speed.
所述第一函数也可以为,并满足如下约束条件: ,表示任务对资源 节点中资源类型的消耗量,为资源节点中资源的可用量, 表示中央处理 器的资源可用量、表示内存的资源可用量和表示带宽的资源可用量, 为取值 范围在0至1之间的权重参数,为取值范围在0至1之间的权重参数,且,,表示所有资源节点 全部完成在提交所述目标任务之前的提交的任务到资源节点中完成所述目标任务之间 的时间间隔,表示表示资源节点完成所述目标任务的时间,n表示任务的数量,m表示 资源节点的数量,为任务的长度,为资源节点的中央处理器执行速度, 表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需的时间,表示任务是否在资源节点执行, 的取值为1或0, 表示任务在资源节点上执行, 表示任务不在资源节点上执行,,表示在第一时 长大于预设时长的情况下完成所述N个待完成任务所需花费的成本,n表示任务的数量,m表 示资源节点的数量,表示任务是否在资源节点执行,为任务的长度, 为资 源节点的中央处理器执行速度,为资源节点在单位时长内的资源使用成本。 The first function can also be , and satisfy the following constraints: , represents a task resource node Medium resource type consumption, For resource nodes China resources available amount, Indicates the available resources of the CPU, Represents the available amount of memory resources and Indicates the amount of resource available for bandwidth, is a weight parameter with a value ranging from 0 to 1, is a weight parameter with a value ranging from 0 to 1, and , , Indicates that all resource nodes have completed the submitted tasks to the resource nodes before submitting the target task. The time interval between completing the target tasks in Indicates resource nodes The time to complete the target task, n represents the number of tasks, m represents the number of resource nodes, for task length, For resource nodes CPU execution speed, Indicates the time required to complete the N to-be-completed tasks when the first duration is greater than the preset duration, represents a task Whether it is in the resource node implement, The value is 1 or 0, represents a task at the resource node executed on represents a task Not in the resource node executed on , Represents the cost required to complete the N to-be-completed tasks when the first duration is longer than the preset duration, n represents the number of tasks, m represents the number of resource nodes, represents a task Whether it is in the resource node implement, for task length, For resource nodes CPU execution speed, For resource nodes Resource usage cost per unit time.
需要说明的是,通过设置权重参数,表示任务完成时间和资源使用成本的相对重要性。It should be noted that by setting the weight parameter, the relative importance of task completion time and resource usage cost is expressed.
步骤103、根据目标算法对所述第一函数进行计算,得到目标解;Step 103: Calculate the first function according to the target algorithm to obtain the target solution;
应理解,所述目标算法可以是能求解带约束条件的函数的启发式算法。It should be understood that the target algorithm may be a heuristic algorithm capable of solving a function with constraints.
在步骤103中,所述目标解可以是所述第一函数的局部最优解,也可以是所述第一函数的全局最优解。In step 103, the target solution may be a local optimal solution of the first function or a global optimal solution of the first function.
步骤104、根据基于所述目标解确定的目标资源调度方案,调度所述资源节点处理所述目标任务。Step 104: Schedule the resource node to process the target task according to the target resource scheduling plan determined based on the target solution.
在步骤104中,得到第一函数的目标解后,生成各个资源节点的任务执行次序表,然后按照提交任务时间的先后时间顺序将任务编号添加到该任务执行次序表中,资源节点根据该任务执行次序表中的任务编号执行相应的任务。In step 104, after obtaining the target solution of the first function, a task execution sequence table of each resource node is generated, and then the task number is added to the task execution sequence table in the order of the time when the task is submitted. The task number in the execution sequence table executes the corresponding task.
在本发明实施例中,通过获取目标任务的类型以及资源节点的运行状态信息;在所述目标任务的类型为预设类型的情况下,根据所述目标任务和所述运行状态信息,确定第一函数,其中,所述预设类型表示所述目标任务为N个待完成任务中的第2个待完成任务至第N个待完成任务中的任一个待完成任务,所述N个待完成任务依次排列,N为大于1的整数;根据目标算法对所述第一函数进行计算,得到目标解;根据基于所述目标解确定的目标资源调度方案,调度所述资源节点处理所述目标任务。可以在资源节点上存在尚未完成的任务时,往其他已经完成任务的资源节点上分配任务,从而使得总的任务执行时长缩短。In the embodiment of the present invention, the type of the target task and the running status information of the resource node are obtained; in the case that the type of the target task is a preset type, the first task is determined based on the target task and the running status information. A function, wherein the preset type indicates that the target task is any to-be-completed task from the 2nd to N-th to-be-completed tasks among the N to-be-completed tasks, and the N to-be-completed tasks are The tasks are arranged in order, and N is an integer greater than 1; the first function is calculated according to the target algorithm to obtain the target solution; the resource nodes are scheduled to process the target task according to the target resource scheduling plan determined based on the target solution . When there are unfinished tasks on a resource node, tasks can be assigned to other resource nodes that have completed tasks, thereby shortening the total task execution time.
可选地,在一些实施例中,所述目标算法包括遗传算法和贪心算法中的至少一项。Optionally, in some embodiments, the target algorithm includes at least one of a genetic algorithm and a greedy algorithm.
在本发明实施例中,通过所述目标算法包括遗传算法和贪心算法,这样可以在利用遗传算法对带约束的资源调度问题进行求解时,为了保证种群的多样性,在初始化、交叉和变异等阶段没有采用舍弃不满足约束条件的个体,而是结合贪心算法去对不满约束条件的个体进行调整,使得调整过后的个体具有更少的任务完成时间和资源节点的使用成本,最终提高了全局收敛精度。In the embodiment of the present invention, the target algorithm includes a genetic algorithm and a greedy algorithm, so that when using the genetic algorithm to solve the constrained resource scheduling problem, in order to ensure the diversity of the population, initialization, crossover, mutation, etc. Instead of discarding individuals that do not meet the constraints, the stage uses a greedy algorithm to adjust individuals that do not meet the constraints, so that the adjusted individuals have less task completion time and resource node usage costs, ultimately improving global convergence. Accuracy.
可选地,在一些实施例中, 在所述目标算法包括遗传算法和贪心算法的情况下,所述根据目标算法对所述第一函数进行计算,得到目标解包括:Optionally, in some embodiments, when the target algorithm includes a genetic algorithm and a greedy algorithm, calculating the first function according to the target algorithm to obtain the target solution includes:
根据所述贪心算法和第一个体的需求资源类型,在资源列表中确定所述第一个体的目标资源节点,所述第一个体为不满足预设约束条件的个体,所述个体基于所述遗传算法确定;According to the greedy algorithm and the required resource type of the first individual, the target resource node of the first individual is determined in the resource list. The first individual is an individual that does not meet the preset constraints. The individual Determined based on the genetic algorithm;
应理解,所述目标资源节点的资源可用量满足所述第一个体的任务需求量。It should be understood that the resource availability of the target resource node meets the task requirement of the first individual.
应理解,上述预设约束条件为: ,表示任务对资源节 点中资源类型的消耗量,为资源节点中资源的可 用量, 分别表示中央处理器、内存和带宽的资源可用量。 It should be understood that the above preset constraints are: , represents a task resource node Medium resource type consumption, For resource nodes China resources available amount, Indicates the available resources of CPU, memory and bandwidth respectively.
根据所述第一个体的目标资源节点,确定第一种群,所述第一种群包括所述第一个体的目标资源节点;Determine a first population according to the target resource node of the first individual, and the first population includes the target resource node of the first individual;
应理解,所述第一种群包括多个个体以及每一个体对应的资源节点。It should be understood that the first population includes multiple individuals and resource nodes corresponding to each individual.
根据所述遗传算法,对所述第一种群进行迭代计算并记录迭代次数;According to the genetic algorithm, iteratively calculate the first population and record the number of iterations;
在所述第一种群的迭代次数达到预设迭代次数的情况下,将当前种群中适应度最高的个体确定为所述第一函数的目标解,所述当前种群为所述第一种群经过预设迭代次数的迭代计算得到的种群。When the number of iterations of the first population reaches the preset number of iterations, the individual with the highest fitness in the current population is determined as the target solution of the first function, and the current population is the preset number of iterations for the first population. Let the number of iterations be the iteratively calculated population.
应理解,预设迭代次数可以是在100~2000之间。It should be understood that the preset number of iterations may be between 100 and 2000.
可选地,在一些实施例中,所述根据遗传算法,对所述第一种群进行迭代计算包括:Optionally, in some embodiments, the iterative calculation of the first population according to a genetic algorithm includes:
根据遗传算法,计算所述第一种群内个体的适应度;Calculate the fitness of individuals within the first population according to a genetic algorithm;
根据所述遗传算法,所述第一种群内个体的适应度和预设适应度,确定第二种群并进行迭代计算。According to the genetic algorithm, the fitness of individuals in the first population and the preset fitness, the second population is determined and iteratively calculated.
在本发明实施例中,计算所述第一种群内个体的适应度的公式可以是:,也可以是;并对其做归一化处理,归一化处理公式如下:;其中,和分别为该种群中的最大和最小的适应度。 In this embodiment of the present invention, the formula for calculating the fitness of individuals in the first group may be: ,can also be ; and perform normalization processing on it. The normalization processing formula is as follows: ;in, and are the maximum and minimum fitness in the population respectively.
同时,将大于预设适应值的个体确定为第二种群。 At the same time, the Individuals whose fitness value is greater than the preset value are determined as the second population.
在本发明实施例中,通过上述方式,通过对适应度进行归一化处理,可以减少适应度在数量级上的影响。In the embodiment of the present invention, by performing normalization processing on the fitness in the above manner, the impact of the fitness on an order of magnitude can be reduced.
可选地,所述根据所述遗传算法、所述交叉概率和所述变异概率,对所述第一种群进行迭代计算包括:Optionally, the iterative calculation of the first population according to the genetic algorithm, the crossover probability and the mutation probability includes:
计算所述第一种群的M个个体的适应度和所述M个个体的适应度的总和,M为正整数;Calculate the fitness of the M individuals of the first population and the sum of the fitness of the M individuals, where M is a positive integer;
根据目标个体的适应度和所述M个个体的适应度的总和,确定所述目标个体的第一概率,所述目标个体为任一所述M个个体,所述第一概率为所述目标个体被挑选到第二种群内的概率;According to the fitness of the target individual and the sum of the fitnesses of the M individuals, the first probability of the target individual is determined, the target individual is any of the M individuals, and the first probability is the target The probability that an individual is selected into the second population;
根据所述目标个体的第一概率,确定所述第二种群,所述第二种群为所述第一种群经过一次迭代后的种群。The second population is determined according to the first probability of the target individual, and the second population is the population after one iteration of the first population.
在本发明实施例中,个体被选择的概率为: ;其中, 为第i个 个体归一化处理后的适应度,N为任务总数。 In this embodiment of the present invention, the probability of an individual being selected is: ;in, is the normalized fitness of the i-th individual, and N is the total number of tasks.
在本发明实施例中,通过上述方案,可以使得适应度大的个体比适应度小的个体被选择的概率要大。In the embodiment of the present invention, through the above solution, individuals with high fitness can be selected with a higher probability than individuals with low fitness.
可选地,在一些实施例中,从新的种群中以概率选择两个个体进行染色体交叉, 以概率选择一个个体进行染色体变异,生成新的个体,并对新个体进行如下处理:将个 体元素进行解码,并将解码后的值映射到区间内,映射公式为:当时, ,当时, 。其中和分别表示映射前后的值。 Optionally, in some embodiments, from the new population with probability Select two individuals for chromosome crossover, with probability Select an individual for chromosome mutation, generate a new individual, and process the new individual as follows: decode the individual elements and map the decoded values to intervals Within, the mapping formula is: when hour, ,when hour, . in and Represents the values before and after mapping respectively.
进一步地,所有元素映射完成之后采用贪心算法对不满足约束条件的新个体进行 修正,即判断新个体中的元素是否满足约束条件,如果满足,则继续 判断下一个元素;如果不满足约束条件,找到对应的资源类型P,按照资源P可用量从小到大 的顺序生成可用资源列表,该列表记录m个资源节点中3种资源的可用量,所述三种资源的 可用量包括:中央处理器、内存、带宽的可用量,从表中找到3种资源的可用量都满足任务需 求,且资源P的可用量与任务需求量最接近的a个资源节点,a的取值范围为1-5,并分别计算 当任务ti分配到a个不同资源节点时对应的适应度函数值,将最大适应度函数值对应的资 源节点编号赋值给ei,然后继续判断下一个元素,所有元素处理完之后,重新对个体进行二 进制编码,并将加入种群中。 Furthermore, after the mapping of all elements is completed, a greedy algorithm is used to correct new individuals that do not meet the constraint conditions, that is, to determine the elements in the new individuals Whether the constraint conditions are met, if so, continue to judge the next element; if the constraint conditions are not met, find the corresponding resource type P, and generate an available resource list in ascending order of the available amount of resource P. This list records m resource nodes. The available amounts of three resources in The a resource node closest to the task demand, the value range of a is 1-5, and the corresponding fitness function value when the task ti is assigned to a different resource node is calculated respectively, and the maximum fitness function value is The corresponding resource node number is assigned to e i , and then continues to determine the next element. After all elements are processed, the individual is re-binary encoded and added to the population.
可选地,在第一时长小于预设时长的情况下,所述第一函数为:Optionally, when the first duration is less than the preset duration, the first function is:
; ;
其中,ftime表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需的时间,fcost表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需花费的成本,α的取值范围0到1,β的取值范围为0到1,且α+β=1,所述运行状态信息包括每一所述资源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完成任务处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所述第一时刻中最晚的时刻。Where, f time represents the time required to complete the N tasks to be completed when the first duration is less than the preset duration, and f cost represents the time required to complete the N tasks to be completed when the first duration is less than the preset duration. The cost of the task, the value range of α is 0 to 1, the value range of β is 0 to 1, and α+β=1, the running status information includes the first moment of each resource node, The first time is the time when the resource node completes processing of the to-be-completed task before the target task, the first duration is the difference between the second time and the current time, and the second time is the Describe the latest moment among the first moments.
可选地,在第一时长大于预设时长的情况下,所述第一函数为:Optionally, when the first duration is greater than the preset duration, the first function is:
; ;
其中,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需 的时间,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需花费的 成本,的取值范围0到1,的取值范围为0到1,且,所述运行状态信息包括每一所 述资源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完成 任务处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所述 第一时刻中最晚的时刻。 in, Indicates the time required to complete the N to-be-completed tasks when the first duration is greater than the preset duration, Indicates the cost required to complete the N to-be-completed tasks when the first duration is longer than the preset duration, The value range of is 0 to 1, The value range of is 0 to 1, and , the running status information includes the first time of each resource node, the first time is the time when the resource node completes the processing of the to-be-completed task before the target task, and the first duration is the The difference between the second time and the current time. The second time is the latest time among the first time.
参见图2,图2是本发明实施例提供的资源调度装置200的结构示意图,如图2所示,包括以下模块:Referring to Figure 2, Figure 2 is a schematic structural diagram of a resource scheduling device 200 provided by an embodiment of the present invention. As shown in Figure 2, it includes the following modules:
监测模块201,用于获取目标任务的类型以及资源节点的运行状态信息;Monitoring module 201 is used to obtain the type of target tasks and the running status information of resource nodes;
确定模块202,用于在所述目标任务的类型为预设类型的情况下,根据所述目标任务和所述运行状态信息,确定第一函数,其中,所述预设类型表示所述目标任务为N个待完成任务中的第2个待完成任务至第N个待完成任务中的任一个待完成任务,所述N个待完成任务依次排列,N为大于1的整数;Determining module 202, configured to determine a first function according to the target task and the running status information when the type of the target task is a preset type, wherein the preset type represents the target task It is any to-be-completed task from the 2nd to N-th to-be-completed tasks among the N to-be-completed tasks, the N to-be-completed tasks are arranged in sequence, and N is an integer greater than 1;
得到模块203,用于根据目标算法对所述第一函数进行计算,得到目标解;Obtaining module 203 is used to calculate the first function according to the target algorithm and obtain the target solution;
调度模块204,用于根据基于所述目标解确定的目标资源调度方案,调度所述资源节点处理所述目标任务。The scheduling module 204 is configured to schedule the resource node to process the target task according to the target resource scheduling plan determined based on the target solution.
可选的,所述目标算法包括遗传算法和贪心算法中的至少一项。Optionally, the target algorithm includes at least one of a genetic algorithm and a greedy algorithm.
可选地,在所述目标算法包括遗传算法和贪心算法的情况下,所述得到模块包括:Optionally, when the target algorithm includes a genetic algorithm and a greedy algorithm, the obtaining module includes:
第一确定子模块,用于根据所述贪心算法和第一个体的需求资源类型,在资源列表中确定所述第一个体的目标资源节点,所述第一个体为不满足预设约束条件的个体,所述个体基于所述遗传算法确定;The first determination sub-module is used to determine the target resource node of the first individual in the resource list according to the greedy algorithm and the required resource type of the first individual. The first individual does not meet the preset Individuals of constraints, the individuals are determined based on the genetic algorithm;
第二确定子模块,用于根据所述第一个体的目标资源节点,确定第一种群,所述第一种群包括所述第一个体的目标资源节点;The second determination sub-module is used to determine the first population according to the target resource node of the first individual, where the first population includes the target resource node of the first individual;
计算子模块,用于根据所述遗传算法,对所述第一种群进行迭代计算并记录迭代次数;A calculation submodule, configured to iteratively calculate the first population according to the genetic algorithm and record the number of iterations;
第三确定子模块,用于在所述第一种群的迭代次数达到预设迭代次数的情况下,将当前种群中适应度最高的个体确定为所述第一函数的目标解,所述当前种群为所述第一种群经过预设迭代次数的迭代计算得到的种群。The third determination sub-module is used to determine the individual with the highest fitness in the current population as the target solution of the first function when the number of iterations of the first population reaches the preset number of iterations. The current population is the population obtained by iterative calculation of the first population through a preset number of iterations.
可选地,计算子模块包括:Optionally, the calculation submodule includes:
第一计算子单元,用于根据遗传算法,计算所述第一种群内个体的适应度;The first calculation subunit is used to calculate the fitness of individuals in the first population according to a genetic algorithm;
第一确定子单元,用于根据所述遗传算法、所述第一种群内个体的适应度和预设适应度阈值,确定第二种群并进行迭代计算。The first determination subunit is used to determine the second population and perform iterative calculations based on the genetic algorithm, the fitness of individuals in the first population, and the preset fitness threshold.
可选地,计算子模块包括:Optionally, the calculation submodule includes:
第二计算子单元,用于计算所述第一种群的M个个体的适应度和所述M个个体的适应度的总和,M为正整数;The second calculation subunit is used to calculate the fitness of the M individuals of the first population and the sum of the fitnesses of the M individuals, where M is a positive integer;
第二确定子单元,用于根据目标个体的适应度和所述M个个体的适应度的总和,确定所述目标个体的第一概率,所述目标个体为任一所述M个个体,所述第一概率为所述目标个体被挑选到第二种群内的概率;The second determination subunit is used to determine the first probability of the target individual based on the fitness of the target individual and the sum of the fitnesses of the M individuals, where the target individual is any of the M individuals, so The first probability is the probability that the target individual is selected into the second population;
第三确定子单元,用于根据所述目标个体的第一概率,确定所述第二种群,所述第二种群为所述第一种群经过一次迭代后的种群。The third determination subunit is used to determine the second population according to the first probability of the target individual. The second population is the population after one iteration of the first population.
可选地,在第一时长小于预设时长的情况下,所述第一函数为:Optionally, when the first duration is less than the preset duration, the first function is:
; ;
其中,表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需的 时间,表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需花费的成 本,的取值范围0到1,的取值范围为0到1,且,所述运行状态信息包括每一所述 资源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完成任 务处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所述第 一时刻中最晚的时刻。 in, Indicates the time required to complete the N to-be-completed tasks when the first duration is less than the preset duration, Indicates the cost required to complete the N to-be-completed tasks when the first duration is less than the preset duration, The value range of is 0 to 1, The value range of is 0 to 1, and , the running status information includes the first time of each resource node, the first time is the time when the resource node completes the processing of the to-be-completed task before the target task, and the first duration is the The difference between the second time and the current time. The second time is the latest time among the first time.
可选地,在第一时长大于预设时长的情况下,所述第一函数为:Optionally, when the first duration is greater than the preset duration, the first function is:
; ;
其中,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需 的时间,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需花费的 成本,的取值范围0到1,的取值范围为0到1,且,所述运行状态信息包括每一所 述资源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完成 任务处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所述 第一时刻中最晚的时刻。 in, Indicates the time required to complete the N to-be-completed tasks when the first duration is greater than the preset duration, Indicates the cost required to complete the N to-be-completed tasks when the first duration is longer than the preset duration, The value range of is 0 to 1, The value range of is 0 to 1, and , the running status information includes the first time of each resource node, the first time is the time when the resource node completes the processing of the to-be-completed task before the target task, and the first duration is the The difference between the second time and the current time, the second time being the latest time among the first time.
本发明实施例还提供了一种电子设备。参见图3,图3是本发明实施例提供的电子设备的结构示意图。由于电子设备解决问题的原理与本发明实施例中资源调度的方法相似,因此该电子设备的实施可以参见方法的实施,重复之处不再赘述。An embodiment of the present invention also provides an electronic device. Referring to Figure 3, Figure 3 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. Since the problem-solving principle of the electronic device is similar to the resource scheduling method in the embodiment of the present invention, the implementation of the electronic device can be referred to the implementation of the method, and repeated details will not be repeated.
如图3所示,电子设备300 包括:处理器310,用于读取存储器320中的程序,执行下列过程:As shown in Figure 3, the electronic device 300 includes: a processor 310, used to read the program in the memory 320 and perform the following processes:
获取目标任务的类型以及资源节点的运行状态信息;Obtain the type of target task and the running status information of the resource node;
在所述目标任务的类型为预设类型的情况下,根据所述目标任务和所述运行状态信息,确定第一函数,其中,所述预设类型表示所述目标任务为N个待完成任务中的第2个待完成任务至第N个待完成任务中的任一待完成任务,所述N个待完成任务依次排列,N为大于1的整数;When the type of the target task is a preset type, a first function is determined based on the target task and the running status information, wherein the preset type indicates that the target task is N tasks to be completed. Any to-be-completed task from the 2nd to N-th to-be-completed task, the N to-be-completed tasks are arranged in sequence, and N is an integer greater than 1;
根据目标算法对所述第一函数进行计算,得到目标解;Calculate the first function according to the target algorithm to obtain the target solution;
根据基于所述目标解确定的目标资源调度方案,调度所述资源节点处理所述目标任务。According to the target resource scheduling plan determined based on the target solution, the resource node is scheduled to process the target task.
其中,在图3中,总线架构可以包括任意数量的互联的总线和桥,具体由处理器310代表的一个或多个处理器和存储器320代表的存储器的各种电路链接在一起。总线架构还可以将诸如外围设备、稳压器和功率管理电路等之类的各种其他电路链接在一起,这些都是本领域所公知的,因此,本文不再对其进行进一步描述。总线接口提供接口。处理器310负责管理总线架构和通常的处理,存储器320可以存储处理器310在执行操作时所使用的数据。In FIG. 3 , the bus architecture may include any number of interconnected buses and bridges, specifically one or more processors represented by processor 310 and various circuits of the memory represented by memory 320 are linked together. The bus architecture can also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are all well known in the art and therefore will not be described further herein. The bus interface provides the interface. The processor 310 is responsible for managing the bus architecture and general processing, and the memory 320 can store data used by the processor 310 when performing operations.
可选的,处理器310还用于读取存储器320中的程序,执行如下步骤:Optionally, the processor 310 is also used to read the program in the memory 320 and perform the following steps:
所述目标算法包括遗传算法和贪心算法中的至少一项。The target algorithm includes at least one of a genetic algorithm and a greedy algorithm.
可选地,在所述目标算法包括遗传算法和贪心算法的情况下,所述根据目标算法对所述第一函数进行计算,得到目标解包括:Optionally, when the target algorithm includes a genetic algorithm and a greedy algorithm, calculating the first function according to the target algorithm to obtain the target solution includes:
根据所述贪心算法和第一个体的需求资源类型,在资源列表中确定所述第一个体的目标资源节点,所述第一个体为不满足预设约束条件的个体,所述个体基于所述遗传算法确定;According to the greedy algorithm and the required resource type of the first individual, the target resource node of the first individual is determined in the resource list. The first individual is an individual that does not meet the preset constraints. The individual Determined based on the genetic algorithm;
根据所述第一个体的目标资源节点,确定第一种群,所述第一种群包括所述第一个体的目标资源节点;Determine a first population according to the target resource node of the first individual, and the first population includes the target resource node of the first individual;
根据所述遗传算法,对所述第一种群进行迭代计算并记录迭代次数;According to the genetic algorithm, iteratively calculate the first population and record the number of iterations;
在所述第一种群的迭代次数达到预设迭代次数的情况下,将当前种群中适应度最高的个体确定为所述第一函数的目标解,所述当前种群为所述第一种群经过预设迭代次数的迭代计算得到的种群。When the number of iterations of the first population reaches the preset number of iterations, the individual with the highest fitness in the current population is determined as the target solution of the first function, and the current population is the preset number of iterations for the first population. Let the number of iterations be the iteratively calculated population.
可选地所述根据所述遗传算法,对所述第一种群进行迭代计算包括:Optionally, the iterative calculation of the first population according to the genetic algorithm includes:
根据遗传算法,计算所述第一种群内个体的适应度;Calculate the fitness of individuals within the first population according to a genetic algorithm;
根据所述遗传算法、所述第一种群内个体的适应度和预设适应度阈值,确定第二种群并进行迭代计算。According to the genetic algorithm, the fitness of individuals in the first population and the preset fitness threshold, the second population is determined and iteratively calculated.
可选地,在一些实施例中,所述根据所述遗传算法、所述交叉概率和所述变异概率,对所述第一种群进行迭代计算包括:Optionally, in some embodiments, the iterative calculation of the first population according to the genetic algorithm, the crossover probability and the mutation probability includes:
计算所述第一种群的M个个体的适应度和所述M个个体的适应度的总和,M为正整数;Calculate the fitness of the M individuals of the first population and the sum of the fitnesses of the M individuals, where M is a positive integer;
根据目标个体的适应度和所述M个个体的适应度的总和,确定所述目标个体的第一概率,所述目标个体为任一所述M个个体,所述第一概率为所述目标个体被挑选到第二种群内的概率;According to the fitness of the target individual and the sum of the fitnesses of the M individuals, the first probability of the target individual is determined, the target individual is any of the M individuals, and the first probability is the target The probability that an individual is selected into the second population;
根据所述目标个体的第一概率,确定所述第二种群,所述第二种群为所述第一种群经过一次迭代后的种群。The second population is determined according to the first probability of the target individual, and the second population is the population after one iteration of the first population.
可选地,在一些实施例中,在第一时长小于预设时长的情况下,所述第一函数为:Optionally, in some embodiments, when the first duration is less than the preset duration, the first function is:
; ;
其中,表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需 的时间,表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需花费的 成本,的取值范围0到1,的取值范围为0到1,且,所述运行状态信息包括每一所 述资源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完成 任务处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所述 第一时刻中最晚的时刻。 in, Indicates the time required to complete the N to-be-completed tasks when the first duration is less than the preset duration, Indicates the cost required to complete the N to-be-completed tasks when the first duration is less than the preset duration, The value range of is 0 to 1, The value range of is 0 to 1, and , the running status information includes the first time of each resource node, the first time is the time when the resource node completes the processing of the to-be-completed task before the target task, and the first duration is the The difference between the second time and the current time. The second time is the latest time among the first time.
可选地,在一些实施例中,在第一时长大于预设时长的情况下,所述第一函数为:Optionally, in some embodiments, when the first duration is greater than the preset duration, the first function is:
; ;
其中,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需 的时间,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需花费的 成本,的取值范围0到1,的取值范围为0到1,且,所述运行状态信息包括每一所 述资源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完成 任务处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所述 第一时刻中最晚的时刻。 in, Indicates the time required to complete the N to-be-completed tasks when the first duration is greater than the preset duration, Indicates the cost required to complete the N to-be-completed tasks when the first duration is longer than the preset duration, The value range of is 0 to 1, The value range of is 0 to 1, and , the running status information includes the first time of each resource node, the first time is the time when the resource node completes the processing of the to-be-completed task before the target task, and the first duration is the The difference between the second time and the current time. The second time is the latest time among the first time.
本发明实施例提供的电子设备,可以执行上述方法实施例,其实现原理和技术效果类似,本实施例此处不再赘述。The electronic device provided by the embodiments of the present invention can execute the above method embodiments, and its implementation principles and technical effects are similar, and will not be described again in this embodiment.
此外,本发明实施例的计算机可读存储介质,用于存储计算机程序,所述计算机程序可被处理器执行实现以下步骤:In addition, the computer-readable storage medium of the embodiment of the present invention is used to store a computer program, and the computer program can be executed by a processor to implement the following steps:
获取目标任务的类型以及资源节点的运行状态信息;Obtain the type of target task and the running status information of the resource node;
在所述目标任务的类型为预设类型的情况下,根据所述目标任务和所述运行状态信息,确定第一函数,其中,所述预设类型表示所述目标任务为N个待完成任务中的第2个待完成任务至第N个待完成任务中的任一待完成任务,所述N个待完成任务依次排列,N为大于1的整数;When the type of the target task is a preset type, a first function is determined based on the target task and the running status information, wherein the preset type indicates that the target task is N tasks to be completed. Any to-be-completed task from the 2nd to N-th to-be-completed task, the N to-be-completed tasks are arranged in sequence, and N is an integer greater than 1;
根据目标算法对所述第一函数进行计算,得到目标解;Calculate the first function according to the target algorithm to obtain the target solution;
根据基于所述目标解确定的目标资源调度方案,调度所述资源节点处理所述目标任务。According to the target resource scheduling plan determined based on the target solution, the resource node is scheduled to process the target task.
可选地,在所述目标算法包括遗传算法和贪心算法的情况下,所述根据目标算法对所述第一函数进行计算,得到目标解包括:Optionally, when the target algorithm includes a genetic algorithm and a greedy algorithm, calculating the first function according to the target algorithm to obtain the target solution includes:
根据所述贪心算法和第一个体的需求资源类型,在资源列表中确定所述第一个体的目标资源节点,所述第一个体为不满足预设约束条件的个体,所述个体基于所述遗传算法确定;According to the greedy algorithm and the required resource type of the first individual, the target resource node of the first individual is determined in the resource list. The first individual is an individual that does not meet the preset constraints. The individual Determined based on the genetic algorithm;
根据所述第一个体的目标资源节点,确定第一种群,所述第一种群包括所述第一个体的目标资源节点;Determine a first population according to the target resource node of the first individual, and the first population includes the target resource node of the first individual;
根据所述遗传算法,对所述第一种群进行迭代计算并记录迭代次数;According to the genetic algorithm, iteratively calculate the first population and record the number of iterations;
在所述第一种群的迭代次数达到预设迭代次数的情况下,将当前种群中适应度最高的个体确定为所述第一函数的目标解,所述当前种群为所述第一种群经过预设迭代次数的迭代计算得到的种群。When the number of iterations of the first population reaches the preset number of iterations, the individual with the highest fitness in the current population is determined as the target solution of the first function, and the current population is the preset number of iterations for the first population. Let the number of iterations be the iteratively calculated population.
可选地,所述根据所述遗传算法,对所述第一种群进行迭代计算包括:Optionally, the iterative calculation of the first population according to the genetic algorithm includes:
根据遗传算法,计算所述第一种群内个体的适应度;Calculate the fitness of individuals within the first population according to a genetic algorithm;
根据所述遗传算法、所述第一种群内个体的适应度和预设适应度阈值,确定第二种群并进行迭代计算。According to the genetic algorithm, the fitness of individuals in the first population and the preset fitness threshold, the second population is determined and iteratively calculated.
可选地,所述根据所述遗传算法、所述交叉概率和所述变异概率,对所述第一种群进行迭代计算包括:Optionally, the iterative calculation of the first population according to the genetic algorithm, the crossover probability and the mutation probability includes:
计算所述第一种群的M个个体的适应度和所述M个个体的适应度的总和,M为正整数;Calculate the fitness of the M individuals of the first population and the sum of the fitnesses of the M individuals, where M is a positive integer;
根据目标个体的适应度和所述M个个体的适应度的总和,确定所述目标个体的第一概率,所述目标个体为任一所述M个个体,所述第一概率为所述目标个体被挑选到第二种群内的概率;According to the fitness of the target individual and the sum of the fitnesses of the M individuals, the first probability of the target individual is determined, the target individual is any of the M individuals, and the first probability is the target The probability that an individual is selected into the second population;
根据所述目标个体的第一概率,确定所述第二种群,所述第二种群为所述第一种群经过一次迭代后的种群。The second population is determined according to the first probability of the target individual, and the second population is the population after one iteration of the first population.
可选地,在第一时长小于预设时长的情况下,所述第一函数为:Optionally, when the first duration is less than the preset duration, the first function is:
; ;
其中,表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需的 时间,表示在第一时长小于预设时长的情况下完成所述N个待完成任务所需花费的成 本,的取值范围0到1,的取值范围为0到1,且,所述运行状态信息包括每一所述 资源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完成任 务处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所述第 一时刻中最晚的时刻。 in, Indicates the time required to complete the N to-be-completed tasks when the first duration is less than the preset duration, Indicates the cost required to complete the N to-be-completed tasks when the first duration is less than the preset duration, The value range of is 0 to 1, The value range of is 0 to 1, and , the running status information includes the first time of each resource node, the first time is the time when the resource node completes the processing of the to-be-completed task before the target task, and the first duration is the The difference between the second time and the current time. The second time is the latest time among the first time.
可选地,在第一时长小于预设时长的情况下,所述第一函数为:Optionally, when the first duration is less than the preset duration, the first function is:
; ;
其中,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需 的时间,表示在第一时长大于预设时长的情况下完成所述N个待完成任务所需花费的 成本, 的取值范围0到1,的取值范围为0到1,且,所述运行状态信息包括每一 所述资源节点的第一时刻,所述第一时刻为所述资源节点将所述目标任务之前的所述待完 成任务处理完成的时刻,第一时长为第二时刻与当前时刻之间的差值,所述第二时刻为所 述第一时刻中最晚的时刻。 in, Indicates the time required to complete the N to-be-completed tasks when the first duration is greater than the preset duration, Indicates the cost required to complete the N to-be-completed tasks when the first duration is longer than the preset duration, The value range of is 0 to 1, The value range of is 0 to 1, and , the running status information includes the first time of each resource node, the first time is the time when the resource node completes the processing of the to-be-completed task before the target task, and the first duration is the The difference between the second time and the current time. The second time is the latest time among the first time.
在本申请所提供的几个实施例中,应该理解到,所揭露方法和装置,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理包括,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in various embodiments of the present invention may be integrated into one processing unit, each unit may be physically included separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
上述以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述收发方法的部分步骤。而前述的存储介质包括:U 盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium and includes a number of instructions to cause a computer device (which can be a personal computer, a server, or a network device, etc.) to execute some steps of the sending and receiving methods described in various embodiments of the present invention. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code. .
以上所述是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明所述原理的前提下,还可以作出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。The above is the preferred embodiment of the present invention. It should be pointed out that for those of ordinary skill in the art, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications can also be made. should be regarded as the protection scope of the present invention.
Claims (7)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311028063.3A CN116755866B (en) | 2023-08-16 | 2023-08-16 | A resource scheduling method, device, electronic equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311028063.3A CN116755866B (en) | 2023-08-16 | 2023-08-16 | A resource scheduling method, device, electronic equipment and readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116755866A CN116755866A (en) | 2023-09-15 |
CN116755866B true CN116755866B (en) | 2024-01-26 |
Family
ID=87951776
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311028063.3A Active CN116755866B (en) | 2023-08-16 | 2023-08-16 | A resource scheduling method, device, electronic equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116755866B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103902375A (en) * | 2014-04-11 | 2014-07-02 | 北京工业大学 | Cloud task scheduling method based on improved genetic algorithm |
CN107977740A (en) * | 2017-11-23 | 2018-05-01 | 海南电网有限责任公司 | A kind of scene O&M intelligent dispatching method |
CN109583709A (en) * | 2018-11-09 | 2019-04-05 | 同济大学 | A kind of automatic parking robot group method for scheduling task |
CN112667379A (en) * | 2020-12-29 | 2021-04-16 | 深圳Tcl新技术有限公司 | Task scheduling method and server |
CN113411369A (en) * | 2020-03-26 | 2021-09-17 | 山东管理学院 | Cloud service resource collaborative optimization scheduling method, system, medium and equipment |
-
2023
- 2023-08-16 CN CN202311028063.3A patent/CN116755866B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103902375A (en) * | 2014-04-11 | 2014-07-02 | 北京工业大学 | Cloud task scheduling method based on improved genetic algorithm |
CN107977740A (en) * | 2017-11-23 | 2018-05-01 | 海南电网有限责任公司 | A kind of scene O&M intelligent dispatching method |
CN109583709A (en) * | 2018-11-09 | 2019-04-05 | 同济大学 | A kind of automatic parking robot group method for scheduling task |
CN113411369A (en) * | 2020-03-26 | 2021-09-17 | 山东管理学院 | Cloud service resource collaborative optimization scheduling method, system, medium and equipment |
CN112667379A (en) * | 2020-12-29 | 2021-04-16 | 深圳Tcl新技术有限公司 | Task scheduling method and server |
Also Published As
Publication number | Publication date |
---|---|
CN116755866A (en) | 2023-09-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2024060571A1 (en) | Heterogeneous computing power-oriented multi-policy intelligent scheduling method and apparatus | |
US11784931B2 (en) | Network burst load evacuation method for edge servers | |
CN108366082B (en) | Capacity expansion method and capacity expansion device | |
CN115292046B (en) | Computing power allocation method, device, storage medium and electronic device | |
CN111813506A (en) | A resource-aware computing migration method, device and medium based on particle swarm optimization | |
CN109788489A (en) | A kind of base station planning method and device | |
CN108845886B (en) | Cloud computing energy consumption optimization method and system based on phase space | |
CN113821318A (en) | Internet of things cross-domain subtask combined collaborative computing method and system | |
CN112165721A (en) | Multi-service task unloading and service migration method based on edge computing | |
CN110162390B (en) | Task allocation method and system for fog computing system | |
CN115934362B (en) | Server-less perception computing cluster scheduling method and product for deep learning | |
CN115314402A (en) | Network element load monitoring method, device, storage medium and electronic device | |
CN113132471B (en) | Cloud service budget optimization scheduling method, device, equipment and storage medium | |
CN114791853A (en) | A Workflow Scheduling Optimization Method Based on Reliability Constraints | |
CN111291893A (en) | Scheduling method, scheduling system, storage medium, and electronic apparatus | |
CN116755866B (en) | A resource scheduling method, device, electronic equipment and readable storage medium | |
CN115016889A (en) | A virtual machine optimization scheduling method for cloud computing | |
CN106802822A (en) | A kind of cloud data center cognitive resources dispatching method based on moth algorithm | |
CN117608754A (en) | Processing method and device for multi-resource pool application, electronic equipment and storage medium | |
CN114363988B (en) | Clustering method and device and electronic equipment | |
CN116668351A (en) | Service quality prediction method, device, computer equipment and storage medium | |
CN112882917B (en) | Virtual machine service quality dynamic prediction method based on Bayesian network migration | |
CN113220414B (en) | A Cloud Workflow Scheduling Method Based on Improved Wealth and Poor Optimization Algorithm | |
CN114666223B (en) | Cloud computing resource pool processing method and device and readable storage medium | |
CN115220890A (en) | Password calculation task scheduling method, device, medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |