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

*参考文献见链接

本文主要归纳了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.

Cplex: MIP Control Callback Methods的更多相关文章

  1. Cplex: MIP Control Callback

    *本文主要记录和分享学习到的知识,算不上原创 *参考文献见链接 之前,我们有简单提到Cplex中的MIP Callback Interface,包括了Informational callback, q ...

  2. Cplex: MIP Callback Interface

    *本文主要记录和分享学习到的知识,算不上原创 *参考文献见链接 这篇文章主要记录一些Cplex的Callback的使用方法,采用Java语言. https://www.ibm.com/support/ ...

  3. Tutorial: WPF User Control for AX2012

    原作者: https://community.dynamics.com/ax/b/goshoom/archive/2011/10/06/tutorial-wpf-user-control-for-ax ...

  4. Android图形系统之Surface、SurfaceView、SurfaceHolder及SurfaceHolder.Callback之间的联系

    1.Surface Surface extends Objectimplements Parcelable java.lang.Object    ↳ android.view.Surface Cla ...

  5. 【Leafletjs】5.L.Control 自定义一个Control

    L.Control 所有leaflet控制的基础类.继承自IControl接口. 你可以这样添加控件: control.addTo(map); // the same as map.addContro ...

  6. Overview of Form Control Types [AX 2012]

    Overview of Form Control Types [AX 2012] Other Versions 0 out of 1 rated this helpful - Rate this to ...

  7. A Complete ActiveX Web Control Tutorial

    A Complete ActiveX Web Control Tutorial From: https://www.codeproject.com/Articles/14533/A-Complete- ...

  8. Spring Bean Life Cycle Methods – InitializingBean, DisposableBean, @PostConstruct, @PreDestroy and *Aware interfaces

    Spring Beans are the most important part of any Spring application. Spring ApplicationContext is res ...

  9. java多线程系类:JUC线程池:03之线程池原理(二)(转)

    概要 在前面一章"Java多线程系列--"JUC线程池"02之 线程池原理(一)"中介绍了线程池的数据结构,本章会通过分析线程池的源码,对线程池进行说明.内容包 ...

随机推荐

  1. openstack安装newton版本dashboard+cinder(六)

    一.dashboard 1.安装dashboard及配置 [root@linux-node1 ~]# yum install openstack-dashboard -y #可以装任何地方只要能连接 ...

  2. 正确使用Enum的FlagsAttribute

    正确使用Enum的FlagsAttribute FlagsAttribute 标志枚举对象的值可以包括多个枚举成员,每个成员代表枚举值中的一个位域 使用步骤 添加标记[Flags] 用 2 的幂(即 ...

  3. c#基础值类和引用类型_字符串

    值类型和引用类型区别:1.值类型和引用类型在内存上存储的地方不一样.2.在传递值类型和传递引用类型的时候,传递的方式不一样.值类型我们称之为值传递,引用类型我们称之为引用传递.我们学的值类型和引用类型 ...

  4. [Java]Eclipse无法import “com.sun.management.OperatingSystemMXBean”的解决方法

    背景: 当使用jdk的自带的API获取系统信息时,代码中import “com.sun.management.OperatingSystemMXBean”出现报错. 解决方法: Eclipse默认把这 ...

  5. Dictionary(支持 XML 序列化),注意C#中原生的Dictionary类是无法进行Xml序列化的

    /// <summary> /// Dictionary(支持 XML 序列化) /// </summary> /// <typeparam name="TKe ...

  6. 为什么要用mallloc

    为什么要用malloc函数申请内存空间? 有的程序往往在运行时才知道要动态分配多大的内存,例如: void foo(char *str, int n) { char buf[?]; strncpy(b ...

  7. Python3+Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)

    #!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)'''from sel ...

  8. 安装python3后,没有Scripts目录的解决办法

    设置好python环境变量后,执行命令即可:python -m ensurepip

  9. LeetCode Remove Linked List Elements 删除链表元素

    题意:移除链表中元素值为val的全部元素. 思路:算法复杂度肯定是O(n),那么就在追求更少代码和更少额外操作.我做不出来. /** * Definition for singly-linked li ...

  10. MFC【exe】工程中的文件大致信息(翻译的)

    在工程文件夹中有个readme文件,下面是翻译过来的. ======================================================================== ...