SetIntermediateCallback() private method

private SetIntermediateCallback ( IntPtr ipopt_problem, Intermediate_CB intermediate_cb ) : IpoptBoolType
ipopt_problem System.IntPtr
intermediate_cb Intermediate_CB
return IpoptBoolType
Ejemplo n.º 1
0
        public void SetIntermediateCallback_CallbackFunctionDefined_CallbackFunctionCalled()
        {
            const bool expected = true;

            IpoptAdapter.SetIntermediateCallback(_instance, _hs037.intermediate);
            _hs037.hasIntermediateBeenCalled = false;

            var    x = new[] { 10.0, 10.0, 10.0 };
            double obj;

            IpoptAdapter.IpoptSolve(_instance, x, null, out obj, null, null, null, IntPtr.Zero);
            var actual = _hs037.hasIntermediateBeenCalled;

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Setting a callback function for the "intermediate callback"
 /// method in the optimizer.  This gives control back to the user once
 /// per iteration.  If set, it provides the user with some
 /// information on the state of the optimization.  This can be used
 /// to print some user-defined output.  It also gives the user a way
 /// to terminate the optimization prematurely.  If the callback
 /// method returns false, Ipopt will terminate the optimization.
 /// Calling this set method to set the CB pointer to null disables
 /// the intermediate callback functionality.
 /// </summary>
 /// <param name="intermediate_cb">Native intermediate callback function</param>
 /// <returns>true if the callback function could be set successfully, false otherwise</returns>
 public bool SetIntermediateCallback(Intermediate_CB intermediate_cb)
 {
     return(IsInitialized &&
            IpoptAdapter.SetIntermediateCallback(m_problem, m_intermediate_cb = intermediate_cb) == IpoptBoolType.True);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Setting a callback function for the "intermediate callback"
 /// method in the optimizer.  This gives control back to the user once
 /// per iteration.  If set, it provides the user with some
 /// information on the state of the optimization.  This can be used
 /// to print some user-defined output.  It also gives the user a way
 /// to terminate the optimization prematurely.  If the callback
 /// method returns false, Ipopt will terminate the optimization.
 /// Calling this set method to set the CB pointer to null disables
 /// the intermediate callback functionality.
 /// </summary>
 /// <param name="intermediate_cb">Managed intermediate callback function</param>
 /// <returns>true if the callback function could be set successfully, false otherwise</returns>
 public bool SetIntermediateCallback(IntermediateDelegate intermediate_cb)
 {
     return(IsInitialized && IpoptAdapter.SetIntermediateCallback(
                m_problem, m_intermediate_cb = new IntermediateReporter(intermediate_cb).Report) == IpoptBoolType.True);
 }