AMPLProcess

class AMPLProcess

An AMPL process.

Fields

_buffer

byte[] _buffer

_messageLength

int _messageLength

amplProcess

protected Process amplProcess

amplexecutable

File amplexecutable

engine

Engine engine

env

Environment env

interpreter

volatile AMPLOutputInterpreter interpreter

interpreterThread

Thread interpreterThread

isSolving

volatile boolean isSolving

isStarted

boolean isStarted

isStopping

protected Boolean isStopping

isTerminateAllowed

protected Boolean isTerminateAllowed

pInput

protected OutputStream pInput

pOutput

protected InputStream pOutput

pb

protected ProcessBuilder pb

startingFlag

boolean startingFlag

version

protected int version

Constructors

AMPLProcess

protected AMPLProcess(Environment env, Engine engine)

Methods

canInterrupt

public boolean canInterrupt()

close

public void close()

Stops the process.

create

public static AMPLProcess create(Environment env, Engine engine)

Starts an AMPL process (class factory, generates process which is platform dependent)

createProcessBuilder

protected ProcessBuilder createProcessBuilder()

getAMPLVersion

int getAMPLVersion()

Returns the ampl version as an integer, getting it from the underlying AMPL interpreter

Parameters:
  • amplPath – Path to ampl executable
  • env – Environment
Throws:
Returns:

AMPL version. If OptiRisk AMPL, the returned integer is negative. So (version <0) returns true if it is an OptiRisk AMPL (it embeds AMPLSIG in windows versions) and abs(version) returns the actual version number

getVersion

int getVersion()

Get stored AMPL version

getWorkingDir

public String getWorkingDir()

interpretAndReturn

void interpretAndReturn(String s, OutputHandler output)

interpretAndReturn

AMPLOutputs interpretAndReturn(String s)

interpretAsync

void interpretAsync(String s, Runnable over, OutputHandler output)

interrupt

public void interrupt()

isBusy

public boolean isBusy()

Returns true if the engine is busy in an async operation

isProcessRunning

public Boolean isProcessRunning()

isStarted

public boolean isStarted()

onBeginSolve

public void onBeginSolve()

onInterrupt

protected void onInterrupt()

When the underlying process is interrupted, need to wait for the reader thread to finish or else we end up with a dirty buffer

setWorkingDir

public void setWorkingDir(String workingdir)

start

public void start()

Starts the underlying process