Treatment of user defined start point when multistart is enabled

41 views
Skip to first unread message

Arvind Venkat

unread,
Jun 1, 2024, 10:32:04 AMJun 1
to Artelys Knitro forum
Dear experts,

I have recently started playing with Knitro 14 (in python) and have a possibly naive question regarding multi-start.

Before enabling multi-start, I have been setting my start point with

    for x in xIndices:
        KN_set_var_primal_init_values(kc, x, initial_guess[x])

Now I enable multi-start, and see multiple solutions popping up. What does Knitro do with my user defined start point above when multi-start is enabled? Does it ignore it in favour of its randomly generated start point? Or does it set the random initial values only for the dual variables?

I ask because, I see different solutions when I don't set the initial point above above with multi-start enabled, compared to when I do.

Additionally, is there some simple way of getting knitro to spit out the start point it is using (when multi-start is enabled, or when it is generating some random start point)? This would allow me to answer my own question. I tried writing a callback which queries the iteration number, but this only seems to be able to get the information after at least one iteration.

Thanks in advance for your help,
Arvind.

Richard Waltz

unread,
Jun 3, 2024, 10:41:54 AMJun 3
to kni...@googlegroups.com
Hi Arvind,

When you provide an initial point to Knitro via "KN_set_var_primal_init_values()" and enable the multi-start procedure, Knitro uses the provided initial point as the initial point for the first multi-start solve.

You should be able to get access to the initial points generated by Knitro multi-start using the "KN_set_ms_initpt_callback()".  See the section "Multi-Start callbacks" here:


From the knitro.h header file:

/** Type declaration for the callback that allows applications to
 *  specify an initial point before each local solve in the multistart
 *  procedure.  On input, arguments "x" and "lambda" are the randomly
 *  generated initial points determined by Knitro, which can be overwritten
 *  by the user.  The argument "nSolveNumber" is the number of the
 *  multistart solve.  Return 0 if successful, a negative error code if not.
 *  Use KN_set_ms_initpt_callback to set this callback function.
 */
typedef int  KN_ms_initpt_callback (      KN_context_ptr  kc,
                                    const KNINT           nSolveNumber,
                                          double * const  x,
                                          double * const  lambda,
                                          void   * const  userParams);

/** Return 0 if successful, a negative error code if not.
 */
int  KNITRO_API KN_set_ms_initpt_callback (KN_context_ptr                 kc,
                                           KN_ms_initpt_callback * const  fnPtr,
                                           void                  * const  userParams);


I believe if you just access the "x" value passed into "KN_ms_initpt_callback()" this will be the Knitro initial point generated for the next multi-start solve.  You can then over-write that "x" if you want to specify your own custom initial point.

Regards,
Richard



From: kni...@googlegroups.com <kni...@googlegroups.com> on behalf of Arvind Venkat <arvindv...@gmail.com>
Sent: Saturday, June 1, 2024 7:28 AM
To: Artelys Knitro forum <kni...@googlegroups.com>
Subject: [Knitro] Treatment of user defined start point when multistart is enabled
 
--
You received this message because you are subscribed to the Artelys "Knitro Nonlinear Optimization Solver" google group.
To post to this group, send email to kni...@googlegroups.com
To unsubscribe from this group, send email to knitro-un...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/knitro?hl=en
Thank You,
Artelys
http://www.artelys.com/en/optimization-tools/knitro
---
You received this message because you are subscribed to the Google Groups "Artelys Knitro forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knitro+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/knitro/95f61646-e1da-4b2a-aa6d-900d0f26f375n%40googlegroups.com.

Arvind Venkat

unread,
Jun 3, 2024, 11:36:02 AMJun 3
to Artelys Knitro forum
Hi Richard,

Thank you very much for your answer. So if KNITRO is using my provided values for the primal variables, is it just using the random values for the dual variables? I ask because I see different solutions from the different solves, so something must be different in the start point.

