*本文主要记录和分享学习到的知识,算不上原创

*参考文献见链接

本文主要归纳了Cplex的Control callback常用的方法。

目录

    NodeCallback

    SolveCallback

    UserCutCallback

    LazyConstraintCallback

    HeuristicCallback

    BranchCallback

    IncumbentCallback

Control CallBack Interface

If you determine that your application needs to seize control, intervene in the search, and redirect the optimizer, then the following control callbacks are available to do so.

The node callback allows you to query and optionally overwrite the next node CPLEX will process during a branch & cut search.
  IloCplex.NodeCallback
in the Java API
The solve callback allows you to specify and configure the optimizer option to be used for solving the LP at each individual node.
  IloCplex.SolveCallback
in the Java API
The user cut callback allows you to add problem-specific user-defined cuts at each node.
  IloCplex.UserCutCallback
in the Java API
The lazy constraint callback allows you to add lazy constraints; that is, constraints that are not evaluated unless they are violated.
  IloCplex.LazyConstraintCallback
in the Java API
The heuristic callback allows you to implement a heuristic that tries to generate a new incumbent from the solution of the LP relaxation at each node.
  IloCplex.HeuristicCallback
in the Java API
The branch callback allows you to query and optionally overwrite the way CPLEX will branch at each node.
  IloCplex.BranchCallback
in the Java API
The incumbent callback allows you to check and optionally reject incumbents found by CPLEX during the search.
  IloCplex.IncumbentCallback
in the Java API

In Java, there is no way of removing individual callbacks from yourIloCplexorCplexobject. Instead, you remove all callbacks by calling the methodIloCplex.clearCallbacksorCplexClearCallbacks.

Node Callback

getBranchVar(long node)                  Returns the variable that was branched upon to create the node specified by number node.

getDepth(long node)              Returns the depth of the node in the search tree.

getNodeId(long node)                        Returns the node identifier of the node specified by the node number node.

getNodeNumber(IloCplex.NodeId nodeid)              Returns the node number of the node specified by the node identifier.

getObjValue(long node)                   Returns the objective value of the node specified by the node number.

selectNode(long node)           Selects the next node to be processed by its number.

Solve Callback

setStart()                     Specifies a starting point for the next invocation of the method solve during the current solve callback.

solve()                   Solves the current node using the default algorithm (IloCplex.Algorithm.Auto).

solve(int alg)            Solves the current node using the algorithm alg.

useSolution()             Instructs IloCplex to use a solution.

** This method instructs IloCplex to use the solution generated with this callback instead of solving the node itself.

Heuristic Callback

setBounds()                              Sets the bounds for a set of variables.

setSolution()                              Sets a solution to be used as the incumbent.

User Cut Callback

add()                                       Adds a linear global cut to the current subproblem.

**This cut must be globally valid. It will not be removed by backtracking or any other means during the search. The cut must also not cut off any integer feasible solution.

addLocal()                              Adds a linear local cut to the current subproblem.

isAfterCutLoop()                     Returns True if called after the cut loop, False otherwise.

abortCutLoop()                       Terminate the cut loop and proceed with branching.

Lazy Constraint Callback

add(IloRange cut)                        Adds a linear consraint cut as a global lazy constraint to the problem being solved.

** As a lazy constraint, this cut must be globally valid. It will not be removed by backtracking or any other means during the search.

addLocal(IloRange cut)           Adds cut as a local lazy constraint to the problem being solved.

isUnboundedNode()                     This method indicates whether or not the callback was invoked when the LP relaxation is found to be unbounded and the user needs to test whether a lazy constraint cuts off the unbounded direction.

Branch Callback

getBranches()                 Returns one of the candidate branches at the current node if not overridden by the invoking callback.

getBranchType()                         Returns the type of the branch at the current node unless overridden by the invoking callback.

getNbranches()                Returns the number of branches CPLEX is going to create at the current node unless overridden by the invoking callback.

getNodeId()               Returns the node identifier of the current node.

isIntegerFeasible()         Returns true if the current node solution is considered to be integer feasible and thus potentially eligible as a new incumbent, but not suitable for branching.

makeBranch()                           Creates a child node for the current node

prune()                    Removes the current node from the search tree.

Incumbent Callback

getObjValue()             Returns the objective value of the potential incumbent.

reject()                   Rejects the proposed incumbent solution.

Some other methods

setBounds                               Sets the bounds for a set of variables.

setSolution                              Sets a solution to be used as the incumbent.

Abort                                       Aborts current optimization.

GetBestObjValue                    This method returns a bound on the optimal solution value of the active problem at the moment the callback is called.

GetCplexStatus                       Returns the Cplex.CplexStatus for the current node.

GetCplexTime                         This method returns a time stamp, useful in measuring elapsed time in seconds. elapsed time=end time-start time

GetCutoff                                 Returns the cutoff for the objective value when nodes are being solved during branch-and-cut search.

GetEndTime                            This method returns a time stamp specifying when the time limit will occur. remaining time=getEndTime-getCplexTime

GetIncumbentObjValue           Returns the objective value of the current best integer solution at the moment the callback is called. (incumbent: best integer feasible solution)

GetModel                                Returns the model being solved when the invoking callback is called, that is the active model.

GetNiterations                         Returns the total number of iterations for solving node relaxations during the current optimization.

GetNnodes                             Returns the number of nodes processed so far in the active branch-and-cut search.

GetNremainingNodes             Returns the number of nodes remaining to be processed, or, equivalently, the number of active nodes in the tree.

GetObjValue                           Returns the objective function value of the solution of the continuous relaxation of the current node.

GetStartTime                          This method returns a time stamp specifying when the solving process was started.

GetStatus                                Returns the solution status for the current node.

HasIncumbent                        Returns true if an incumbent solution has been found when the callback is called.

Main                                        The method to be implemented by user callback classes.

Solve                                     Solves the current node relaxation using the default algorithm.

最新文章

  1. PHP之打开文件
  2. 【HDU】3853 LOOPS
  3. Android:给ViewPager添加切换效果
  4. Linux Shell编程三
  5. Linux redirect the stdout to a file
  6. 转发:在开发机上绕过Chrome同源策略的办法
  7. CSS3每日一练之内容处理-嵌套编号
  8. FFT修正
  9. [转]VMware 出现下述错误: Application failure. hr=0x80040101:Failed to initialize virtual machine.
  10. 如何在settings里的休眠模式里添加永不休眠
  11. oracle之spool详细使用总结(转)
  12. 二叉树 - 建立与遍历使用Java
  13. mongodb中limit与skip方法
  14. java笔记----获取项目resource中class下的路径
  15. 前后端分离djangorestframework——认证组件
  16. SnowFlake学习
  17. 浅谈前端三大框架Angular、react、vue
  18. ajax登陆页面
  19. 一个基于DPI技术实现了内网资产识别的应用
  20. mysql index hint 在index不存在时的处理

热门文章

  1. docker 在Windows下使用遇到的坑
  2. IntelJ IDEA创建简单Java工程
  3. Android中当item数量超过一定大小RecyclerView高度固定
  4. iOS VIPER架构(三)
  5. Centos 7 搭建git服务器及使用gitolite控制权限
  6. Mysql-数据库及数据表结构和操作
  7. 重温Javascript(三)-继承
  8. win7下一直试用Beyond Compare 4
  9. Lua与游戏的不解之缘
  10. Java设计模式之责任链模式、职责链模式