memoize function to avoid repeat of function evaluation

7 ビュー (過去 30 日間)
mumin chy
mumin chy 2019 年 4 月 29 日
回答済み: Matt J 2019 年 4 月 29 日
I am using memoize function to avoid repeat of function evaluation in a very computationally expensive optimization problem. But I found that my function is not using the value saved as the inputs are slightly difference by 0.1 or 1%. Is there a way that I can used the previously computed function value if the inputs are within a certain range? example: suppose : I had 6 = f(1) , then I don't want to compute f(1.01). I want to use f(1.01) equal to 6. I want to set that if 0.99 <input <1.01 then use the value f(1) rather than computing again.

回答 (1 件)

Matt J
Matt J 2019 年 4 月 29 日
Pre-apply round() or discretize() to the input.

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by