Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

LocalUnivariateMinimum parameter range positive and negative problem #672

Open
AidPaike opened this issue May 1, 2023 · 1 comment · May be fixed by #678
Open

LocalUnivariateMinimum parameter range positive and negative problem #672

AidPaike opened this issue May 1, 2023 · 1 comment · May be fixed by #678
Labels
Kind-Enhancement New feature or request Status-NeedsApiReview This PR requires an API review before merging in.

Comments

@AidPaike
Copy link

AidPaike commented May 1, 2023

Positive and negative problems of the tolerance parameter in LocalUnivariateMinimum

Conceptual overview

  1. When calling the LocalUnivariateMinimum function, the search will never stop if the tolerance input is negative, because the bool value of Width(interval) > tolerance is always true.
  2. When the (item1,item2) in argument bounds is item1>item2, the bool value of Width(interval) > tolerance is always false, the program will not enter the search logic.

Current status

  1. mutable tolerance = -1.0;The program will never finish executing

  2. let bounds = (1.0, 0.1); The program will never search

Proposal

New and modified functions, operations, and UDTs

  1. LocalUnivariateMinimum source code

    Adding fact statement:

    Fact(tolerance > 0.0, "The tolerance value must be positive.");

  2. LocalUnivariateMinimum Width source code

    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}");
    }
}
@AidPaike AidPaike added Kind-Enhancement New feature or request Status-NeedsApiReview This PR requires an API review before merging in. labels May 1, 2023
@AidPaike
Copy link
Author

AidPaike commented May 1, 2023

@msoeken I hope that you can spare time to check this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Kind-Enhancement New feature or request Status-NeedsApiReview This PR requires an API review before merging in.
Projects
None yet
1 participant