This application is based upon and claims the benefit of priority of the prior Japanese Patent Application No. 2021-159484, filed on Sep. 29, 2021, the entire contents of which are incorporated herein by reference.
The embodiment discussed herein is related to a computer-readable recording medium storing an optimization program, an optimization method, and an optimization apparatus.
A combinatorial optimization problem is used in fields such as manufacturing, finance, and logistics. The combinatorial optimization problem is an optimization problem of which a solution has a combinatorial structure such as an order or an assignment.
As a method of solving a large-scale multivariate optimization problem, there is an optimization apparatus (may also be referred to as an Ising machine or a Boltzmann machine) that uses an Ising-type energy function. The optimization apparatus performs a calculation by replacing a problem subjected to the calculation with an Ising model that is a model representing a behavior of a spin of a magnetic material.
For example, by using a stochastic search method such as simulated annealing, the optimization apparatus obtains, as an optimum solution, a combination of values of respective bits with which a minimum value of a value (referred to as an energy) of the aforementioned Ising-type energy function is obtained. The simulated annealing method is a type of Monte Carlo methods and is a method of stochastically obtaining a solution by using a random number value. Description will be given below by using, as an example, a problem of minimizing a value of an energy function to be optimized. In a case of maximization, the sign of the energy function may be changed. The energy function may also be called as an evaluation function, a cost function, or an objective function.
The Ising model is a model that represents a system of n spins that interact with each other. Each spin (corresponding to a state variable) xi takes a binary value of +1 or −1. An energy E(x) of the entire system is represented by Equation (1) below. Equation (1) is an example of an evaluation function.
E(x)=−Wijxixj−Σibixi (1)
In Equation (1), Wij denotes an interaction coefficient between a spin xi and a spin xj, and bi denotes an external magnetic field coefficient that is a bias value for the entire system. Wij and bi are constants determined in accordance with a problem to be solved.
A candidate for a state transition from a current state to a next state is of inversion of one spin, and there are n candidates. Thus, one spin number or a set of a plurality of spin numbers to be inverted may be generated as a transition candidate.
An energy change ΔEi caused by inversion of an i-th spin is represented by Equation (2) below.
A value in parentheses in Equation (2) is a value of a local field (total input) of a bit i and represents a rate of the energy change caused by inversion of each spin. In Equation (2), if δxi that is an output change and the sign of a local field of the bit i coincide with each other, the energy decreases. In the simulated annealing, the minimum value (or the maximum value) of the energy E is searched for by iterating determination as to whether to make a state transition in accordance with an increase or decrease in ΔEi.
As the related art for searching for the minimum value (or the maximum value) of the energy E, there are Markov Chain Monte Carlo (MCMC) methods.
In the MCMC, an amount of energy change ΔE in a case where the state moves from the current state to a neighboring state is calculated. If the calculated amount of energy change ΔE satisfies a condition, the state transitions to the next state. ΔE is calculated by subtracting an energy E′ after the transition from an energy E before the transition. In the MCMC, a search is performed by stochastically inverting a state (bit). Thermal noise is applied, so that the search does not stay at a local solution.
The case C1 indicates a graph obtained when a width of the applied thermal noise is large (evar=max.). The case C2 indicates a graph obtained when the width of the thermal noise is medium (evar=mid.). The case C3 indicates a graph obtained when the width of the thermal noise is small (evar=min.). In the graphs, a white dot indicates a minimum value (optimum solution) of the energy E, and a black dot indicates a local solution (minimum value in the neighborhood).
In a steepest descent method or the like, at the time of a search for the minimum value of the energy E, once the search gets stuck in a local solution, the search is usually unable to escape therefrom. By contrast, in simulated annealing, application of thermal noise enables movement in a direction in which the energy increases to some extent (gray portions in the figure). In simulated annealing, the width of the thermal noise is reduced gradually from the case C1 to the case C3. Consequently, in simulated annealing, the search that has gotten stuck in the optimum solution is unable to escape therefrom (but is able to escape from a local solution) and finally converges to the optimum solution.
For example, as illustrated in
Then, in the simulated annealing processing of the related art, an acceptance probability (A(ΔEi)) of the state transition is calculated based on the energy increase (ΔEi) (S102). The acceptance probability of the state transition is calculated using Equation of A(ΔEi)=min(1, exp(−ΔEi/T)) (where, T denotes a temperature corresponding to the thermal noise).
Then, in the simulated annealing processing of the related art, based on the calculated acceptance probability (A(ΔEi)) of the state transition, it is determined whether to accept the state transition by using a uniform random number (0<u[i]<1) (S103). In this determination, if u[i]<(A(ΔEi)) (S103: Yes), the bit is inverted and updated (S104: the state transition is accepted). The processing then returns to S101. If u[i]<(A(ΔEi)) is not satisfied (S103: No), the bit is not inverted and the state is maintained (the state transition is not accepted). The processing then returns to S101.
Japanese Laid-open Patent Publication No. 10-293756, Japanese Laid-open Patent Publication No. 9-34951, Japanese Laid-open Patent Publication No. 6-19507, and Japanese Laid-open Patent Publication No. 2020-79991 are disclosed as related art.
According to an aspect of the embodiments, there is provided a non-transitory computer-readable recording medium storing an optimization program for causing a computer to execute optimization processing. In an example, the optimization processing includes: performing a search for a state that serves as a solution through iteration of processing, the processing being configured to determine, by using a difference between a first energy value of an evaluation function based on respective values of a plurality of variables that indicate a first state and a second energy value of the evaluation function based on respective values of the plurality of variables that indicate a second state in which a value of at least one variable among the plurality of variables is changed, whether to accept a state transition from the first state to the second state, and perform the state transition based on a result of the determining; and in the performing of the search for the state, storing the difference between the first energy value in the first state and the second energy value in the second state, and the respective values of the plurality of variables that indicate the second state, in a case where negation of the state transition is consecutively iterated a specific number of times, selecting one state from among the stored second states, based on the differences, and making the state transition from the first state to the selected one state.
The object and advantages of the invention will be realized and attained by means of the elements and combinations particularly pointed out in the claims.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory and are not restrictive of the invention.
However, in the related art described above, when the state transition is consecutively rejected in the determination as to whether to accept the state transition at the time of the search for the optimum solution, the state change does not occur, so that the time in which the search stays at the local solution increases. Consequently, the processing time for obtaining the optimum solution increases. For example, in a case of local optimization or low thermal noise, a state change does not occur and the search stays at a local solution for a long time. This causes an issue in that the efficiency for the search for the optimum solution decreases.
In one aspect, an object is to provide a computer-readable recording medium storing an optimization program, an optimization method, and an optimization apparatus capable of efficiently performing a search for a solution.
An optimization program, an optimization method, and an optimization apparatus according to embodiments will be described below with reference to the drawings. In the embodiments, components having the same functions are denoted by the same reference sign, and redundant description thereof is omitted. The optimization program, the optimization method, and the optimization apparatus described in the embodiments below are merely illustrative and do not intend to limit the embodiments. The individual embodiments below may be appropriately combined with each other within a scope without any contradiction.
The communication unit 10 receives various kinds of data from an external apparatus via a network. The communication unit 10 is an example of a communication device. For example, the communication unit 10 may receive, from the external apparatus, information that is part or entirety of initial setting information 41 (described later).
The input unit 20 is an input device that inputs various kinds of information to the control unit 50 of the optimization apparatus 1. The input unit 20 corresponds to a keyboard, a mouse, a touch panel, or the like. For example, the input unit 20 receives the information that is the part or entirety of the initial setting information 41 (described later) through an input operation performed by a user.
The display unit 30 is a display device that displays information output from the control unit 50. For example, the display unit 30 displays a processing result or the like obtained in the optimization apparatus 1.
The storage unit 40 stores the initial setting information 41, state information 42, and transition candidate information 43. The storage unit 40 corresponds to a semiconductor memory element such as a random-access memory (RAM) or a flash memory, or a storage device such as a hard disk drive (HDD).
The initial setting information 41 is information on initial settings used when an optimum solution of an Ising-type energy function corresponding to an optimization problem is obtained through simulated annealing processing. For example, the initial setting information 41 includes information (such as constants Wij and bi determined in accordance with a problem to be solved) of a model equation of the Ising-type energy function (evaluation function) corresponding to the optimization problem.
The initial setting information 41 also includes an initial temperature of thermal noise, the number of iterations (N), a threshold (M) of the number of consecutive rejections, an initial value (j=0) of a counter (j) for counting the number of consecutive rejections, and the number of candidate states (K) that are used in the simulated annealing processing. The number of consecutive rejections indicates the number of consecutive iterations in which a state transition is not accepted but is rejected in the simulated annealing processing. The initial setting information 41 includes a threshold (TH) for determining a candidate state that serves a candidate for a transition destination.
The state information 42 is information indicating a state (value of each variable (spin)) or the like of the Ising-type energy function used when the optimum solution of the energy function is obtained through the simulated annealing processing. For example, the state information 42 includes information on (value of each variable (spin) of) each of a predetermined number of (for example, M) states (Si) that are set as candidates for the transition destination in the simulated annealing processing, and an energy increase (ΔEi) from an energy before the transition to an energy in each state.
The transition candidate information 43 is information on candidate states that are set as candidates for the next transition destination when rejection of the state transition is iterated without being accepted in the simulated annealing processing. For example, the transition candidate information 43 includes the value of each variable (spin) indicating the candidate state and the energy increase from the energy before the transition to the energy in that candidate state.
The control unit 50 includes an initial state setting unit 51, an energy calculation unit 52, a state holding unit 53, and a calculation control unit 54. The control unit 50 is implemented by a central processing unit (CPU), a graphics processing unit (GPU), or a hard wired logic such as application-specific integrated circuit (ASIC) or a field-programmable gate array (FPGA).
The initial state setting unit 51 is a processing unit that sets an initial state used when the optimum solution of the Ising-type energy function corresponding to the optimization problem is obtained through the simulated annealing processing.
For example, the initial state setting unit 51 receives information on the initial state via the communication unit 10 or the input unit 20. For example, the information on the initial state includes the information on the model equation of the Ising-type energy function (evaluation function) corresponding to the optimization problem, the initial temperature of thermal noise, the number of iterations (N), the threshold (M) of the number of consecutive rejections, and the initial value of the counter (j) for counting the number of consecutive rejections. The information on the initial state also includes the number of candidate states (K) that are set as candidates for the transition destination, and the threshold (TH) for determining the candidate state. The initial state setting unit 51 stores the received information on the initial state in the storage unit 40 as the initial setting information 41.
The energy calculation unit 52 is a processing unit that performs a calculation related to an energy value of the Ising-type energy function (evaluation function) in the simulated annealing processing. For example, based on Equation (1) described above, the energy calculation unit 52 calculates the energy value related to the energy E(x) of the entire system. Based on Equation (2) described above, the energy calculation unit 52 calculates the energy increase (ΔEi) from an energy in the current state to an energy in a state (Si) in which a value of at least one variable among the variables (bits) is changed.
The state holding unit 53 is a processing unit that stores, in the storage unit 40, information on each state in which a value of each variable (each bit) is changed in the simulated annealing processing. For example, the state holding unit 53 stores, in the storage unit 40 as the state information 42, the energy increase (ΔEi) from the energy in the current state to the energy in the state (Si) in which a value of at least one variable among the variables (bits) is changed, which is calculated by the energy calculation unit 52 in the simulated annealing processing, and the value of each variable indicating that state (Si).
If the energy difference (ΔEi) is smaller than a specific value (threshold (TH)), the state holding unit 53 stores the energy difference and the value of each variable indicating the corresponding state (candidate state) in the storage unit 40 as the transition candidate information 43.
The calculation control unit 54 is a processing unit that controls calculation processing (simulated annealing processing) for obtaining the optimum solution. For example, in the simulated annealing processing, the calculation control unit 54 determines whether to accept the state transition, based on the difference (ΔEi) between the energy value of the current state (value of each variable) and the energy value of the state (Si) changed from the current state by bit inversion, calculated by the energy calculation unit 52. By iterating this processing, the calculation control unit 54 searches for a state that serves as the solution.
In a case where negation of the state transition is consecutively iterated a specific number of times when the search for the solution is iteratively performed in such a manner, the calculation control unit 54 selects one state based on the energy difference from among the states included in the stored state information 42. Then, the calculation control unit 54 causes the state to transition from the current state to the selected one state. Thus, the optimization apparatus 1 may avoid a circumstance in which a state change does not occur and the search stays at a local solution for a long time because of consecutive negation of the state transition.
For example, the initial state setting unit 51 receives the information on the initial state via the communication unit 10 or the input unit 20, and sets the initial state of the simulated annealing processing. The setting of the initial state includes, in addition to initial setting of the Ising-type energy function and each variable (bit) in that function, setting of the initial temperature of thermal noise, setting of the number of iterations (N), setting of the threshold (M) of the number of consecutive rejections, and initialization (j=0) of the counter (j) for counting the number of consecutive rejections. The setting of the initial state also includes setting of the number of candidate states (K) that serve as candidates for the transition destination, setting of the threshold (TH) for determining the candidate state, and so on.
Then, the calculation control unit 54 sets a counter (i) of the number of iterations to i=1 (S2), and starts the simulated annealing processing (S3 to S14).
For example, the energy calculation unit 52 randomly or sequentially selects a variable (bit) from the current state (Smin), and calculates the energy increase (ΔEi) caused when the value of the selected variable is changed (when the bit is inverted) in accordance with Equation (2) (S3). In a case where the iteration counter is i=1, the current state (Smin) is the state of the initial setting made in the S1.
Then, the state holding unit 53 causes the storage unit 40 to hold, as the state information 42, the energy increase (ΔEi) calculated by the energy calculation unit 52 and the state (Si) in which the value of the variable is changed (S4).
Then, based on the energy increase (ΔEi) calculated by the energy calculation unit 52, the calculation control unit 54 determines whether to accept, as the transition destination, the state (Si) in which the value of the variable is changed (S5).
For example, the calculation control unit 54 calculates an acceptance probability (A(ΔEi)) of the state transition, based on the energy increase (ΔEi), and determines acceptance or rejection in accordance with whether that probability is equal to or greater than a predetermined value. The calculation control unit 54 may determine acceptance or rejection by using a difference between a uniform random number u[i] and the acceptance probability (A(ΔEi)) of the state transition.
If the state (Si) is accepted as the transition destination (S5: Yes), the calculation control unit 54 updates the current state (Smin) and the energy increase (ΔEmin) corresponding to that state (S6). The processing then proceeds to S10. For example, the calculation control unit 54 replaces ΔEmin with the energy increase (ΔEi) calculated by the energy calculation unit 52. The calculation control unit 54 also sets the state (Si) in which the value of the variable is changed, as the new current state (Smin).
If the state (Si) is not accepted as the transition destination (S5: No), the calculation control unit 54 increments the counter (j) for counting the number of consecutive rejections (j=j+1) (S7).
Then, the calculation control unit 54 determines whether the counter (j) for counting the number of consecutive rejections is equal to the threshold (M) of the number of consecutive rejections (j=M?) (S8). If the counter (j) for counting the number of consecutive rejections is not equal to the threshold (M) of the number of consecutive rejections (S8: No), the calculation control unit 54 causes the processing to proceed to S13.
If the counter (j) for counting the number of consecutive rejections is equal to the threshold (M) for the number of consecutive rejections (S8: Yes), the calculation control unit 54 performs setting processing for setting the state (Smin) that serves as the transition destination and the energy increase (ΔEmin) corresponding to that state (S9). The processing then proceeds to S10.
Then, the calculation control unit 54 selects, as candidate states, K states respectively corresponding to top K energy increases ΔE after the sorting (S21). Then, the calculation control unit 54 randomly selects one of the K selected candidate states and sets the selected candidate state as a new state (Smin) that serves as the transition destination (S22). Then, the calculation control unit 54 sets the energy increase ΔE corresponding to the selected state as ΔEmin (S23).
For example, in the example illustrated in
Referring back to
Then, the calculation control unit 54 determines whether the energy Emin of the entire system calculated by the energy calculation unit 52 satisfies a predetermined condition (Emin<known energy) (S12). The known energy is a known energy value that is the minimum in the evaluation function (energy function), and is set together with the energy function at the time of initial setting or the like, for example.
If the condition is satisfied (S12: Yes), the calculation control unit 54 sets the current state (Si) obtained through the simulated annealing processing (S3 to S14), as the state that serves as the solution. The processing then ends.
If the condition is not satisfied (S12: No), the calculation control unit 54 determines whether the counter (i) of the number of iterations is equal to the number of iterations (N) set as the initial condition (i=N?) (S13). If the counter (i) is equal to the number of iterations (N) (S13: Yes), the calculation control unit 54 sets the current state (Si) as the state that serves as the solution. The processing then ends.
If the counter (i) is not equal to the number of iterations (N) (S13: No), the calculation control unit 54 increments the counter (i) for counting the number of iterations (i=i+1) (S14). The processing then returns to S3.
In the setting processing for setting the state (Smin) that serves as the transition destination and the energy increase (ΔEmin) corresponding to that state in S9, the calculation control unit 54 may select and set one state from among the candidate states included in the transition candidate information 43.
For example, in the S4, the state holding unit 53 stores each energy difference and the value of each variable indicating the corresponding state (candidate state) in the case where the energy difference (ΔEi) is smaller than the specific value (threshold (TH)), in the storage unit 40 as the transition candidate information 43. The calculation control unit 54 randomly selects one of the candidate states included in this transition candidate information 43 and sets the selected candidate state as the new state (Smin) that serves as the transition destination (S22). Then, the calculation control unit 54 sets the energy increase ΔE corresponding to the selected state as ΔEmin (S23).
In S4, the state holding unit 53 may store information on a specific number of candidate states in the storage unit 40 as the transition candidate information 43. For example, in a case where three candidate states are held as the transition candidate information 43, the state holding unit 53 stores the energy difference and the value of each variable indicating the corresponding state (candidate state) in the case where the energy difference is smaller than the specific value (threshold (TH)) up to the third candidate state, in the storage unit 40 as the transition candidate information 43. Then, in a case where three candidate states are held, the state holding unit 53 updates one of the three candidate states with the latest information (the energy difference and the value of each variable indicating that state (candidate state)). For example, the state holding unit 53 updates the oldest information among the three candidate states, with the latest information.
As described above, the optimization apparatus 1 searches for a state that serves as a solution through iteration of processing in which, based on a difference (ΔEi) between an energy value of an evaluation function based on values of respective variables that indicate a current state and an energy value of the evaluation function based on values of the variables that indicate a state (Si) in which a value of at least one variable among the variables is changed, whether to accept a state transition is determined and the state transition is made. In this search, the optimization apparatus 1 stores, as the state information 42, the difference (ΔEi) between the energy in the current state and the energy in the changed state and the values of the respective variables that indicate the changed state (Si). The optimization apparatus 1 selects, based on the energy difference, one state from among the states included in the stored state information 42 in a case where negation of the state transition is consecutively iterated a specific number of times. Then, the optimization apparatus 1 makes the state transition from the current state to the selected one state.
Thus, the optimization apparatus 1 may avoid a circumstance in which, when a search for a state that serves as the solution is performed, a state change does not occur and the search stays at a local solution for a long time. Because this leads to a reduction in processing time for obtaining the optimum solution, the search for the solution may be performed efficiently.
The optimization apparatus 1 selects the one state from a top specific number of the states obtained in a case where the respective energy differences (ΔEi) are sorted in ascending order. For the state (Si) changed from the current state, as the energy difference (ΔEi) becomes smaller, the acceptance probability of the state transition becomes higher. Thus, it may be said that the state is appropriate as the transition destination. Thus, the optimization apparatus 1 may select a state that is more appropriate as the transition destination by sorting the states in ascending order of the energy differences (ΔEi) and selecting one state from among the top specific number of states.
The optimization apparatus 1 stores, as the transition candidate information 43, the energy difference (ΔEi) and values of the respective variables that indicate the corresponding state (candidate state) in a case where the energy difference is smaller than a specific value (threshold (TH)). The optimization apparatus 1 selects one state from among the candidate states included in stored transition candidate information 43. Thus, the optimization apparatus 1 may select one state from among states that are narrowed down in advance and of which the energy difference (ΔEi) is smaller than the specific value.
The optimization apparatus 1 updates one of the specific number of candidate states in the stored transition candidate information 43, with a new candidate state. Thus, the optimization apparatus 1 may avoid an increase in memory usage by making the number of candidate states in the transition candidate information 43 not exceed the specific number.
The optimization apparatus 1 calculates an energy value in the state to which the state transition is made. The optimization apparatus 1 sets the state to which the state transition is made, as the state that serves as the solution in a case where the calculated energy value satisfies a specific condition. Thus, the optimization apparatus 1 may obtain, as the solution, the state of which the energy value of the evaluation function satisfies the specific condition. For example, in a case where a maximum or minimum energy value is known for the energy value of the evaluation function, the optimization apparatus 1 may obtain, as the solution, a state having that energy value.
Note that each component of each apparatus illustrated in the drawings is not necessarily configured physically as illustrated in the drawings. For example, specific forms of distribution and integration in each apparatus are not limited to those illustrated in the drawings. The entirety or part of the apparatus may be configured by being functionally or physically distributed or integrated in arbitrary units in accordance with various loads, usage situations, and the like.
All or arbitrary some of various processing functions of the initial state setting unit 51, the energy calculation unit 52, the state holding unit 53, and the calculation control unit 54 carried out in the control unit 50 of the optimization apparatus 1 may be executed with a CPU (or a microcomputer such as a micro-processor unit (MPU) or a micro-controller unit (MCU)). Needless to say, all of or arbitrary some of the various processing functions may be executed with a program analyzed and executed by the CPU (or a microcomputer such as an MPU or an MCU) or with hardware of wired logic. The various processing functions carried out in the optimization apparatus 1 may be executed in such a manner that a plurality of computers cooperate with each other via cloud computing.
The various kinds of processing described in the embodiment described above may be implemented by execution of a program prepared in advance by a computer. Accordingly, an example of a (hardware) configuration of the computer that executes the program having substantially the same functions as those of the embodiment described above will be described below.
As illustrated in
The hard disk device 207 includes an initial state setting program 207a, an energy calculation program 207b, a state holding program 207c, and a calculation control program 207d. The CPU 201 reads the initial state setting program 207a, the energy calculation program 207b, the state holding program 207c, and the calculation control program 207d and loads the initial state setting program 207a, the energy calculation program 207b, the state holding program 207c, and the calculation control program 207d to the RAM 206.
The initial state setting program 207a functions as an initial state setting process 206a. The energy calculation program 207b functions as an energy calculation process 206b. The state holding program 207c functions as a state holding process 206c. The calculation control program 207d functions as a calculation control process 206d.
Processing of the initial state setting process 206a corresponds to the processing of the initial state setting unit 51. Processing of the energy calculation process 206b corresponds to the processing of the energy calculation unit 52. Processing of the state holding process 206c corresponds to the processing of the state holding unit 53. Processing of the calculation control process 206d corresponds to the processing of the calculation control unit 54.
Each program among the initial state setting program 207a, the energy calculation program 207b, the state holding program 207c, and the calculation control program 207d is not necessarily stored in the hard disk device 207 initially. For example, each program may be stored on a “portable physical medium” such as a flexible disk (FD), a compact disc read-only memory (CD-ROM), a digital versatile disc (DVD), a magneto-optical disk, or an integrated circuit (IC) card to be inserted into the computer 200. The computer 200 may then read and execute each program. Alternatively, each program may be stored in an apparatus coupled to a public network, the Internet, a LAN, or the like, and the computer 200 may read each program from the apparatus and execute the program.
In relation to the embodiment above, the following appendices are further disclosed.
All examples and conditional language provided herein are intended for the pedagogical purposes of aiding the reader in understanding the invention and the concepts contributed by the inventor to further the art, and are not to be construed as limitations to such specifically recited examples and conditions, nor does the organization of such examples in the specification relate to a showing of the superiority and inferiority of the invention. Although one or more embodiments of the present invention have been described in detail, it should be understood that the various changes, substitutions, and alterations could be made hereto without departing from the spirit and scope of the invention.
Number | Date | Country | Kind |
---|---|---|---|
2021-159484 | Sep 2021 | JP | national |