Design component selection using "Quantum annealing". - Page 1
Forum section: electronics / projects

author: azeeman
author_rank: Regular Contributor
timestamp: September 01, 2025, 04:51:52 pm
content: Passive component values are quantized which makes it possible to devise a simple algorithm for component selection. For example, precision resistors values have to be one of 96 different values excluding the multiplier. If the circuit topology is such that a change of one component value results in less than one quanta of change in the other component values, the algorithm will eventually converge.The algorithm itself is very simple, it is fed four things, tolerance range, current component value, target output value and a function used to calculate the output value. A chooser algorithm takes the current component value and calculates the output value, decreases the component value to the next lower quanta then uses the function to calculate a value and finally increases the current component value to the next higher quanta and calculates a value.It then compares the output values to the target value and returns the component value giving the closest match to the target output value and a status value. The status value is -1 if the function failed to return a value, 0 if the component value was unchanged and 1 if the component value was changed.The chooser is applied to all components in the circuit until no component values are changed. If the circuit topology is correct, the algorithm should converge fairly quickly and if not, it will give some indication of where the circuit topology is causing issues.This is a variation of classical annealing where there is a large multidimensional problem space. Because of quantization, the problem space is broken up into smaller fixed volumes where a selected component value has room to bounce around without affecting components in other volumes. The number of possible solutions within the problem space is reduced from an effectively infinite number when continuous values are used to a much smaller number of discrete spaces.The number of spaces can be reduced even further by restricting the component range. If the resistance range is reduced to 1k to 1M range, then one axis of the problem space is 96,000 units long. If four components have to be selected, the problem space is four dimensional and the volume is 96,000^4 or 85e18 units. This is quite large, but sparse and it's possible to estimate part values within an order of magnitude which reduces the problem space volume for a component. If the initial component values are known to within a 10:1 range, the problem space volume is now 960^4 or 849^9 units which is much more manageable. If the initial component values are even closer the problem space can be reduced down to 96^4 = 85^6 units and now a dedicated engineer with a hand calculator could design the circuit within a few years.If non-quantized values are used the problem space volume is constrained only by computation resolution which can be huge. Modern computers can calculate to 64 bit resolution so the problem space volume becomes (2^64)^4 = 2^128 or 340e36.The tolerance range must be sized to match the difference between quanta. If 1% components are used, it will be impossible to have 0.1% tolerance range. The algorithm should still converge because any change in component value will be outside of the tolerance range and a 0 status will be returned.For an example of the algorithm in use, a switched attenuator is required with an extremely wide range while maintaining a constant output resistance. The circuit topology used is based on a ladder network which is very well behaved in terms of sensitivity to component variation.Current loop equations are used as the output function and the 1% resistor series is used to determine quantization. The 1% series has 96 different values so the low component value is calculated by multiplying by just less than 10^(-1/96) or 0.9763 and the high component value calculated by just above 10^(1/96) or 1.0243. This moves the computed value to the next lower or higher quanta.On the attenuator only one switch is active at any time so the output targets are as follows:Ideal full scale voltage outputs for each stage will be as follows with each range 1/3 the previous:V1: 32.805 mVV2: 10.935 mVV3: 3.645 mVV4: 1.215 mVV5: 405 μV6: 135 μVV7: 45 μVV8: 15 μVV9: 5 μVThe maximum DAC output current is also calculated to verify that it is below 1 mA.Python along with Numpy used to solve the loop current matrix is used to implement the algorithm.The algorithm output is as follows:Status None Resistors [50, 1690, 4990, 3010, 8870, 5760, 15000, 7680, 24300, 10200, 30100, 10200, 30100, 10200, 30100, 10200, 30100, 1180, 30100, 1180] Loops 65Output 0.03224309338731206Output 0.011702360942831457Output 0.004130065408941781Output 0.0015584884596604332Output 0.0007238200975696066Output 0.00043473971093527534Output 0.0002929797579069173Output 0.00025050198197658455Output 5.106433601743188e-06Max current input pattern (5, 0, 0, 0, 0, 0, 0, 0, 0) 0.0006448618677462411DAC attenuator output resistance 4831.773325967165The match between the calculated attenuations and desired attenuations is not perfect, but given the complexity of the problem and the constraint of using 1% series resistors, the result is still quite usable. Convergence is also very quick requiring only 65 loops.Incidentally, the ladder technology used is extremely versatile for applications like ultra high resolution trimming. By using a 1.xR:2R ladder network, it is trivial to make a programmable voltage source with 32 bit resolution and a constant output resistance. The resistance ratio is critical in terms of direction, but not in terms of precision. The traditional R:2R ladder network is well known for digital to analog conversion, but only if the R:2R is very precise. If the ratio is 0.75R:2R, the output as a function of the input code is not linear, but it is monotonic. If the input code increases, the output is guaranteed to increase. If the input code decreases, the output is guaranteed to decrease. The actual increase or decrease is not precise, but in an application with feedback, the setting value doesn't matter. One example would be digital auto zeroing of an op-amp input offset. The input code required for zeroing out the offset is not important, only that the output is zero. The network acts as trim pot with potentially millions of turns.If the ratio is 2.25R:2R, the opposite happens, the output becomes non-monotonic and increasing the input can either increase or decrease the output and it becomes unusable in a feedback application.Another advantage of the ladder network is that the output resistance is constant, it can be fed into one side of a bridge circuit without disturbing the bridge resistance balance or in an op-amp circuit where the input offset can be trimmed without affecting the gain.I call this circuit topology an AMU or analog memory unit because it can retain an analog value indefinitely. This analog value can then be used to multiply a voltage source as shown above.I've attached a Python script which exhaustively tests monotonicity and calculates statistics showing ladder performance with random resistance values. Provided that the ratio is skewed sufficiently in the right direction, any resistor tolerance can be used and still have a monotonic output over any number of bits.

