Options

Stop RM process when timeout occurs

tregoregtregoreg Member Posts: 2 Contributor I
edited November 2018 in Help
Hello,

I'm experimenting with some evolutionary parameter optimization of RM operators. Currently, I'm playing with Kernel PCA operator. Everything works fine, but from time to time, the parameter setting causes the operator to compute for very long time (forever as it seems to me). This is not good for evaluating fitness, so my idea is to bound processing time, and if it takes to long, terminate the process and penalize the individual.

The problem is: how do I terminate the process? I use [tt](new com.rapidminer.Process(xml)).run()[/tt]. I don't even try to use the [tt]stop()[/tt] method of the [tt]Process[/tt] object since the process does not terminate even if i push "Stop" button in RapidMiner's IDE for the same configuration.

After some investigation, I found it to be good idea to use [tt]ExecutorService[/tt] object to invoke the [tt]run()[/tt] method and shutdown if timeout occurs. This works fine and the computation does not freeze, but there's some internal RM's thread which continues working even if the [tt]run()[/tt] method has been shut down. The result is that useless threads accumulate, use more and more CPU and the evolution slows down.

Is there a way how to terminate the process in some hard way if I really don't want it anymore?
Tagged:

Answers

  • Options
    fischerfischer Member Posts: 439 Maven
    Hi,

    you can simply call Process.stop();
    That should terminate the process thread after completion of the current operator. (As you know there is no other way of stopping a running Java thread.)

    Best,
    Simon
  • Options
    tregoregtregoreg Member Posts: 2 Contributor I
    Hi,
    thanks for your reply!
    Simon Fischer wrote:

    That should terminate the process thread after completion of the current operator.
    Actually, the problem is that the current operator is not willing to complete. What I need is to terminate the operator (I suppose it has separate thread), not the process.
  • Options
    fischerfischer Member Posts: 439 Maven
    Hi,

    in Java, you cannot terminate a Thread in a general way. That makes a lot of sense because killing a Thread would not free any allocated resources, run finally blocks, etc. Instead, you must periodically check whether the user requested to stop the process, and that can be done by invoking Operator.checkForStop(). It will automatically raise a ProcessStoppedException to terminate the process execution thread.

    Best,
    Simon
Sign In or Register to comment.