problem.setcbcascadeend
problem.setcbcascadeend |
Purpose
Set a user callback to be called at the end of the cascading process, after the last variable has been cascaded
Synopsis
problem.setcbcascadeend (callback, data)
value = callback (prob, myobject)
Arguments
callback
|
The function to be called at the end of the cascading process.
callback returns an integer value. The return value is noted by Xpress SLP but it has no effect on the optimization.
|
prob
|
The problem passed to the callback function.
|
myobject
|
The user-defined object passed as
data to
setcbcascadeend.
|
data
|
User-defined object, which can be used for any purpose by the function.
data is passed to
callback as
my_object.
|
Example
The following example sets up a callback to be executed at the end of the cascading process which checks if any of the values have been changed significantly:
csol = [1,2,3,4] p.setcbcascadeend (CBCascEnd, csol)
A suitable callback function might resemble this:
def CBCascEnd (prob, obj): for iCol in range (prob.controls.cols): (a,b,c,s,d,e,f,value,g,h,i,j,k,l,m,n) = prob.getvar (iCol) if (abs (value - obj[iCol]) > .01) : print ("Col {0} changed from {1} to {2}".format (iCol, obj[iCol], value) return 0
The
obj argument is used here to hold the original solution values.
Further information
This callback can be used at the end of the cascading, when all the solution values have been recalculated.
Related topics