diff --git a/docs/source/class-structure.rst b/docs/source/class-structure.rst index 4f6cc50..6e159d2 100644 --- a/docs/source/class-structure.rst +++ b/docs/source/class-structure.rst @@ -93,7 +93,7 @@ Commands and options ~~~~~~~~~~~~~~~~~~~~ Some AMPL commands are encapsulated by functions in the :class:`AMPL` class for ease of access. -These comprise :meth:`.AMPL.solve()` and others. +These comprise :meth:`.AMPL.solve("", "")` and others. To access and set options in AMPL, the functions :meth:`.AMPL.getOption()` and :meth:`.AMPL.setOption()` are provided. These functions provide an easier programmatic access to the AMPL options. In general, when an encapsulation is available for an AMPL command, the programmatic access to it is to be preferred to calling the same command using @@ -258,7 +258,7 @@ The currently defined entities are obtained from the various get methods of the (see section :ref:`secAMPLClass`). Once a reference to an entity is created, the entity is automatically kept up-to-date with the corresponding entity in the AMPL interpreter. That is, if a reference to a newly created AMPL variable is obtained by means of :meth:`.AMPL.getVariable()`, and the model the variable is part of is then solved -by means of :meth:`.AMPL.solve()`, the values of the instances of the variable will automatically be updated. +by means of :meth:`.AMPL.solve("", "")`, the values of the instances of the variable will automatically be updated. The following code snippet should demonstrate the concept. .. code-block:: R @@ -271,7 +271,7 @@ The following code snippet should demonstrate the concept. # At this point x$value() evaluates to 0 print(x$value()) # prints 0 - ampl$solve() + ampl$solve("", "") # At this point x$value() evaluates to 10 print(x$value()) # prints 10 diff --git a/docs/source/quick-start.rst b/docs/source/quick-start.rst index 4f3ec02..916dc9f 100644 --- a/docs/source/quick-start.rst +++ b/docs/source/quick-start.rst @@ -30,7 +30,7 @@ This is the complete listing of the example. Please note that, for clarity of pr ampl$readData("models/diet.dat") # Solve - ampl$solve() + ampl$solve("", "") # Get objective entity by AMPL name totalcost <- ampl$getObjective("Total_Cost") @@ -43,7 +43,7 @@ This is the complete listing of the example. Please note that, for clarity of pr cat("Increased costs of beef and ham.\n") # Resolve and display objective - ampl$solve() + ampl$solve("", "") cat(sprintf("New objective value: %g\n", totalcost$value())) # Reassign data - all instances @@ -52,7 +52,7 @@ This is the complete listing of the example. Please note that, for clarity of pr cat("Updated all costs.\n") # Resolve and display objective - ampl$solve() + ampl$solve("", "") cat(sprintf("New objective value: %g\n", totalcost$value())) # Get the values of the variable Buy in a dataframe object @@ -123,7 +123,7 @@ To solve the currently loaded problem instance, it is sufficient to issue the co .. code-block:: R - ampl$solve() + ampl$solve("", "") Get an AMPL entity in the programming environment (get objective value) @@ -175,7 +175,7 @@ values is overloaded, and is in both cases :meth:`Parameter.setValues()`. cost <- ampl$getParameter("cost") cost$setValues(data.frame(index=c("BEEF", "HAM"), value=c(5.01, 4.55))) cat("Increased costs of beef and ham.\n") - ampl$solve() + ampl$solve("", "") cat(sprintf("New objective value: %g\n", totalcost$value())) The code above assigns the values 5.01 and 4.55 to the parameter cost for the objects beef and ham respectively. @@ -186,7 +186,7 @@ both the index and the value. A collection of values is assigned to each of the cost$setValues(c(3, 5, 5, 6, 1, 2, 5.01, 4.55)) cat("Updated all costs.\n") - ampl$solve() + ampl$solve("", "") cat(sprintf("New objective value: %g\n", totalcost$value())) The statements above produce the following output:: diff --git a/docs/source/reference/ramplcpp.rst b/docs/source/reference/ramplcpp.rst index 208342b..41adf42 100644 --- a/docs/source/reference/ramplcpp.rst +++ b/docs/source/reference/ramplcpp.rst @@ -203,7 +203,7 @@ AMPL Returns ``TRUE`` if the underlying engine is running. -.. method:: AMPL.solve() +.. method:: AMPL.solve("", "") Solve the current model. diff --git a/examples/dietmodel.R b/examples/dietmodel.R index 7476d5f..25b7e55 100644 --- a/examples/dietmodel.R +++ b/examples/dietmodel.R @@ -47,7 +47,7 @@ dietmodel <- function(solver=NULL, modelDirectory=NULL) { ampl$setData(df, 2, "") # Solve the model - ampl$solve() + ampl$solve("", "") # Print out the result cat(sprintf("Objective: %f\n", ampl$getObjective("Total_Cost")$value())) diff --git a/examples/efficientfrontier.R b/examples/efficientfrontier.R index 60e0282..722b149 100644 --- a/examples/efficientfrontier.R +++ b/examples/efficientfrontier.R @@ -43,7 +43,7 @@ efficientfrontier <- function(solver=NULL, modelDirectory=NULL) { # Relax the integrality ampl$setOption("relax_integrality", TRUE) # Solve the problem - ampl$solve() + ampl$solve("", "") # Calibrate the efficient frontier range minret <- portfolioReturn$value() values <- averageReturn$getValues() @@ -60,14 +60,14 @@ efficientfrontier <- function(solver=NULL, modelDirectory=NULL) { ampl$eval("let stockopall:={};let stockrun:=stockall;") # Relax integrality ampl$setOption("relax_integrality", TRUE) - ampl$solve() + ampl$solve("", "") cat(sprintf("QP result = %g\n", variance$value())) # Adjust included stocks ampl$eval("let stockrun:={i in stockrun:weights[i]>0};") ampl$eval("let stockopall:={i in stockrun:weights[i]>0.5};") # Set integrality back ampl$setOption("relax_integrality", FALSE) - ampl$solve() + ampl$solve("", "") cat(sprintf("QMIP result = %g\n", variance$value())) # Store data of corrent frontier point returns <- c(returns, maxret - (i - 1) * stepsize) diff --git a/examples/firstexample.R b/examples/firstexample.R index 23e4ac9..b78672f 100644 --- a/examples/firstexample.R +++ b/examples/firstexample.R @@ -19,7 +19,7 @@ firstexample <- function(solver=NULL, modelDirectory=NULL) { ampl$readData(paste(modelDirectory, "/diet/diet.dat", sep="")) # Solve - ampl$solve() + ampl$solve("", "") # Get objective entity by AMPL name totalcost <- ampl$getObjective("Total_Cost") @@ -34,7 +34,7 @@ firstexample <- function(solver=NULL, modelDirectory=NULL) { cat(sprintf("Increased costs of beef and ham.\n")) # Resolve and display objective - ampl$solve() + ampl$solve("", "") cat(sprintf("New objective value: %f\n", totalcost$value())) # Reassign data - all instances @@ -43,7 +43,7 @@ firstexample <- function(solver=NULL, modelDirectory=NULL) { cat(sprintf("Updated all costs.\n")) # Resolve and display objective - ampl$solve() + ampl$solve("", "") cat(sprintf("New objective value: %f\n", totalcost$value())) # Get the values of the variable Buy in a dataframe object diff --git a/examples/trackingmodel.R b/examples/trackingmodel.R index 968d7b1..7543cd7 100644 --- a/examples/trackingmodel.R +++ b/examples/trackingmodel.R @@ -36,7 +36,7 @@ trackingmodel <- function(solver=NULL, modelDirectory=NULL) { # Relax the integrality ampl$setOption("relax_integrality", TRUE) # Solve the problem - ampl$solve() + ampl$solve("", "") cat(sprintf("QP objective value ", ampl$getObjectives()[[1]]$value())) lowcutoff <- 0.04 @@ -62,6 +62,6 @@ trackingmodel <- function(solver=NULL, modelDirectory=NULL) { # Get back to the integer problem ampl$setOption("relax_integrality", FALSE) # Solve the (integer) problem - ampl$solve() + ampl$solve("", "") cat(sprintf("QMIP objective value %g\n", ampl$getObjectives()[[1]]$value())) } diff --git a/src/rampl.cpp b/src/rampl.cpp index c655b9a..178a003 100644 --- a/src/rampl.cpp +++ b/src/rampl.cpp @@ -320,7 +320,7 @@ bool RAMPL::isRunning() const { */ void RAMPL::solve(std::string problem, std::string solver) { _impl.solve(problem, solver); - //return _impl.solve(); // FIXME: does not print to stdout with R IDE on Windows + //return _impl.solve("", ""); // FIXME: does not print to stdout with R IDE on Windows }