Initial test
To begin, open a R console and set the working directory to the directory containing the examples:
setwd(paste(find.package("rAMPL"), "examples", sep="/"))
To complete an initial test, run firstexample.R
with
source("firstexample.R")
firstexample(solver=NULL)
where optionally solver="<solver>"
is the name of a solver that has been installed with AMPL.
(If a solver is not specified, AMPL’s default choice will be used.) This will solve
several small diet problems and then display the optimal amounts of the foods
from the last solution.
Note that the folder containing the AMPL executable should be in the system search path.
Otherwise, the error message “AMPL could not be started” will be shown.
If the AMPL installation directory is not in the system search path,
you can add it passing a new Environment
to AMPL
as follows:
ampl <- new(AMPL, new(Environment, "full path to the AMPL installation directory"))
Note that you may need to escape backslashes (e.g., ‘C:\\ampl\\ampl.mswin64’) if included in the path.