Initializing help system before first use

problem.setcbitervar

problem.setcbitervar


Purpose
Set a user callback to be called after each column has been tested for convergence
Synopsis

problem.setcbitervar(callback, object)

retval = callback(my_prob, my_object, colindex)


Arguments
callback 
The function to be called after each column has been tested for convergence. callback returns an integer value. The return value is interpreted as a convergence status. The possible values are:
< 0 
The variable has not converged;
The convergence status of the variable is unchanged;
1 to 10 
The column has converged on a system-defined convergence criterion (these values should not normally be returned);
> 10 
The variable has converged on user criteria.
my_prob 
The problem passed to the callback function.
my_object 
The user-defined object passed as object to setcbitervar.
ColIndex 
The number of the column which has been tested for convergence.
object 
A user-defined object, which can be used for any purpose by the function. object is passed to callback as my_object.
Example
The following example sets up a callback to be executed after each variable has been tested for convergence. The user object Important is an integer array which has already been set up and holds a flag for each variable indicating whether it is important that it converges.
Obj = None
p.setcbitervar(CBIterVar, Obj)
The following sample callback function tests if the variable is already converged. If not, then it checks if the variable is important. If it is not important, the function returns a convergence status of 99.
def CBIterVar(MyProb, Obj, iCol):
  (a,b,c,d,e,f,g,h,i,converged,j,k,l,m,n) = MyProb.getvar(iCol)
  if converged:
    return 0
  if Obj[iCol]:
    return 99
  return -1
The object argument is used here to hold the address of the array Important.
Further information
This callback can be used after each variable has been checked for convergence, and allows the convergence status to be reset if required.
Related topics