ampl.run.neos: Solves an AMPL model remotely using the NEOS Server

Description Usage Arguments Examples

View source: R/rampl.r

Description

Solves an AMPL model remotely using the NEOS Server

Usage

1
2
3
4
5
ampl.run.neos(name = "", category = "cp", solver = "PATH",
  path = getwd(), wait = TRUE, mod.file = paste(path, "/", name, ".mod",
  sep = ""), dat.file = paste(path, "/", name, ".dat", sep = ""),
  run.file = paste(path, "/", name, ".run", sep = ""),
  log.file = paste(path, "/log_", name, "_", solver, ".txt", sep = ""))

Arguments

name

the model name

category

category of the optimization problem, call neos.ampl.solvers() for an overview

solver

desired solver, call neos.ampl.solvers() for a list

path

path in which mod.file, dat.file and run.file can be found

wait

default=TRUE shall R wait until NEOS returns the solution (may take some time)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 
  # Model of power plant investments and dispatch included in package
  mod.file = paste(.path.package(package = "rampl"),"/data/cournot.mod",sep="")
  dat.file = paste(.path.package(package = "rampl"),"/data/cournot.dat",sep="")
  run.file = paste(getwd(),"/cournot.run",sep="")
  ampl.make.run.file(name="cournot", neos=TRUE, mod.file=mod.file,dat.file=dat.file,run.file=run.file, options=c(""))
  ret = ampl.run.neos(name="cournot", category="nco", solver="MINOS", mod.file=mod.file, dat.file=dat.file, run.file=run.file)
  ret
  
  # Solve for different parameter values
  n = 2
  sets = list(N=1:n)
  param = list(a=1,b=1,c=c(0.1,0.1))
  
  dat.file = paste(getwd(),"/cournot.dat",sep="")
  run.file = paste(getwd(),"/cournot.run",sep="")
   
  solve.cournot = function(c1=0,c2=0, neos=FALSE) {
    param$c = c(c1,c2)
    ampl.make.dat.file(mod.file=mod.file,dat.file=dat.file,sets = sets, param=param)

    if (!neos) {
      
       ampl.make.run.file(name="cournot", options=c("option solver minos;"), mod.file=mod.file,dat.file=dat.file,run.file=run.file)
      ret = ampl.run.local(name="cournot", display=FALSE, run.file=run.file)
    
    } else {
      ampl.make.run.file(name="cournot", neos=TRUE, mod.file=mod.file,dat.file=dat.file,run.file=run.file, options=c(""))
      ret = ampl.run.neos(name="cournot", category="nco", solver="MINOS", mod.file=mod.file, dat.file=dat.file, run.file=run.file)
    }
    t(ret$q)
  }
  solve.cournot(c1=0.1,c2=0, neos=TRUE)
  

## End(Not run)

skranz/rampl documentation built on April 12, 2021, 11:43 a.m.