Hello to all. I am trying to write a separation algorithm for a branch and boung algorithm. Sadly, like all the people I know who ever had to do this one day, I am not as good in java as in maths, and the web cruelly lacks of examples. My question is "how to tell java to use a constraint?". I have

public class SeparateurArbo extends IloCplex.UserCutCallback {

    // constructor...

    protected void main() throws IloException {
        //... I find the constraint
        IloLinearNumExpr constraint = cplex.linearNumExpr();

        // ...
        IloCplex cplex = new IloCplex();


This gives me the worse java error message I ever saw in my entire life :

# A fatal error has been detected by the Java Runtime Environment:
#  SIGSEGV (0xb) at pc=0x00007ff00e899377, pid=10931, tid=140670663706368
# JRE version: 6.0_45-b06
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.45-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libcplex1260remotejni.so+0x36e377]  _dc08c5413c38b61a7a9d7290e4ecded8+0xd27
# An error report file with more information is saved as:
# /home/angilella/workspace/GponOptimizer/hs_err_pid10931.log
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp

Without the addlocal line, it works perfectly fine, but doesn't add the constraint (so the entire callback becomes useless). I guess I'm not calling this method the proper way, how should I do it? Note that I hate Interfaces and never understood why one would ever create something like that (in this case, IloRange).

If possible, I would like a Minimum Java Knowledge Required Answer (MJKRA, a concept that should be more popular).

Sorry about being so demanding, but most people answering on forums have no idea what amount of (mostly empirical) knowledge is needed in order to read them.

Thanks in advance

Provided an address, I am also willing to send a box of chocolate or foie-gras.

asked 27 Jan '16, 10:24

V%20A's gravatar image

accept rate: 0%

edited 29 Jan '16, 09:51

fbahr's gravatar image

fbahr ♦


The log says that an "error report file with more information is saved" at /home/angilella/workspace/GponOptimizer/hs_err_pid10931.log. Mind to share?

(29 Jan '16, 09:53) fbahr ♦

I'm pretty sure the problem is that you created a brand new IloCplex object (cplex) inside the callback, used it to generate a constraint, and then tried to add that constraint to the original IloCplex object (the one to which the callback is attached).

CPLEX ships with source code (including Java code) for a number models, some of which use callbacks. Their location is typically <CPLEX ROOT>/cplex/examples/src/java/. Take a look at AdMIPex5.java and BendersATSP.java.

I posted Java code for a Benders decomposition example (http://orinanobworld.blogspot.com/2014/08/updated-benders-example.html). It uses a LazyConstraintCallback, but the syntax for a UserCutCallback is essentially the same.


answered 29 Jan '16, 15:46

Paul%20Rubin's gravatar image

Paul Rubin ♦♦
accept rate: 19%

edited 30 Jan '16, 03:18

fbahr's gravatar image

fbahr ♦

You should use a lazy cut callback or an user cut callback depending on your algorithm (the former omits integer infeasible solution, while the latter omits only fractional infeasible solutions). For an example of the correct implementation of these callbacks, see the BendersATSP.java example in your CPLEX installation folder. Within those callback, the getValue() and getValues() methods retreive the value of decision variables and expressions, provided that they have values (see lines 120 and 157 of the example code).

BTW I don't know java, so I cannot help you with more details (I know the details in C++).


answered 27 Jan '16, 13:52

Ehsan's gravatar image

Ehsan ♦
accept rate: 16%

edited 29 Jan '16, 10:12

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 27 Jan '16, 10:24

Seen: 6,783 times

Last updated: 30 Jan '16, 03:18

OR-Exchange! Your site for questions, answers, and announcements about operations research.