[Ipopt-tickets] [Ipopt] #246: Crash on Java when calculating gradient using multi-threading

Ipopt coin-trac at coin-or.org
Tue Nov 4 04:38:33 EST 2014


#246: Crash on Java when calculating gradient using multi-threading
----------------------+----------------------------------
  Reporter:  shouji   |      Owner:  ipopt-team
      Type:  defect   |     Status:  closed
  Priority:  normal   |  Component:  Ipopt
   Version:  3.3      |   Severity:  blocker
Resolution:  wontfix  |   Keywords:  Java multi-threading
----------------------+----------------------------------
Changes (by stefan):

 * status:  new => closed
 * resolution:   => wontfix


Old description:

> 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), the Java
> program frequently crashed at different points. I've also attached a
> crash report. 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;
>                 }
>         }

New description:

 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), the Java
 program frequently crashed at different points. I've also attached a crash
 report. 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;
                 }
         }
 }}}

--

Comment:

 I don't see anything that is obviously wrong with the code snipet that you
 send and I don't have any way to replicate the problem.

 The crash report doesn't say much. If the crash comes up in the Ipopt
 library itself, compiling it with debugging symbols may give more
 information.

--
Ticket URL: <https://projects.coin-or.org/Ipopt/ticket/246#comment:1>
Ipopt <http://projects.coin-or.org/Ipopt>
Interior-point optimizer for nonlinear programs.



More information about the Ipopt-tickets mailing list