author: azeeman
author_rank: Regular Contributor
timestamp: September 01, 2025, 09:09:31 pm
content: Here's a simple proof to show that the quantum annealing program works in log time. If a process has a gain for example compound interest, the output of the process will grow exponentially. As an investment earns money, the money is reinvested and grows more which can then be reinvested for further growth and so on.Conversely, if a process has a loss, the output of the process will decay logarithmically. Once a resistor value has been found, because it has to change a significant amount before it can take on a new value, it will not disturb the search for other resistors. As more resistor values are found, the easier it is to find the other resistor values and the algorithm will converge very quickly as there is less and less interaction between the different components. This is also what I've found to be true in practice.

author: Haenk
author_rank: Super Contributor
timestamp: September 02, 2025, 07:26:18 am
content: Not sure what this approach is good for.In fact this has been solved decades ago - the R2R DACs used laser-trimmed internal resistors, so the "stepped value of components" is a non-issue. And likely the results are much more precise and availabe faster than your iterative approach using switches.Even built with discrete components, you can easily grade components to a much more precise spec, however the discrete approach adds a lot of other issues - that's why it is, besides some HiFi-enthusiast products - never done. And those products measure usually way worse than an integrated DAC...However, your approach has a completely other use: Portioning of food. Imagine you want to sell a pack of 1kg meat. Your input are pieces of 50g to 200g, and you want to be as close to 1kg as possible, and a max of 10g underweight. You need to individually weight the pieces, put them in a selector, and calculate the best combination out of maybe 50 pieces. I assume the algorithm is pretty much the same as you did.

author: azeeman
author_rank: Regular Contributor
timestamp: September 02, 2025, 01:16:43 pm
content: Don't mistake the example for the algorithm. The algorithm will choose components for any circuit as long as there is a function available to calculate the desired output. The circuit shown is difficult to calculate manually and there are many other types of circuits where the algorithm can be used.As for the 1.xR-2R ladder network, it doesn't need laser trimmed resistors to work. I have a 32 bit version made with 1% resistors used to null a voltage down to the nanovolt range. Think of it as a billion turn digitally controlled trimpot. The output is slightly non-linear with respect to the input, but for a lot of applications that is not an issue.The ladder network will also work with 5%, 10%, 20% or any tolerance provided the ratio is skewed correctly.This is very useful for trimming op-amp input offset down to nanovolt range using digital techniques. There's another thread about that.https://www.eevblog.com/forum/metrology/digital-null-meter-design/

