Open fedemagnani opened 1 year ago
Apologies for the very very late reply! I have been very busy over the last couple of months and my access to the internet is currently limited (#360).
Thanks for this detailed and helpful report. Unfortunately I wasn't able to test this myself yet. As a first guess I think that the problem is that you set the gradient 0 whenever the solver it outside of the feasible range. Could you try to change your setup such that the gradient increases the further away it is from the feasible range?
First of all I want to say thanks to all the contributors of this crate, you've done an amazing job.
I'm getting started with argmin running some basic examples. I wanted to run a simple constrained optimization problem finding the minimum of a halfine (
y=x
withx>=0
) starting from the origin using LBFGS as solver. Of course the solution to this problem is x=0 and the minimum is zero. I've implemented the CostFunction and Gradient traits as follows:Where
Floating
is a type alias forf64
. I've tried to incorporate the constraintx>=0
returning100.0
in casex>0
(I tried returningf64::INFINITY
but the code used to panic with errorMoreThuenteLineSearch: NaN or Inf encountered during iteration
).This is the code for solving the problem:
By setting a number of iterations equal to 1, it solves the problem as follows:
And of course the solution is close to zero if not exactly zero. However, by setting a number of iterations
>1
, the code loops endlessly reamaining stuck atx=NaN
,objective=NaN
andgradient=1
Any thoughts?