I am somewhat new to C++, and wanted to use this library for a constrained minimization problem. I am practicing with sumt using a simple case $f(x) = x^2$ with initial value $2$, and I intend to minimize $f(x)$ with constraint $x \geq 1$ (i.e. the solution should be $x=1$). However, running the code outputs $x=2$ instead.
From reading the function description on the website, I originally assumed that the constraint function needed to return a vector in the form $[g_1(x), g_2(x)... g_n(x)]$ matching constraint $g_i(x) \geq 0$ for each $i \in 1...n$. This assumption seems to be wrong though, given the output. Could someone please clarify the correct implementation for the constraint function? I have included my code below.
Hello,
I am somewhat new to C++, and wanted to use this library for a constrained minimization problem. I am practicing with sumt using a simple case $f(x) = x^2$ with initial value $2$, and I intend to minimize $f(x)$ with constraint $x \geq 1$ (i.e. the solution should be $x=1$). However, running the code outputs $x=2$ instead.
From reading the function description on the website, I originally assumed that the constraint function needed to return a vector in the form $[g_1(x), g_2(x)... g_n(x)]$ matching constraint $g_i(x) \geq 0$ for each $i \in 1...n$. This assumption seems to be wrong though, given the output. Could someone please clarify the correct implementation for the constraint function? I have included my code below.
Many Thanks, Sam