author: MariuszD
author_rank: Regular Contributor
timestamp: September 03, 2025, 08:21:09 pm
content: Quote from: azeeman on September 02, 2025, 01:16:43 pmCan you prove that you can set any voltage in range ?I think a converter with values other than precisely matched R2R will be useless even for trimming.Such a converter will have huge DNL errors and many gaps that will not be achievable.An example from a simulation: an 9 bit R2R converter would have subsequent values spaced 1/512 = 0.2% apart, while a 1.5R-2R 9 bit converter has a 14% gap in the middle of its range.

author: azeeman
author_rank: Regular Contributor
timestamp: September 03, 2025, 09:55:50 pm
content: Following are the bit weights for each node of a 32 bit ladder consisting or 562k and 1M resistors. Any output can be constructed by adding the bit weights. As you can see there is less than nanovolt changes at the lower bit weights. The error is proportional to the range. This is a ratio of 562/1,000,000 or 0.562. I assume that as the ratio gets farther from 0.5, the error will increase.The full scale output is 2.40199800133548.If the first 31 bits are added and compared to the 32 bit, the change is 1.1539188796775 to 1.24807912165798 or 0.0941602419804763 which is 3.9% of full range. If balancing nanovolts, it's unlikely that full range will be used. In the circuit I'm using, the op-amp input being balanced out is in the millivolt range where the much higher resolution is required. Also, because the bit weights are known, the true output value can be calculated. Resistor tolerance errors don't propagate through the network because the both the node voltage and error are halved each stage. The only significant errors occur at transitions like 0111 10 1000.The sum of the lowest 15 bits is 9.29E-06 and the next significant bit output is 1.00E-05 or a difference of 7.58E-07 or 758 nanovolts. The sum of all 16 bits is 1.93E-05 the error is 3.92% Although there is significant error, being able to control a voltage down to below nanovolt levels with such a simple circuit using only 1% standard parts is quite useful. Remember that the division ratio is billions and the output resistance of the ladder network is constant regardless of the division ratio. It's possible to buy a gigaohm resistor and use it with a 1 Ohm resistor make a billion to one voltage divider for dividing a DAC output down, but is that practical? In my circuit, I can take my trusty DMM and measure each node of the network and verify that it's working correctly. Creating clean room conditions and buying the equipment to work with gigaohm resistors is way out of my budget.I've attached the Python script used to model the network.I've used a 32 stage network to get down to the nanovolt level, a more practical way would be to use less stages with a much greater division ratio, but this was an experimental circuit where I was trying to null down to microvolts and at the cost of a few more resistors and with available digital outputs, I went to the full 32 stages. I was very surprised to see the circuit null down to the nanovolt level considering both the physical and electrical environment.As for trimming, the output is monotonic. The step sizes will increase as the output increases. The step size error can be made arbitrarily small by just reducing the ratio and using higher precision resistors. The closer the ratio approaches 0.5 without going under, the better the result. If the ratio goes under 0.5, then things get progressively worse as the ratio decreases.There are four types of the network. The perfect 1:2 ratio, the 1:2 ratio with random errors above and below 1:2, a ladder network with the ratio guaranteed to always be above 0.5 and a ladder network with the ratio guaranteed to always be below 0.5. The perfect 1:2 ratio doesn't exist. The ladder with a guaranteed ratio above 0.5 is feasible and has predictable properties. Also, each node is accessible and operates at a relatively high voltage and can easily be calibrated. The highest error is in the most significant stage, the error is halved for each less significant stage so only the upper stages need to be calibrated for high precision applications.Bit weight 1 3.4811917833820547e-10Bit weight 2 7.27983416664156e-10Bit weight 3 1.516974335155362e-09Bit weight 4 3.1585048300038832e-09Bit weight 5 6.5751150393145855e-09Bit weight 6 1.3686939900720092e-08Bit weight 7 2.8490824986330262e-08Bit weight 8 5.930655371425805e-08Bit weight 9 1.2345256562959887e-07Bit weight 10 2.5697891942877423e-07Bit weight 11 5.349274259469206e-07Bit weight 12 1.1135051458472366e-06Bit weight 13 2.3178727577137003e-06Bit weight 14 4.8248848594152625e-06Bit weight 15 1.0043482252108202e-05Bit weight 16 2.0906516670485956e-05Bit weight 17 4.35190134576768e-05Bit weight 18 9.058919580808201e-05Bit weight 19 0.00018857050620262928Bit weight 20 0.00039252844108305426Bit weight 21 0.000817087359852156Bit weight 22 0.0017008493748581694Bit weight 23 0.0035404887385344736Bit weight 24 0.00736988277326715Bit weight 25 0.015341150926575965Bit weight 26 0.03193414590062047Bit weight 27 0.06647413087081368Bit weight 28 0.13837257739040412Bit weight 29 0.2880364124034017Bit weight 30 0.5995767111871109Bit weight 31 1.2480791216579765

