Closed GabrielPonte closed 1 year ago
I would like to say that in some branches, doptf and dopt∇f are different.
I don't think this is possible.
But can't you just write a single function that looks at the current values of x
being passed in? Why do you need to change the entire function?
For example, you could write:
function dopt_f(x...)
if x[1] <= 0
return sum(x[i]^2 for i in 2:length(x))
else
return sum(x[i] for i in 2:length(x))
end
end
It's a really nice idea, thank you! I'm not doing this because I needed some information from the node, and I think this function doesn't accept other arguments as input. Still, I could try to use an auxiliary global variable and set it equal to the node information to help me decide it.
You could try the global variable thing, but be wary. You're likely violating a lot of assumptions about how Juniper works, so there's no guarantee that you won't run into an error or incorrect solution.
Ok, thanks. And is there a way to set an initial solution to KNITRO inside Juniper?
Juniper will Warmstart the continuous solves with solutions that it has available. I assume if you set one initially, it will also use that.
But as a general comment, Juniper is not designed so that you can mess with the solvers deep in the tree.
Understood, thank you so much!
Hi, I'm using Juniper with KNITRO as nl_solver, and I would like to ask two questions about Juniper, please.
Does the final solution from the parent become the initial starting point for the child in the nl_solver?
I set f(x) and the gradient to my model using register(model, :my_dopt_func, n, doptf, dopt∇f). But I would like to change the function and the gradient inside the branch and bound. Is this possible? I have a better formulation, but I can't start from it because it has to satisfy some properties that are only satisfied inside the branch and bound.
Here is the code that I'm using
and I would like to say that in some branches, doptf and dopt∇f are different.
Thank you!