ampl

package
v0.0.0-...-0c4d5fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// A file to read by default with the path to the AMPL executable
	AMPLLocFile = "amplloc.txt"
)

Variables

This section is empty.

Functions

func ClearAMPLLoc

func ClearAMPLLoc() error

Remove the cached location stored in `amplloc.txt`

func GetAMPLLoc

func GetAMPLLoc() (string, error)

Look for a file called `amplloc.txt` and read the contents if it exists

func PromptAMPLLoc

func PromptAMPLLoc() (string, error)

Present a prompt and try to get the AMPL location on stdin. Cache the location in `amplloc.txt`

Types

type AMPLCommandError

type AMPLCommandError struct {
	// contains filtered or unexported fields
}

Returned when AMPL returns an error trying to run a command

func (*AMPLCommandError) Error

func (self *AMPLCommandError) Error() string

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

An instance of the AMPL binary

func NewRunner

func NewRunner(amplLoc string) (*Runner, error)

Open a new runner using the AMPL binary at `amplLoc`

func (*Runner) RunCommand

func (self *Runner) RunCommand(cmd string) error

Submit a command to the running AMPL binary, with the default timeout for a response. Returns an AMPLCommandError if the command fails, or nil if everything appears successful

func (*Runner) RunCommandTimeout

func (self *Runner) RunCommandTimeout(cmd string, timeout time.Duration) error

Submit a command to the running AMPL binary. Waits for up to `timeout` for an error message from AMPL. Returns an AMPLCommandError

if the command fails, or nil if there is no response. Note that if `timeout` is not long enough we may miss the error message.

func (*Runner) Stop

func (self *Runner) Stop()

Stop the AMPL binary - blocks until the process has ended.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL