LocalUnivariateMinimum parameter range positive and negative problem
Positive and negative problems of the tolerance parameter in LocalUnivariateMinimum
Conceptual overview
- When calling the LocalUnivariateMinimum function, the search will never stop if the tolerance input is negative, because the bool value of
Width(interval) > toleranceis alwaystrue. - When the
(item1,item2)in argumentboundsisitem1>item2, the bool value ofWidth(interval) > toleranceis alwaysfalse, the program will not enter the search logic.
Current status
-
mutable tolerance = -1.0;The program will never finish executing -
let bounds = (1.0, 0.1);The program will never search
Proposal
New and modified functions, operations, and UDTs
-
LocalUnivariateMinimum source codehttps://github.com/microsoft/QuantumLibraries/blob/2214d89925e732bd3a10c642885699834cb975fa/Standard/src/Optimization/Univariate.qs#L73 Adding fact statement:
Fact(tolerance > 0.0, "The tolerance value must be positive."); -
LocalUnivariateMinimum Width source codehttps://github.com/microsoft/QuantumLibraries/blob/2214d89925e732bd3a10c642885699834cb975fa/Standard/src/Optimization/Univariate.qs#L28 Adding fact statement:
Fact(left <= right, "Left endpoint of bounds must be less than or equal to right endpoint.");
I hope I will be allowed to submit a pr as soon as possible because this logic problem is serious.
Code
namespace Test {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Optimization;
@EntryPoint()
operation main () : Unit {
//mutable tolerance = -1.0;
mutable tolerance = 0.1;
mutable fn = AbsD;
let bounds = (1.0, 0.1);
//let bounds = (0.1,1.0);
let result = LocalUnivariateMinimum(fn, bounds, tolerance);
Message($"{result}");
}
}
@msoeken I hope that you can spare time to check this issue