[Ipopt-tickets] [Ipopt] #245: Crash on Java when calculating gradient using multi-threading
Ipopt
coin-trac at coin-or.org
Mon Oct 6 21:12:49 EDT 2014
#245: Crash on Java when calculating gradient using multi-threading
---------------------------------+------------------------
Reporter: shouji | Owner: ipopt-team
Type: defect | Status: new
Priority: normal | Component: Ipopt
Version: 3.3 | Severity: blocker
Keywords: Java multi-threading |
---------------------------------+------------------------
I use IPOPT by the Java interface (3.3.2). I understand that the IPOPT
itself is not thread-safe, so I tried to calculate the gradient of the
target function by multi-threading as a work-around. Part of my IPOPT code
in Java is listed below.
For input with large number of variables ( n is about 7300), it seems to
run smoothly. However, for small input with small n (about 50), it
frequently crashed at different points. I would like to know if there is a
way to fix that. Thanks.
@Override
protected boolean eval_grad_f(int n, double[] x, boolean new_x,
double[] grad_f) {
try {
assert n == this.n;
ExecutorService executor = Executors
.newFixedThreadPool(numberOfCpu);
Collection<Future<?>> futures = new
LinkedList<Future<?>>();
for (int i = 0; i <= n - 1; i++) {
futures.add(executor.submit(new
GradientCalculationTaskNew(
namfisOptimizerInputData,
grad_f, i)));
}
executor.shutdown();
for (Future<?> future : futures) {
future.get();
}
return true;
} catch (InterruptedException e) {
e.printStackTrace();
return false;
} catch (ExecutionException e) {
e.printStackTrace();
return false;
}
}
--
Ticket URL: <https://projects.coin-or.org/Ipopt/ticket/245>
Ipopt <http://projects.coin-or.org/Ipopt>
Interior-point optimizer for nonlinear programs.
More information about the Ipopt-tickets
mailing list