Okay, I was mistaken. The problem is not solved. It has nothing to do with the number of threads.
I have tried what you suggested.
if (context.inRelaxation() || context.inCandidate() ) {
try {
context.getLongInfo(IloCplex.Callback.Context.Info.NodeUID);
}catch(Exception e) {
System.err.println("Still not working");
}
Version identifier: 20.1.0.0 | 2020-11-10 | 9bedb6d68
CPXPARAM_Emphasis_MIP 2
CPXPARAM_MIP_Strategy_RINSHeur 500
CPXPARAM_TimeLimit 1800
Generic callback 0x66
Lazy constraint(s) or lazy constraint/branch callback is present.
Disabling dual reductions (CPX_PARAM_REDUCE) in presolve.
Disabling presolve reductions that prevent crushing forms (CPX_PARAM_PREREFORM).
Still not working
Still not working
Still not working
------------------------------
Ser Y
------------------------------
Original Message:
Sent: Wed October 13, 2021 10:36 AM
From: Vincent Beraudier
Subject: how to access the node ID inside the generic callback
Some info getters are available only in some contexts otherwise will raise errors.
See https://www.ibm.com/docs/en/icos/20.1.0?topic=manual-cpxcallbackinfo
So NodeUID can be queried only in Relaxation and Candidate, not ThreadUp and not in ThreadDown.
Did you check the context with a
if (context.inRelaxation() || context.inCandidate() )
before calling NodeUID ?
------------------------------
Vincent Beraudier
Original Message:
Sent: Wed October 13, 2021 09:39 AM
From: Ser Y
Subject: how to access the node ID inside the generic callback
Here is more information:
System.out.println("print:" +IloCplex.Callback.Context.Info.NodeUID);
try {
long node_ID= context.getLongInfo(IloCplex.Callback.Context.Info.NodeUID);
}catch(Exception e) {
System.out.println("Something went wrong.");
}
print:NodeUID
Something went wrong.
The way I attach the callback in the main method is;
int numThreads = cplex.getNumCores();
final myCallback cb = new myCallback(x,y,t, numThreads);
long contextmask = IloCplex.Callback.Context.Id.Candidate
| IloCplex.Callback.Context.Id.ThreadUp
| IloCplex.Callback.Context.Id.ThreadDown;
contextmask |= IloCplex.Callback.Context.Id.Relaxation;
cplex.use(cb, contextmask);
------------------------------
Ser Y
Original Message:
Sent: Wed October 13, 2021 08:28 AM
From: Ser Y
Subject: how to access the node ID inside the generic callback
When I call context.getLongInfo(IloCplex.Callback.Context.Info.NodeUID);
I receive the following error and I am using the last version of CPLEX.
Exception from callback: ilog.cplex.CpxException: CPLEX Error 1811: Attempt to invoke unsupported operation..
Exception in thread "main" ilog.cplex.CpxException: CPLEX Error 1006: Error during callback.
at ilog.cplex.CplexI.CALL(CplexI.java:5314)
at ilog.cplex.CplexI.setStatus(CplexI.java:6816)
at ilog.cplex.CplexI.access$600(CplexI.java:191)
at ilog.cplex.CplexI$SolveHandle.stop(CplexI.java:3175)
at ilog.cplex.CplexI.solve(CplexI.java:3225)
at ilog.cplex.CplexI.solve(CplexI.java:3217)
at ilog.cplex.IloCplex.solve(IloCplex.java:13291)
#DecisionOptimization