author: azeeman
author_rank: Regular Contributor
timestamp: September 04, 2025, 01:04:14 am
content: To calculate the ideal resistor value for the smaller resistor, it's maximum value must be greater than twice the larger. If the tolerance is 0.1% then the smaller resistor's minimum value will be R*0.999*2 >= 1MR>=1M/(1.998)>=500.5K. Plug this into the model and the maximum error between steps is 0.033%.The highest precision digital trim pot I could find is 1024 bits with nominal resistor tolerance of +/- 8%. Since it's 10 bits, the step size is 1/1024 = 0.097%.https://www.analog.com/media/en/technical-documentation/data-sheets/AD5235-EP.pdf.The cost is $35 if bought 10 at a time.A 0.1%, 1M resistor is $0.10 each in quantities of 100. A 16 bit port expander,https://ww1.microchip.com/downloads/aemDocuments/documents/APID/ProductDocuments/DataSheets/MCP23017-Data-Sheet-DS20001952.pdfis $2.63 in quantities of 1. The 500.5k resistor might be problematic, but the vendor says custom values are available. 505k resistors are available and are $0.24 each in quantities of 100. Using 505k with 1 M, the step error is 0.332% This is equivalent to an eight bit digital trim pot in terms of settability, but with 32 bit overall range.The 10 bit digital trim pots could be put in series to get a wider range, but the 8% resistance tolerance range will cause significant error. The overall cost may also be higher.Another option is to use a DAC to drive the ladder network and then the ladder network effectively interpolates between the DAC steps. The ladder step errors are then a fraction of the DAC step and much less problematic. This requires a lot of analog switches, but those are about $0.23 each from DigiKey.https://www.diodes.com/assets/Datasheets/74LVC1G3157.pdfThe 1.xR:2R criteria still applies to guarantee monotonicity, but this could be a cost effective solution to get precision trimming over a wide range with less error. The ladder network is still non-linear, but each bit weighting can easily be calculated and stored in a lookup table to calculate the true output value and adjust the DAC setting accordingly.The greatest error occurs on the most significant stage and high precision resistors can be used on the higher stages to reduce error. For applications like digital auto zero where feedback will be used, monontonicity is critical, while errors will be corrected by the feedback and are not as critical.

author: azeeman
author_rank: Regular Contributor
timestamp: September 04, 2025, 08:30:14 am
content: I've attached a circuit showing a simple way to do low side current measurement using and extended DAC. The extended DAC resolution is 20 bits, while the precision is going to be much less, but it's capable of detecting below 316 nV. The op-amp,https://www.ti.com/lit/ds/symlink/opa607.pdf?ts=1756972529678&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FOPA607,has a maximum input offset of 1 mV. By biasing the input of the op-amp by 1 mV, the DAC can be used to compensate for the offset. To get really fancy, the connection to the shunt can be switched to ground and the DAC used to measure the offset correction.The op-amp has minimum open loop gain of 110 dB or 10^(110/20)=316,000. A digital input has about 100 mV of hysteresis so the minimum sensitivity is 100 mV / 316,000 = 316 nV.Because the feedback loop is digital, noise can be arbitrarily reduced to any level at the expense of speed. If the op-amp output is high, the DAC output can be increased a lot or increased a tiny little bit. If increased by tiny little bits very slowly, the effective bandwidth can be reduced to nanohertz if desired. If the DAC output is increased by large amounts, the bandwidth can be hundreds of kilohertz or even megahertz. It's all software controlled.Even better, for a very low cost solution, the DAC can be replaced by a PWM. The input resistance of the ladder network is constant and about 500k and the input resistance of the op-amp is extremely high so a PWM is practical. To get down to the nanovolt level, additional stages will have to be added to the ladder. Most of the precision is in the DAC, but it would still pay to use high precision resistors in the ladder network. The ladder output is not linear, but the bit weights can be calculated and a lookup table used to convert the DAC setting to a true output voltage. The circuit is easy to model so it's performance can be tested.I've used a variation of this circuit where a 16 bit PWM was used directly for feedback. It was very slow, but the application was controlling the current through a magnetic brake coil. The coil would heat up when in use and the resistance increase. The PWM output was used as a setpoint and the power supply voltage adjusted up and down to keep a constant current. The power supply was also controlled by a PWM because of the low speed required. If the current was too high, the power supply PWM duty cycle would start counting down, if the current was too low, the power supply PWM duty cycle would start counting up. The power supply was simply a three phase generator with triacs, a bridge rectifier and filter capacitor. The triacs were simply switched on and off by an op-amp comparing the power supply output to the setpoint PWM output.In general, I've found that DC single bit digital null detection is far superior to chopper based or analog AC null detection. Because almost everything is digital, software can control everything and software is far more versatile and easy to work with than hardware. The trick is generating extremely low voltages with high resolution to act as feedback. Solve this problem and very low voltage measurement becomes very easy.

author: MariuszD
author_rank: Regular Contributor
timestamp: September 04, 2025, 11:26:06 am
content: For trimming non-monotonic is better because there is no gaps inaccessible with any code.The lack of monotonicity isn't as bad as it seems, the microcontroller needs to check a slightly larger range of codes.

author: azeeman
author_rank: Regular Contributor
timestamp: September 04, 2025, 12:22:48 pm
content: The need for monotonicity depends on the search algorithm. For my applications I have single bit feedback and at the extremes, the feedback code will go up and down by one step. Monotonicity is critical then. The gaps are a problem, but they are completely predictable so allowance can be made for them.

author: MariuszD
author_rank: Regular Contributor
timestamp: September 04, 2025, 03:47:49 pm
content: Quote from: azeeman on September 04, 2025, 12:22:48 pmIf you want to zero the amplifier offset, you can't predict its value in advance or whether it will fall within a gap that your DAC cannot generate. If the offset changes with temperature and requires constant retuning, it will definitely hit such a gap.Quote from: azeeman on September 04, 2025, 12:22:48 pmThis is the simplest algorithm. But with a microcontroller, you can write a better one. If the converter is not monotonic and the input changes across two code ranges, the more accurate "zero" is where only the less significant bits change.Previously, I thought a high-resolution "R2R" converter was useless, but thanks to you, I've realized that one with intentionally introduced non-monotonicity could be useful to me because now I know how to use it.