I am trying to understand how to call KN_ms_initpt_callback from python. I am using the callable API library, but I don't understand how to call this function and have it give me the random x it started with. Should I give it an empty array as input that it will fill with the random x?

Best,
Arvind.

Richard Waltz

unread,
Jun 3, 2024, 12:12:30 PMJun 3
to kni...@googlegroups.com
Hi Arvind,

The attached file shows how to read the "x" value from "KN_ms_initpt_callback".  You need to rename the file "exampleMultiStart.py" to run it.  It is a small modification of the "knitro-14.0.0*/examples/Python/examples/exampleMultiStart.py" problem provided in the Knitro distribution.  In the attached example, I set it to run single-threaded so that the output is more clear.

So if KNITRO is using my provided values for the primal variables, is it just using the random values for the dual variables? 

Knitro has its own specialized procedure for initializing the dual variables.  It does not use random values, but rather tries to initialize them to minimize the KKT error for the given initial "x" value.  As such, providing initial dual variable values does not have much affect usually in Knitro.

I ask because I see different solutions from the different solves, so something must be different in the start point.

Do you mean you see a difference in all the solves when providing an initial point via "KN_set_var_primal_init_values()" versus not providing an initial point this way?  It could be the case, as providing an initial point (even though it's only for the initial solve) may somehow affect the randomly generated initial points for subsequent solves (e.g. maybe the seed changes). 

As a side note, we will have a new Knitro 14.1 release coming out in the next month with improvements to the Knitro multi-start procedure. 

Regards,
Richard




Sent: Monday, June 3, 2024 8:34 AM

To: Artelys Knitro forum <kni...@googlegroups.com>
Subject: Re: [Knitro] Treatment of user defined start point when multistart is enabled
 
exampleMultiStart.txt

Arvind Venkat

unread,
Jun 3, 2024, 12:52:53 PMJun 3
to Artelys Knitro forum
Hi Richard,

Thank you very much for the example. It is simpler than I expected and I am able to get KNITRO to print out the initial start points it uses with multi-start. In fact what I see is that even when I am setting the start point via "KN_set_var_primal_init_values" with multi-start enabled, none of the solves use this start point, and all of them seem to use randomly generated values.

Thank you also for the explanation regarding the dual variables. What you say makes sense.

What I meant before was: when I set the start point by hand, as above, and have multi-start enabled, I see different solutions from the different solves, which seems to be explained by the fact that the different solves use different randomly generated start points.

I am surprised by the number of different local minima found by the multi-start. I think I need to implement some sort of second order test to check if they are all true minima.

Noted about the new KNITRO release. I look forward to it.

Best,
Arvind.

PS: In case it is relevant, I am using the Active Set SQP algorithm

Arvind Venkat

unread,
Jun 4, 2024, 10:07:53 AMJun 4
to Artelys Knitro forum
Hello again,

I did not read your reply, as well as my output logs, carefully enough. Indeed, when I provide a start point, it looks like it is used for the first solve and then randomly generated points are used for subsequent solves. 

But even when I don't provide a point, the callback only seems to report the start point for Solve number 2 onwards ( I attach the output log of running your example, with the line setting the start point commented out).

Is it possible to also get the callback to spit out the start point of the first solve?

Thanks for your help,
Arvind.

output_MultiStart_Richard_noUserInit.txt

Richard Waltz

unread,
Jun 4, 2024, 12:37:53 PMJun 4
to kni...@googlegroups.com
Hi Arvind,

Is it possible to also get the callback to spit out the start point of the first solve?

Unfortunately, this seems to be missing in the current release.  It will be fixed for our Knitro 14.1 release due out soon (hopefully by the end of the month).

Regards,
-Richard

Sent: Tuesday, June 4, 2024 7:06 AM

Arvind Venkat

unread,
Jun 5, 2024, 9:26:54 AMJun 5
to Artelys Knitro forum
Understood. Thanks a lot Richard.

Cheers,
Arvind.

Reply all
Reply to author
Forward
0 new messages