CN113283706A - Method and device for determining calculation sequence, storage medium and electronic device - Google Patents

Method and device for determining calculation sequence, storage medium and electronic device Download PDF

Info

Publication number
CN113283706A
CN113283706A CN202110450530.6A CN202110450530A CN113283706A CN 113283706 A CN113283706 A CN 113283706A CN 202110450530 A CN202110450530 A CN 202110450530A CN 113283706 A CN113283706 A CN 113283706A
Authority
CN
China
Prior art keywords
attributes
attribute
determining
calculation
directed acyclic
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.)
Pending
Application number
CN202110450530.6A
Other languages
Chinese (zh)
Inventor
涓ュ嘲
严峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Qingdao Haier Technology Co Ltd, Haier Smart Home Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202110450530.6A priority Critical patent/CN113283706A/en
Publication of CN113283706A publication Critical patent/CN113283706A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0631Resource planning, allocation, distributing or scheduling for enterprises or organisations
    • G06Q10/06316Sequencing of tasks or work
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/18Complex mathematical operations for evaluating statistical data, e.g. average values, frequency distributions, probability functions, regression analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Human Resources & Organizations (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Economics (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Operations Research (AREA)
  • Strategic Management (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Databases & Information Systems (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • General Engineering & Computer Science (AREA)
  • Algebra (AREA)
  • Probability & Statistics with Applications (AREA)
  • Evolutionary Biology (AREA)
  • Development Economics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Educational Administration (AREA)
  • Software Systems (AREA)
  • Game Theory and Decision Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Marketing (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for determining a calculation sequence, a storage medium and an electronic device, wherein the method comprises the following steps: obtaining a calculation formula of a plurality of first attributes, wherein the first attributes are determined by a plurality of second attributes; determining a directed acyclic graph with a plurality of first attributes according to a plurality of calculation formulas, wherein nodes of the directed acyclic graph are the plurality of first attributes; and determining reference indexes of the plurality of first attributes according to the directed acyclic graph respectively, and determining a calculation order of the plurality of first attributes through the reference indexes, wherein the reference indexes are used for indicating the times that the first attributes are referred by other first attributes, and the calculation order is used for indicating the calculation order of sequentially determining the plurality of first attributes. By adopting the technical scheme, the problems of low efficiency and the like caused by manually appointing the sequence number of each attribute.

Description

Method and device for determining calculation sequence, storage medium and electronic device
Technical Field
The present invention relates to the field of communications, and in particular, to a method and an apparatus for determining a calculation order, a storage medium, and an electronic apparatus.
Background
Along with the development of science and technology, more and more intelligent household appliances are available in daily life, and in the using process of the intelligent household appliances, a plurality of state attributes are reported to a cloud end, for example, an intelligent electric water heater reports the following attributes: the running state, the current water temperature, the set water temperature, the water tank capacity, the maximum power, the current gear and the like. Based on the basic attributes, in order to implement some service functions, operators and research and development staff may calculate a high-order attribute at the cloud end by using a certain specific calculation formula to represent a specific service meaning, such as a current operating power, a predicted heating duration, and the like. But since some attributes may depend on others during the calculation. For example, the attribute a depends on the result of the attribute B during calculation, while the attribute B depends on the result of the attribute C during calculation, and if the result of the attribute B is not calculated yet during calculation of the attribute a, the value of the attribute a cannot be calculated.
However, this manual assignment of the calculated sequence numbers for the respective attributes is not intelligent enough, wastes time and effort, and may even be erroneous, and if the calculated sequence numbers assigned to the two higher-order attributes are exactly equal, there is no way to determine the calculated order of the respective attributes.
Aiming at the problems of low efficiency and the like caused by manually specifying the calculation sequence number of each attribute in the related art, no effective solution is provided at present.
Disclosure of Invention
The embodiment of the invention provides a method and a device for determining a calculation sequence, a storage medium and an electronic device, which are used for at least solving the problems of low efficiency and the like caused by manually appointing a calculation sequence number of each attribute.
According to an aspect of the embodiments of the present invention, there is provided a method for determining a calculation order, including: obtaining a calculation formula of a plurality of first attributes, wherein the first attributes are determined by a plurality of second attributes; determining a directed acyclic graph of the plurality of first attributes according to a plurality of calculation formulas, wherein nodes of the directed acyclic graph are the plurality of first attributes; and respectively determining reference indexes of the first attributes according to the directed acyclic graph, and determining a calculation order of the first attributes through the reference indexes, wherein the reference indexes are used for indicating the times that the first attributes are referred by other first attributes, and the calculation order is used for indicating the calculation order of sequentially determining the first attributes.
Further, determining a directed acyclic graph of the plurality of first attributes according to a plurality of the computational formulas, comprising: obtaining the dependency relationship of every two first attributes in the plurality of first attributes from the plurality of calculation formulas; and determining the directed acyclic graph according to the dependency relationship and the plurality of first attributes.
Further, determining reference indexes of a plurality of the first attributes according to the directed acyclic graph respectively includes: determining a first target attribute in the directed acyclic graph that is not referenced by the first attribute; and sequentially determining the reference indexes of other first attributes except the target attribute in the directed acyclic graph according to the reference indexes of the first target attribute.
Further, sequentially determining the reference indexes of other first attributes except the target attribute in the directed acyclic graph according to the reference indexes of the first target attribute, including: for any first attribute in other first attributes except the target attribute, acquiring a second target attribute dependent on the any first attribute; and determining the reference index of any first attribute according to the reference index of the second target attribute until determining the reference indexes of all other first attributes.
Further, determining the reference index of any first attribute according to the reference index of the second target attribute comprises: adding a sum to the reference index of the second target attribute to obtain a sum value; and taking the summation value as a reference index of any first attribute.
Further, determining a calculation order of the plurality of first attributes by the reference index includes: sorting the first attributes in sequence from big to small according to the reference indexes of the plurality of first attributes; and sequentially calculating the plurality of first attributes in a descending order.
According to still another aspect of the embodiments of the present invention, there is also provided a device for determining a calculation order, including: the acquisition module is used for acquiring a calculation formula of a plurality of first attributes, wherein the first attributes are determined by a plurality of second attributes; a first determining module, configured to determine a directed acyclic graph of the plurality of first attributes according to a plurality of the calculation formulas, where a node of the directed acyclic graph is the plurality of first attributes; a second determining module, configured to determine reference indexes of the plurality of first attributes according to the directed acyclic graph, and determine a calculation order of the plurality of first attributes according to the reference indexes, where the reference indexes are used to indicate the number of times that the first attributes are referred to by other first attributes, and the calculation order is used to indicate that the calculation order of the plurality of first attributes is sequentially determined.
Further, the first determining module is further configured to obtain a dependency relationship between every two first attributes in the plurality of first attributes from the plurality of calculation formulas; and determining the directed acyclic graph according to the dependency relationship and the plurality of first attributes.
According to still another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium having a computer program stored therein, wherein the computer program is configured to execute the above determination method of the calculation order when running.
According to another aspect of the embodiments of the present invention, there is also provided an electronic apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for determining the calculation order through the computer program.
According to the invention, the calculation formulas of the plurality of first attributes determined by the plurality of second attributes are obtained, then the directed acyclic graph with the plurality of first attributes as nodes is determined according to the calculation formulas, the reference indexes of the plurality of first attributes are respectively determined according to the directed acyclic graph, and the calculation sequence of the plurality of first attributes is determined through the reference indexes. By adopting the technical scheme, the problems of low efficiency and the like caused by manually appointing the calculation sequence number of each attribute are solved. And then the directed acyclic graph of the calculation formula related to the first attributes is determined through the calculation formula of the first attributes, and then the reference indexes of the first attributes are determined according to the directed acyclic graph, so that the calculation sequence of the first attributes is determined, the intelligent processing is realized, the time and the energy are saved, and the error is not easy to occur.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a block diagram of a hardware configuration of a computer terminal of a determination method of a calculation order according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method of determining a calculation order according to an embodiment of the invention;
FIG. 3 is an attribute dependency diagram of a method of determining a computational order according to an embodiment of the invention;
fig. 4 is a block diagram of a configuration of a determination apparatus of a calculation order according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The method embodiments provided in the embodiments of the present application may be executed in a computer terminal or a similar computing device. Taking the example of the present invention running on a computer terminal, fig. 1 is a block diagram of a hardware structure of a computer terminal of a method for determining a calculation sequence according to an embodiment of the present invention. As shown in fig. 1, the computer terminal may include one or more (only one shown in fig. 1) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, and in an exemplary embodiment, may also include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the computer terminal. For example, the computer terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration with equivalent functionality to that shown in FIG. 1 or with more functionality than that shown in FIG. 1.
The memory 104 may be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the determination method of the calculation order in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, so as to implement the above-mentioned method. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to a computer terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
In order to better understand the technical scheme of the invention, some technical terms are described as follows:
basic properties: the attribute reported to the cloud end by the intelligent household appliance comprises an attribute name and a corresponding attribute value, and one intelligent household appliance can report a plurality of basic attributes at one time.
High-order attributes: based on a plurality of basic attributes, the new attribute is calculated by a certain calculation formula.
Order of higher-order attributes: because of the interdependencies in the calculation of the high-order attributes, an algorithm is needed to determine the calculation order of the high-order attributes, and the calculation is carried out according to the order, so that the calculation accuracy can be ensured.
Index of citation: a value describing how often a certain attribute is referred to by all other attributes (not necessarily the exact number of references), for example: d refers to C, C refers to B, B is referred to by C and D, B reference index is equal to 2, C is referred to by D, C reference index is equal to 1, D is not referred to by other attributes, so D reference index is equal to 0.
Directed acyclic graph: a loop-free directed graph, wherein points in the graph represent entities and edges represent relationships (directions) between entities.
Degree of entry: in a directed acyclic graph, the number of edges pointing to a node.
Assume that there are basic attributes of several intelligent appliances: a1, A2, A3, A4, further define several high order attributes and their calculation formulas: b-a 1+ a2, C-B/A3, and D-C-a 4. Then there are the following dependencies between these higher-order attributes: d- > C- > B, namely D depends on C and C depends on B, then B should be calculated, C should be calculated, and D should be calculated finally in the calculation of the attributes. Otherwise, if D is calculated first, the attribute C has no value and cannot be calculated.
In order to solve the above problem, in this embodiment, a method for determining a calculation order is provided, and fig. 2 is a flowchart of the method for determining a calculation order according to the embodiment of the present invention, where the flowchart includes the following steps:
step S202, obtaining a plurality of calculation formulas of first attributes, wherein the first attributes are determined by a plurality of second attributes;
step S204, determining directed acyclic graphs of the plurality of first attributes according to the plurality of calculation formulas, wherein nodes of the directed acyclic graphs are the plurality of first attributes;
step S206, respectively determining reference indexes of a plurality of first attributes according to the directed acyclic graph, and determining a calculation order of the plurality of first attributes through the reference indexes, wherein the reference indexes are used for indicating the times that the first attributes are referred by other first attributes, and the calculation order is used for indicating the calculation order of the plurality of first attributes which are sequentially determined.
Through the steps, a calculation formula of a plurality of first attributes determined by a plurality of second attributes is obtained, then a directed acyclic graph with the plurality of first attributes as nodes is determined according to the calculation formula, reference indexes of the plurality of first attributes are respectively determined according to the directed acyclic graph, and the calculation order of the plurality of first attributes is determined through the reference indexes. By adopting the technical scheme, the problems of low efficiency and the like caused by manually appointing the calculation sequence number of each attribute are solved. And then the directed acyclic graph of the calculation formula related to the first attributes is determined through the calculation formula of the first attributes, and then the reference indexes of the first attributes are determined according to the directed acyclic graph, so that the calculation sequence of the first attributes is determined, the intelligent processing is realized, the time and the energy are saved, and the error is not easy to occur. In order to better understand the step S202, in an alternative embodiment, a calculation formula of a plurality of first attributes is obtained, and it should be noted that the first attributes may be determined by a plurality of second attributes together, or may be determined by a plurality of second attributes together with the remaining first attributes. For example, if there are 6 first attributes: a, B, C, D, E, H, 4 second attributes: a1, a2, A3, a 4. The 6 first attributes may be obtained as a calculation formula of the first attribute C, a. 1+ a2, a calculation formula of the first attribute D, a. 1/a2, a calculation formula of the first attribute B, b.c + D + A3, a calculation formula of the first attribute E, a.e.a. 3, a.a.a. 2, and a calculation formula H of the first attribute H, a. 1 a 4.
It should be noted that there are various ways to execute the step S204, and in an alternative embodiment, the determining the directed acyclic graph of the plurality of first attributes according to a plurality of calculation formulas includes: obtaining the dependency relationship of every two first attributes in the plurality of first attributes from the plurality of calculation formulas; and determining the directed acyclic graph according to the dependency relationship and the plurality of first attributes.
In this implementation, the dependency relationship of every two first attributes in the plurality of first attributes is determined according to the plurality of calculation formulas, and then the directed acyclic graph using the first attributes as nodes is determined according to the every two dependency relationships, which needs to be described that if some first attributes do not depend on the rest of the first attributes, the first attributes already exist in the form of independent points. For example: according to the calculation formula of the 6 first attributes, the first attribute a depends on the first attribute B, the first attribute a depends on the first attribute E, the first attribute B depends on the first attribute C, the first attribute B depends on the first attribute D, the first attribute E depends on the first attribute D, and the first attribute H does not depend on the other 5 first attributes. Then, an attribute dependency graph is determined according to the dependency relationship between the 6 first attributes, fig. 3 is an attribute dependency graph of the determination method of the calculation order according to the embodiment of the present invention, and the attributes a, B, C, D, E, H in fig. 3 correspond to the first attributes a, B, C, D, E, H, respectively, and the first attribute H exists in the form of an independent point because the first attribute H does not refer to the remaining attributes.
In an optional embodiment, the step S206 of determining the reference indexes of the first attributes according to the directed acyclic graph may be implemented by the following technical solutions: determining a first target attribute in the directed acyclic graph that is not referenced by the first attribute; and sequentially determining the reference indexes of other first attributes except the target attribute in the directed acyclic graph according to the reference indexes of the first target attribute.
In this embodiment, it is necessary to first find a first target attribute that is not referenced by a first attribute from the directed acyclic graph of the plurality of first attributes, and then determine reference indexes of other first attributes except for the remaining target attributes according to the reference indexes of the first target attribute. For example, as shown in fig. 3, first target attributes that are not referenced by the first attribute are found from the graph, that is, the first target attributes are a and H, and then the first attributes of the remaining first attributes B, C, D, and E are determined according to the reference index of the first target attribute a. It should be noted that the reference coefficient of the first target attribute is zero.
To better explain how to determine the reference indexes of the remaining first attributes according to the reference index of the first target attribute, in an optional embodiment, sequentially determining the reference indexes of the other first attributes except for the target attribute in the directed acyclic graph according to the reference index of the first target attribute includes: for any first attribute in other first attributes except the target attribute, acquiring a second target attribute dependent on the any first attribute; and determining the reference index of any first attribute according to the reference index of the second target attribute until determining the reference indexes of all other first attributes.
In this embodiment, for determining any index reference index of the first index except the first target attribute, a second target attribute dependent on any first index needs to be obtained first, then the reference index of any first attribute is determined according to the reference index of the second target attribute, and the reference indexes of all the first attributes are calculated by using the same method. For example, for the determination method of the reference index of the first attribute C, it is necessary to determine a second target attribute that depends on the first attribute C, that is, a first attribute B, determine the reference index of the first attribute C according to the reference index of the first attribute B, if the attribute of the first index B is uncertain, then the same second target attribute that depends on the first attribute B needs to be found, and then determine the reference index of the first attribute B, and the above method is adopted until all the reference indexes of the first attribute are determined.
It should be noted that, in an alternative embodiment, determining the reference index of any first attribute according to the reference index of the second target attribute may be implemented by the following techniques: adding a sum to the reference index of the second target attribute to obtain a sum value; and taking the summation value as a reference index of any first attribute.
In this embodiment, it is necessary to add one to the reference indexes of all the second target attributes that depend on any first attribute, and then sum the result of adding one to the reference indexes of all the second target attributes, and according to this sum value, the reference index of any first attribute is taken as, for example: now, it is necessary to determine the reference index of the first attribute D, since there are a plurality of second target attributes depending on the first attribute D, which are respectively the first attribute B and the first attribute E, if the reference index of the first attribute B is 1 and the reference index of the first attribute E is also 1, the reference index of the first attribute B and the reference index of the first attribute E are both added by one, and then summed, that is, (1+1) + (1+1) ═ 4, that is, the reference index of the first attribute D can be determined to be 4.
After calculating the index of all the first attributes, determining a calculation order according to the index of reference is needed, and optionally, determining the calculation order of the plurality of first attributes according to the index of reference includes: sorting the first attributes in sequence from big to small according to the reference indexes of the plurality of first attributes; and sequentially calculating the plurality of first attributes in a descending order.
For example, the above-mentioned first attributes a, B, C, D, E, and H are calculated to obtain that the reference index of the first attribute a is 0, the reference index of the first attribute B is 1, the reference index of the first attribute E is 1, the reference index of the first attribute C is 2, the reference index of the first attribute D is 4, the reference index of the first attribute E is 4, and the reference index of the first attribute H is 0. Then, D, C, B, E, A, H are arranged in sequence from large to small according to the size of the respective reference index. It should be noted that, if the index sizes of the two first attributes are the same, the arrangement order is not limited. Further, it is only necessary to calculate the attribute values of the first target attribute in the above order, and it does not happen that when one first attribute value is calculated, the attribute value of another dependent first attribute is not calculated yet, so that the first attribute value cannot be calculated.
It is to be understood that the above-described embodiments are only a few, but not all, embodiments of the present invention. In order to better understand the determination method of the above calculation sequence, the following describes the above process with reference to an embodiment, but the method is not limited to the technical solution of the embodiment of the present invention, and specifically:
in an alternative embodiment, the order of calculation of the attributes is determined by the following steps:
the method comprises the following steps: a calculation formula of a high-order attribute (equivalent to the first attribute in this embodiment) is obtained, and the interdependence relationship between the calculation formula and the high-order attribute is analyzed, so that a plurality of directed acyclic graphs or independent points are generated.
Step two: setting the index of the independent point to 0;
step three: determining a reference index of a high-order attribute in the directed acyclic graph;
step four: and sequencing all the high-order attributes from large to small according to the reference indexes, and sequentially calculating the high-order attributes according to the sequence.
It should be noted that, in the third step, all the attribute sets S that are not referenced by other high-order attributes (i.e., the in-degree is equal to 0) need to be found first as initial points, each attribute S is polled, i.e., the reference index of the attribute S is initialized to 0 first, and according to the attribute dependent path of S, each dependent attribute of S is traversed, and the reference index is calculated recursively: the reference index of the current attribute ═ Σ (the reference index of the other attributes that depend on this attribute + 1).
In order to better understand the third step, assuming that there are three attributes (attribute a, attribute b, attribute c) in the attribute set S that are not referred to by other high-order attributes, the dependent path of the attribute a is traversed first, and assuming that the attribute a has a dependent path: attribute a depends on attribute e, and attribute e depends on attribute f. The reference index of the attribute a is set to 0, and the values of the attribute e and the attribute f are sequentially determined. The index values of all attributes on the attribute b and attribute c dependency paths are calculated according to the same method, it should be noted that sometimes one attribute may be depended on by two attributes, and all the index values of other attributes dependent on the attribute are added by one and then summed when calculating the index value of the attribute.
In an alternative embodiment, if the dependency graph generated in step one is shown in fig. 3, and the reference index of each attribute is represented by a function Ref, the calculation process is as follows according to the description of step three above:
step (1): firstly, finding all attribute sets which are not depended by other attributes (namely, the in degree is equal to 0), wherein the attribute sets are shown as an attribute A and an attribute H in FIG. 3;
step (2): initializing the index of reference for a and H to be 0, i.e., ref (a) ═ 0, ref (H) ═ 0;
and (3): the attribute H has no dependent attribute, and the calculation is finished;
and (4): the attribute A has 2 dependent attributes B and E, and the Ref values of the dependent attributes B and E are respectively calculated as follows: if the attribute of B is a, ref (B) ═ ref (a) +1 ═ 1, and ref (e) ═ 1 in the same way, and if the dependent attribute of B has C and D, ref (C) ═ ref (B) +1 ═ 2, and ref (D) ═ ref (B) +1+ ref (e) +1 ═ 4;
and (5): the attributes are arranged according to the reverse order of Ref values as follows: d (4) > C (2) > B (1) >, E (1) > a (0) >, H (0), and the order when Ref values are the same is not strict, that is, the order of calculation of the attributes is: d, C, B, E, A and H.
In addition, according to the technical scheme of the embodiment of the invention, the more a certain attribute is depended on by other attributes, namely the larger the reference index is, the calculation needs to be carried out in advance, and the less a certain attribute is depended on, namely the smaller the reference index is, the calculation is delayed, so that the feasibility of the whole calculation can be ensured. Meanwhile, in the scheme, the dependency relationship among the attributes is analyzed by analyzing a calculation formula of the high-order attributes, a directed acyclic graph or an independent point (independent attribute) among the attributes is further constructed based on the dependency relationship among the attributes, and the reference index of all the attributes which are not depended is initialized to be 0. By defining a formula for calculating the quote index: the reference index of the current attribute ═ Σ (reference index +1 of other attributes depending on this attribute), and the reference indices of all attributes can be obtained by recursive calculation.
Furthermore, the technical scheme of the invention realizes intellectualization, namely the calculation sequence of the high-order attributes can be automatically determined according to the dependency relationship among the attributes, and the calculation sequence of the high-order attributes does not need to be manually maintained. Meanwhile, the technical scheme of the invention has flexibility, and after the calculation formula of the high-order attribute is changed, the dependency relationship of the high-order attribute may also be changed, and the calculation sequence of the high-order attribute can be synchronously modified only by recalculating the reference index of each attribute.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
In this embodiment, a device for determining a calculation order is further provided, and the device is used to implement the foregoing embodiments and preferred embodiments, and the description of the device that has been already made is omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementations in hardware or a combination of software and hardware are also possible and contemplated.
Fig. 4 is a block diagram of a device for determining a calculation order according to an embodiment of the present invention, the device including:
an obtaining module 42, configured to obtain a calculation formula of a plurality of first attributes, where the first attributes are determined by a plurality of second attributes;
a first determining module 44, configured to determine a directed acyclic graph of the plurality of first attributes according to a plurality of the calculation formulas, where a node of the directed acyclic graph is the plurality of first attributes;
a second determining module 46, configured to determine reference indexes of the plurality of first attributes according to the directed acyclic graph, and determine a calculation order of the plurality of first attributes according to the reference indexes, where the reference indexes are used to indicate the number of times that the first attributes are referred to by other first attributes, and the calculation order is used to indicate that the calculation order of the plurality of first attributes is determined sequentially.
According to the invention, a device for determining the calculation order is introduced, the calculation formulas of a plurality of first attributes determined by a plurality of second attributes are obtained, then the directed acyclic graph with the plurality of first attributes as nodes is determined according to the calculation formulas, the reference indexes of the plurality of first attributes are respectively determined according to the directed acyclic graph, and the calculation order of the plurality of first attributes is determined through the reference indexes. By adopting the technical scheme, the problems of low efficiency and the like caused by manually appointing the calculation sequence number of each attribute are solved. And then the directed acyclic graph of the calculation formula related to the first attributes is determined through the calculation formula of the first attributes, and then the reference indexes of the first attributes are determined according to the directed acyclic graph, so that the calculation sequence of the first attributes is determined, the intelligent processing is realized, the time and the energy are saved, and the error is not easy to occur.
In an alternative embodiment, the obtaining module 42 is configured to obtain a calculation formula of a plurality of first attributes, and it should be noted that the first attributes may be determined by a plurality of second attributes together, or may be determined by a plurality of second attributes together with the remaining first attributes. For example, if there are 6 first attributes: a, B, C, D, E, H, 4 second attributes: a1, a2, A3, a 4. The 6 first attributes may be obtained as a calculation formula of the first attribute C, a. 1+ a2, a calculation formula of the first attribute D, a. 1/a2, a calculation formula of the first attribute B, b.c + D + A3, a calculation formula of the first attribute E, a.e.a. 3, a.a.a. 2, and a calculation formula H of the first attribute H, a. 1 a 4.
It should be noted that, in an alternative embodiment, the first determining module 44 is configured to obtain the dependency relationship between every two first attributes in the plurality of first attributes from the plurality of calculation formulas; and determining the directed acyclic graph according to the dependency relationship and the plurality of first attributes.
In this implementation, the dependency relationship of every two first attributes in the plurality of first attributes is determined according to the plurality of calculation formulas, and then the directed acyclic graph using the first attributes as nodes is determined according to the every two dependency relationships, which needs to be described that if some first attributes do not depend on the rest of the first attributes, the first attributes already exist in the form of independent points. For example: according to the calculation formula of the 6 first attributes, the first attribute a depends on the first attribute B, the first attribute a depends on the first attribute E, the first attribute B depends on the first attribute C, the first attribute B depends on the first attribute D, the first attribute E depends on the first attribute D, and the first attribute H does not depend on the other 5 first attributes. Then, an attribute dependency graph is determined according to the dependency relationship between the 6 first attributes, fig. 3 is an attribute dependency graph of the determination method of the calculation order according to the embodiment of the present invention, and the attributes a, B, C, D, E, H in fig. 3 correspond to the first attributes a, B, C, D, E, H, respectively, and the first attribute H exists in the form of an independent point because the first attribute H does not refer to the remaining attributes.
In an alternative embodiment, the second determining module 46 is configured to determine a first target attribute in the directed acyclic graph that is not referenced by the first attribute; and sequentially determining the reference indexes of other first attributes except the target attribute in the directed acyclic graph according to the reference indexes of the first target attribute.
In this embodiment, it is necessary to first find a first target attribute that is not referenced by a first attribute from the directed acyclic graph of the plurality of first attributes, and then determine reference indexes of other first attributes except for the remaining target attributes according to the reference indexes of the first target attribute. For example, as shown in fig. 3, first target attributes that are not referenced by the first attribute are found from the graph, that is, the first target attributes are a and H, and then the first attributes of the remaining first attributes B, C, D, and E are determined according to the reference index of the first target attribute a. It should be noted that the reference coefficient of the first target attribute is zero.
In an optional embodiment, the second determining module 46 is further configured to, for any one of the other first attributes except the target attribute, obtain a second target attribute dependent on the any one of the other first attributes; and determining the reference index of any first attribute according to the reference index of the second target attribute until determining the reference indexes of all other first attributes.
In this embodiment, for determining any index reference index of the first index except the first target attribute, a second target attribute dependent on any first index needs to be obtained first, then the reference index of any first attribute is determined according to the reference index of the second target attribute, and the reference indexes of all the first attributes are calculated by using the same method. For example, for the determination method of the reference index of the first attribute C, it is necessary to determine a second target attribute that depends on the first attribute C, that is, a first attribute B, determine the reference index of the first attribute C according to the reference index of the first attribute B, if the attribute of the first index B is uncertain, then the same second target attribute that depends on the first attribute B needs to be found, and then determine the reference index of the first attribute B, and the above method is adopted until all the reference indexes of the first attribute are determined.
It should be noted that, in an alternative embodiment, the second determining module 46 is further configured to add one to the reference index of the second target attribute to obtain a sum value; and taking the summation value as a reference index of any first attribute.
In this embodiment, it is necessary to add one to the reference indexes of all the second target attributes that depend on any first attribute, and then sum the result of adding one to the reference indexes of all the second target attributes, and according to this sum value, the reference index of any first attribute is taken as, for example: now, it is necessary to determine the reference index of the first attribute D, since there are a plurality of second target attributes depending on the first attribute D, which are respectively the first attribute B and the first attribute E, if the reference index of the first attribute B is 1 and the reference index of the first attribute E is also 1, the reference index of the first attribute B and the reference index of the first attribute E are both added by one, and then summed, that is, (1+1) + (1+1) ═ 4, that is, the reference index of the first attribute D can be determined to be 4.
The second determining module 46 is further configured to sort the first attributes in descending order according to the reference indexes of the plurality of first attributes; and sequentially calculating the plurality of first attributes in a descending order.
For example, the above-mentioned first attributes a, B, C, D, E, and H are calculated to obtain that the reference index of the first attribute a is 0, the reference index of the first attribute B is 1, the reference index of the first attribute E is 1, the reference index of the first attribute C is 2, the reference index of the first attribute D is 4, the reference index of the first attribute E is 4, and the reference index of the first attribute H is 0. Then, D, C, B, E, A, H are arranged in sequence from large to small according to the size of the respective reference index. It should be noted that, if the index sizes of the two first attributes are the same, the arrangement order is not limited. Further, it is only necessary to calculate the attribute values of the first target attribute in the above order, and it does not happen that when one first attribute value is calculated, the attribute value of another dependent first attribute is not calculated yet, so that the first attribute value cannot be calculated.
Embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above-mentioned method embodiments when executed.
Alternatively, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
s1, obtaining a plurality of calculation formulas of first attributes, wherein the first attributes are determined by a plurality of second attributes;
s2, determining a directed acyclic graph of the first attributes according to the calculation formulas, wherein the nodes of the directed acyclic graph are the first attributes;
and S3, respectively determining reference indexes of the first attributes according to the directed acyclic graph, and determining the calculation order of the first attributes through the reference indexes, wherein the reference indexes are used for indicating the times that the first attributes are referred by other first attributes, and the calculation order is used for indicating the calculation order of the first attributes which are sequentially determined.
In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary embodiments, and details of this embodiment are not repeated herein.
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, obtaining a plurality of calculation formulas of first attributes, wherein the first attributes are determined by a plurality of second attributes;
s2, determining a directed acyclic graph of the first attributes according to the calculation formulas, wherein the nodes of the directed acyclic graph are the first attributes;
and S3, respectively determining reference indexes of the first attributes according to the directed acyclic graph, and determining the calculation order of the first attributes through the reference indexes, wherein the reference indexes are used for indicating the times that the first attributes are referred by other first attributes, and the calculation order is used for indicating the calculation order of the first attributes which are sequentially determined.
In an exemplary embodiment, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary embodiments, and details of this embodiment are not repeated herein.
It will be apparent to those skilled in the art that the various modules or steps of the invention described above may be implemented using a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and they may be implemented using program code executable by the computing devices, such that they may be stored in a memory device and executed by the computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into various integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for determining a calculation order, comprising:
obtaining a calculation formula of a plurality of first attributes, wherein the first attributes are determined by a plurality of second attributes;
determining a directed acyclic graph of the plurality of first attributes according to a plurality of calculation formulas, wherein nodes of the directed acyclic graph are the plurality of first attributes;
and respectively determining reference indexes of the first attributes according to the directed acyclic graph, and determining a calculation order of the first attributes through the reference indexes, wherein the reference indexes are used for indicating the times that the first attributes are referred by other first attributes, and the calculation order is used for indicating the calculation order of sequentially determining the first attributes.
2. The method of claim 1, wherein determining the directed acyclic graph of the plurality of first attributes according to a plurality of the computational formulas comprises:
obtaining the dependency relationship of every two first attributes in the plurality of first attributes from the plurality of calculation formulas;
and determining the directed acyclic graph according to the dependency relationship and the plurality of first attributes.
3. The method of claim 1, wherein determining the index of reference for the first attributes from the directed acyclic graph comprises:
determining a first target attribute in the directed acyclic graph that is not referenced by the first attribute;
and sequentially determining the reference indexes of other first attributes except the target attribute in the directed acyclic graph according to the reference indexes of the first target attribute.
4. The method according to claim 3, wherein sequentially determining the reference indexes of the other first attributes except the target attribute in the directed acyclic graph according to the reference indexes of the first target attribute comprises:
for any first attribute in other first attributes except the target attribute, acquiring a second target attribute dependent on the any first attribute;
and determining the reference index of any first attribute according to the reference index of the second target attribute until determining the reference indexes of all other first attributes.
5. The method of claim 4, wherein determining the index of reference of any of the first attributes from the index of reference of the second target attribute comprises:
adding a sum to the reference index of the second target attribute to obtain a sum value;
and taking the summation value as a reference index of any first attribute.
6. The method of claim 1, wherein determining the calculation order of the plurality of first attributes from the reference index comprises:
sorting the first attributes in sequence from big to small according to the reference indexes of the plurality of first attributes;
and sequentially calculating the plurality of first attributes in a descending order.
7. An apparatus for determining a calculation order, comprising:
the acquisition module is used for acquiring a calculation formula of a plurality of first attributes, wherein the first attributes are determined by a plurality of second attributes;
a first determining module, configured to determine a directed acyclic graph of the plurality of first attributes according to a plurality of the calculation formulas, where a node of the directed acyclic graph is the plurality of first attributes;
a second determining module, configured to determine reference indexes of the plurality of first attributes according to the directed acyclic graph, and determine a calculation order of the plurality of first attributes according to the reference indexes, where the reference indexes are used to indicate the number of times that the first attributes are referred to by other first attributes, and the calculation order is used to indicate that the calculation order of the plurality of first attributes is sequentially determined.
8. The apparatus according to claim 7, wherein the first determining module is further configured to obtain a dependency relationship between every two first attributes in the plurality of first attributes from the plurality of calculation formulas; and determining the directed acyclic graph according to the dependency relationship and the plurality of first attributes.
9. A computer-readable storage medium, comprising a stored program, wherein the program is operable to perform the method of any one of claims 1 to 6.
10. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 6 by means of the computer program.
CN202110450530.6A 2021-04-25 2021-04-25 Method and device for determining calculation sequence, storage medium and electronic device Pending CN113283706A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110450530.6A CN113283706A (en) 2021-04-25 2021-04-25 Method and device for determining calculation sequence, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110450530.6A CN113283706A (en) 2021-04-25 2021-04-25 Method and device for determining calculation sequence, storage medium and electronic device

Publications (1)

Publication Number Publication Date
CN113283706A true CN113283706A (en) 2021-08-20

Family

ID=77277402

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110450530.6A Pending CN113283706A (en) 2021-04-25 2021-04-25 Method and device for determining calculation sequence, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN113283706A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116263802A (en) * 2022-03-14 2023-06-16 横琴人寿保险有限公司 Computing engine system based on financial field

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116263802A (en) * 2022-03-14 2023-06-16 横琴人寿保险有限公司 Computing engine system based on financial field
CN116263802B (en) * 2022-03-14 2023-08-29 横琴人寿保险有限公司 Computing engine system based on financial field

Similar Documents

Publication Publication Date Title
US9118219B2 (en) Methods and systems for determining an association between nodes and phases via a smart grid
CN106681903B (en) Method and device for generating test case
CN108090142B (en) Card sorting method, device, server and storage medium
CN111541582B (en) Satellite network capacity calculation method and device and electronic equipment
CN113283706A (en) Method and device for determining calculation sequence, storage medium and electronic device
CN110472216B (en) Method and device for determining field, storage medium and electronic device
CN114265927A (en) Data query method and device, storage medium and electronic device
CN108259195A (en) The determining method and system of the coverage of anomalous event
CN110569129A (en) Resource allocation method and device, storage medium and electronic device
CN111159577A (en) Community division method and device, storage medium and electronic device
CN112379906A (en) Service updating method, device, storage medium and electronic device
CN112437462A (en) Quality determination method and device for WIFI module, storage medium and electronic device
CN113918775B (en) Data query method and device and electronic equipment
CN113347083B (en) Network path determination and switching method, device, equipment, medium and program product
CN115879845A (en) Method and device for determining cargo scheduling strategy and nonvolatile storage medium
CN109726820B (en) Energy node importance degree calculation method and device, storage medium and electronic device
CN113986931A (en) Report paging method and device, storage medium and computing equipment
CN114266291A (en) Method and device for determining cluster set, storage medium and electronic device
CN113934490A (en) Opening method and device of equipment control page, storage medium and electronic device
CN113518317A (en) Method and device for sending prompt information, storage medium and electronic device
CN115729885A (en) Device grouping method and apparatus, storage medium, and electronic apparatus
CN111061878A (en) Page clustering method, device, medium and equipment
CN110149234A (en) Diagram data compression method, device, server and storage medium
CN113301138B (en) Position determining method and device of target service node and electronic equipment
CN112488590B (en) Target object classification method and device, storage medium and electronic device

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20210820

RJ01 Rejection of invention patent application after publication