author: azeeman
author_rank: Regular Contributor
timestamp: September 04, 2025, 05:00:12 pm
content: Thanks for the feedback. I'm still playing with it and trying to understand how to use it. I'm also working on using single bit feedback and finding some interesting results there also. There are numerous ways to apply the feedback. The simplest is the traditional successive approximation, but that requires a sample and hold which is something I want to avoid. I have a tracking algorithm and it seems to lock in on a reading which is very stable regardless of input noise, but the stability point depends on the peak noise value. I have a Python model which seems to match what's happening in the real world. I'll post that once I'm sure that the code is correct.Another simple way is to just increase the DAC a small amount in the direction indicated by the null detector. This is similar to how sigma-delta converters work, but with much less noise on the feedback because the small changes over time is equivalent to integration with a very large time constant. It works great with slow moving signals, but not so well with fast moving signals.The tracking algorithm I'm working on will take 10 sequential measurements and if all 10 are the same and in the same direction as the previous 10 measurements, the feedback will change exponentially. If a measurement is different, the feedback step size will be reduced and the feedback changed accordingly. This results in a very fast ramp up or down to the input voltage and then it essentially locks in place with very little noise on the feedback.A single bit measurement is essentially a coin toss so 10 coin tosses have 2^10 outcomes with the odds of ten ones or ten zeros in a row of 1/1024. For 20 measurements the odds are 1 in 2^20 or 1 in a million so the null direction is definitely correct. This is correct only if each coin toss is independent. But with single bit detection, the readings are not independent. If the differential input voltage on the op-amp is greater than the peak noise, then the noise will have little or no effect on the op-amp output and any number of readings will be the same. If the op-amp output is already pinned to the rail, increasing the voltage difference won't change anything.I think this is why the feedback locks in place. Once the feedback is very close to the input, the differential voltage is close to the peak noise value and the feedback is as likely to go up as it is to go down. Also, the feedback step is very small so it has very little affect on the differential voltage and the feedback value will just sit there.In the Python model, I can control the peak to peak noise precisely and this seems to set the locking point.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 04, 2025, 05:33:39 pm
content: So essentially you have implemented an optimization algorithm to find "optimal" values for a given objective function, from a set of discrete values. That can be useful. I had done something similar a few years ago using an optimization algorithm better at dealing with local optima than the usual gradient descent.I don't know much about quantum annealing apart from the name, but from your description, it seems very simple.

author: azeeman
author_rank: Regular Contributor
timestamp: September 04, 2025, 05:59:14 pm
content: The name is a semi serious joke. Standard components are quantized because they only come in fixed values. The algorithm makes small changes to those values which is how simulated annealing is done.The trick with having quantized parts is that the search volume is massively reduced. If a search algorithm uses continuous values, the number of choices between 1 and 5 is limited only by the numerical resolution. Now try choosing 5 parts, the choices go up by a power of 5. But, if only a few discrete values exist between 1 and 5, the search becomes much simpler.In the algorithm a list of all possible resistor sizes is created within a resistance range like 1k to 1M. Then initial resistor values are estimated and used to start the search.The annealing is done by trying with one standard component value above the current value and one standard component value below the current component value and then see which of the three values gives a result closest to the circuit output target value. For example the 1% resistor series has 96 values and the values go up by 10^(1/96) or 1.024275221 and down by 10^(-1/96) or 0.9763. The previous resistor value is then multiplied by 1.025 to get a high guess and 0.975 to get a low guess. These values are then tested in the circuit. Either the original value is the best choice or the low or high value is better. The multipliers might have to be tuned slightly to make sure that resistor values change.The algorithm runs until none of resistor values change or the circuit function can't be calculated with the given resistor values.This seems like the algorithm would run very slow compared to a continuous value analytic type, but because of the highly constrained values to choose from, the algorithm converges very quickly. It's a brute force and ignorance algorithm since it essentially just tests all possibilities, but because there are so few possibilities to choose from, the search ends up being very fast.

author: azeeman
author_rank: Regular Contributor
timestamp: September 04, 2025, 06:31:52 pm
content: A simpler way to implement quantum annealing is to just create a list of all possible component choices. One list could be used for all components if they fall within a reasonable range or different lists for each component. Then estimate a rough value for each component. The tweak algorithm would then find the closest standard value using a binary search within its list of components. It would the hold a pointer to that component's position in the list and decrement and increment the pointer to find the next lowest and next highest component value. The current component value, lowest and highest value would be tested in the circuit function to see which one gives the closest result. The pointer value of the best component would be held and used in the next iteration to determine new component values. By eliminating the calculation to determine high and low values, the actual component values can be selected directly and more precisely.The list will be small because even over a 1,000 to 1 range there's only 96^3 = 884,736 1% resistor values. This is a tiny number to search with a modern computer. Typically, the initial estimate will be within an order of magnitude and very few values will have to be tested.Of course the circuit has to be well behaved so that small changes in one component value doesn't create disproportional changes in the choice of another component value.When I get a chance I'll clean up the code and incorporate the above. Quantum annealing may not be the ultimate tool for circuit design, but it is handy to have around.

author: azeeman
author_rank: Regular Contributor
timestamp: September 10, 2025, 07:08:43 pm
content: I've reworked the code and come with a more versatile version of the quantum annealer. The fitness is now measured by taking the ratio of the response and target, subtracting from 1 and then taking the absolute value. This is a scale free way of testing because it is insensitive to the absolute target and response values. To determine the quality of the whole solution, all the fitness values are summed and the solution with the lowest total value is considered best.I've also found that while the annealer will generally find the solution over many iterations, a rare almost perfect solution pops up and then the next iteration is way off. In the new version a fixed number of iterations is done and the quality of each solution is measured and the best one saved. After all iterations are done, the best one is used as the solution.Although the algorithm is extremely simple, it works extremely well even for relatively complex circuits. This is not immediately intuitive because the problem space is so large that a simple linear search should take forever. What's actually happening is that the changes in component values are so small that a component can be refined in value without affecting other components until it has changed a significant amount. It's the same with all the other components, their value can't change other than by quantum jumps. They are forced to stay in one quantum state until other components have changed enough to force them to move to the next quantum state. This allows each component to slowly move in the right direction. It's the same process as shaking a box of matches and then having the matches neatly line up in the box.There are two demonstration circuits, a 12 stage ladder attenuator and a simple Schmitt trigger design. The ladder attenuator is very difficult to design analytically and was the original impetus for the quantum annealer. The Schmitt trigger design is easy to design analytically, but it's main purpose is to show how to use the annealer when there are multiple constraints.In the new version, multiple fitness functions can be applied to a single component. In the case of the Schmitt trigger, the feedback resistor has set both the positive and negative hysteresis values and two fitness tests have to be done. There is no limit on the number of components, constraints, fitness functions or stimuli. The number of iterations is currently set to 1,000, but this is purely arbitrary and probably too high. Print statements can be added to display intermediate results to determine whether to reduce or increase the number of iterations. From what I've seen, a really good solution may pop up very early and then a bunch of improving, but still bad solutions, then another really good solution and more improving but still bad solutions and then finally, random reasonably good solutions intermixed with near perfect solutions.Understanding how this simple algorithm works so well is an interesting research project.Although intended for electronic circuits, I think the algorithm could be useful in other situations where choosing from standard component values or sizes need to be done. The hardest part is creating the model and fitness tests.

author: azeeman
author_rank: Regular Contributor
timestamp: September 11, 2025, 12:08:38 pm
content: I found a minor bug in how component fitness is determined. I was using abs(1-response/target) This gives a bias if the one value is positive and the other negative. An unbiased test is abs(1-response^2/target^2).For example abs(1- -2/1)= 3 while abs(1-2/1) = 0.5. With the change, abs(1- -2^2/1^2)= 3 while abs(1- 2^2/1^2) = 3 which is unbiased.The sum of deviations is used for fitness, but this raises the question of which is best, all medium sized errors which sum to the same value as the sum of one big error with smaller errors.The deviations are all positive numbers so a simple measure of error distribution would be the ratio of peak error to total error. I suspect this would not give good results because the annealing process will tend to minimize all errors and any residual errors are minimum.