Home Help Pricing Contact
Home
Help
Pricing
Contact
Help Resources Getting Started Terminal Commands Running a Solver Working with Spreadsheets Hosting an Optimization Server Project Collections AMPL Book Examples

Help Resources


Getting Started

Terminal Commands

Running a Solver

Working with Spreadsheets

Hosting an Optimization Server

Project Collections

AMPL Book Examples

Getting Started


STEP 1. Click on the New Project button.


STEP 2. Name your project and select the files you want to upload, if any. In this tutorial, we will be using the files from the Steel Production example from the AMPL book. These files can be downloaded from here.


STEP 3. Double click on the files shown on the left to view and edit their content. In our case, we don't want to edit anything, as they are ready for execution.


STEP 4. Everything is ready for execution. Go to the Terminal top menu and select Run.... In this example we are using GLPSOL as the solver, but there are other options. Select the input files and press Run.

STEP 5. All done! See the results of the execution in the terminal on the right.

NEXT STEPS: You can learn about remote solver execution here, and about terminal commands here. Check out the sample projects available in here.

Terminal Commands


Use the terminal to perform a variety of operations: run optimization solvers, query information about the selected Optimization Server, perform administrative tasks over an Optimization Server, etc. The table below shows the different commands available. You can also type help in a terminal to get a similar table. For more detailed information about how to use a command, try entering command --help in the terminal, where 'command' is the name of the command you want to know more about.

Command
Description
Solver Execution Commands
glpsol
Run the GLPSOL solver locally in your browser. Basic usage:
glpsol -m model_file -d data_file
neos
Submit a job to the NEOS server. Basic usage:
neos -m model_file -d data_file -c commands_file
ampl
Run AMPL remotely in the selected LaModAl Optimization Server. Basic usage:
ampl my_file
submit
DEPRECATED. Use glpsol, neos or ampl instead.
Optimization Server Info Commands
show-my-rights
Display your permissions in the selected Optimization Server
show-jobs1
Display list of jobs running at the selected Optimization Server
show-usage1
Display memory and CPU usage at the selected Optimization Server
show-users2
Display list of users allowed at the selected Optimization Server
show-groups2
Display user groups configured at the selected Optimization Server
Optimization Server Admin Commands
add-user2
Add user to an user group at the selected Optimization Server. Basic usage:
add-user username_or_email user_group
remove-user2
Remove user from an user group at the selected Optimization Server. Basic usage:
remove-user username_or_email user_group
kill2
Kill a job running at the selected Optimization Server. Use command show-jobs to get the id of a job. Basic usage:
kill job_id
Other Commands
clear
Clear terminal
help
Display list of available commands
1 Requires monitoring rights in the selected Optimization Server
2 Requires admin rights in the selected Optimization Server

Most commands are for interacting with the currently selected LaModAl Optimization Server. Use the Drop-Down List just above the terminal to select an Optimization Server:


TIP: You don't have to type your long command every time. Use the Repeat Last Command button located just above the terminal. And use the Up and Down arrow keys to navigate through the terminal input history instead of retyping a previously entered command.

Running a Solver


Solve your optimization problems locally (via the glpsol command) or remotely (via the ampl or neos commands). There are important differences between these commands, which are explained below.

1. Run a solver on your browser

Use the glpsol command line to solve your model locally. GLPSOL is a large-scale linear and mixed integer programming solver built on top of the GLPK package. Using the WebAssembly technology, we are able to provide a way for you to run GLPSOL locally, directly from your browser. If you decide to use GLPSOL, keep in mind that:
  • GLPSOL requires the input files to be written in the GNU MathProg language (GMPL), which is a subset of the AMPL language. This means that most AMPL commands will work, but not all.
  • GLPSOL accepts only 2 input files: model and data. You will not be able to have a separate commands file like in the remote solving commands. Instead, put your solve, print and display commands at the end of your model file.
  • GLPSOL will use the CPU and memory from your machine. If your model is too large, we recommend you to use one of the remote execution options.

2. Run a solver on NEOS

Use the neos command line to solve your model on NEOS. NEOS is a free internet-based service for solving numerical optimization problems. Hosted by the Wisconsin Institutes of Discovery at the University of Wisconsin in Madison, the NEOS Server provides access to more than 60 state-of-the-art solvers in more than a dozen optimization categories. If you decide to use NEOS, keep in mind that:
  • NEOS accepts at most 3 files: model, data and commands.
  • NEOS renames your files internally, so if your program tries to read other files with model file_name;, data file_name; or include file_name; it will fail.
  • NEOS does not accept binary files, such as spreadsheets (.xlsx).
  • NEOS requires you to select a solver before-hand, without calling option solver solver_name in the commands file. Use the --solver command line option instead.
  • If you expect your job to take more than 5 minutes to complete, you must use the --priority long command line option. However, long jobs are not streamed, i.e., you will have to wait for the job to finish in order to see its output.
  • Some AMPL commands, such as shell and read <-, are disabled.
  • You can specify an email address to receive the job results when it is done. This is recommended especially if you are running long jobs. Use the --email command line option.

3. Run a solver on a LaModAl Optimization Server

Use the ampl command line to solve your model on a LaModAl Optimization Server. This command will execute the AMPL interpreter on the selected Optimization Server with all the files and options you pass to it. If you decide to use this option, keep in mind that:
  • This feature is not available for users in the free tier.
  • LaModAl does not provide Optimization Servers. To use an Optimization Server you need to either 1) host an optimization server yourself or 2) be allowed to use an Optimization Server hosted by someone else.
  • Files created during execution are not returned to the user, so print your results directly to the terminal.
  • Do not rely on the read <- command to set values for your parameters. During execution the terminal will be locked for input and will only be unlocked once the process is finished.
  • The time used by the process is limited in two ways. First, there is the limit that applies to all users of a particular optimization server due to restrictions of its owner account. Second, there is the limit that applies to a particular group of users due to restrictions set by the owner of the optimization server. Click here to learn more about account limits.
  • The memory used by a process will not exceed the limit set by the owner of the optimization server.

TIP: Use the Command Line Helper to compose a command line through a graphical interface.


TIP: When typing a command in the terminal, use the Up and Down arrow keys to navigate through the terminal input history instead of retyping a previously entered command. And use the Repeat Last Command button located just above the terminal. to re-enter the most recent command.

Working with Spreadsheets


LaModAl offers a limited support for spreadsheets files (.xlsx).
  • Spreadsheet files can be uploaded to a project, but they cannot be edited through LaModAl.
  • Spreadsheet files can be referenced within script files.
  • Spreadsheet files are not supported by GLPSOL nor NEOS, only by LaModAl Optimization Servers.
  • The AMPL folder in the Optimization Server must contain the file amplxl.dll, which can be downloaded from here.
To learn the AMPL syntax for reading data from spreadsheets, take a look at this. The following sample projects show two versions of the same problem, one using spreadsheets and one not. The two main differences are that 1) we use the table command rather than the data command to load the data and 2) we have to add load amplxl.dll; to load the AMPL spreadsheets handler before working with them.
  • Diet model with spreadsheet files (.xlsx)
  • Diet model with data files (.dat)

Hosting an Optimization Server


Important: This feature is in experimental phase. At this phase, we reserve the rights to disable any server at any moment without notice. Use it at your own risk.

PREREQUISITES. Before downloading and installing the LaModAl Optimization Server, you will need:
  • A LaModAl account with optimization server hosting enabled.
  • A Linux 64bit based system. We use Ubuntu 16.04 for testing, which is based on Linux 4.4. Any Linux distribution based on Linux version 4.4 or greater should be fine.
  • Some version of AMPL installed and ready to be used. It will work with either demo, academic or paid version.

STEP 1. Download the LaModAl Optimization Server program by clicking here, or use the command line:
> wget https://beta.lamodal.com/download/opt-server.zip

STEP 2. Extract it wherever you want. Enter the extracted directory and run the opt-server program.
> unzip opt-server.zip
> cd opt-server
> ./opt-server

STEP 3. The first time you run the server you will be asked to give your server a name and to type the full path of the AMPL directory, that is, the directory in which the ampl program is.
1) Give your server a name: My Server
2) Absolute path to the directory containing ampl: /path/to/ampl-directory

STEP 4. After your server connects with our central server, sign-in with your LaModAl account username and password.

STEP 5. At this point your server should be ready to be used by you through the LaModAl web application. You can confirm that by accessing the Opt-Server management page management page and seeing if your server is listed in there.

STEP 6 (Optional). If you are the only user that will be using the optimization server, this step is not needed. In order to allow other users to use your server, you will need to edit the file config.json inside the opt-server directory. First, add a 'user-groups' section with one or more user group inside it. Second, add a 'users' section containing a list of the usernames in each group. For instance, if you want a user group called 'Undergraduates', and you want to limit the memory and time the processes initiated by users in this group can consume, your file would look like this.
{
    "name" : "My Server",
    "remember-me" : true,
    "ampl-directory" : "/path/to/ampl-directory",
    
    "user-groups" : {
        "Undergraduates" : {
            "max-memory" : 20,
            "max-time"   : 60
        }
    },
    
    "users" : {
        "Undergraduates": [
            "JuliaRoberts",
            "brad-pitt",
            "will_smith@uni.edu"
        ]
    }
}
The following table contains the restrictions and permissions that can be set for an user group.
Restriction/Permission
Value
Description
Default
max-memory
number
Maximum memory (in megabytes) used by jobs submited by users in the user group
0 (i.e. unlimited)
max-time
number
Maximum execution time (in minutes) of jobs submited by users in the user group
0 (i.e. unlimited)
max-jobs
number
Maximum number of simultaneous jobs submited by users in the user group
0 (i.e. unlimited)
monitor-rights
true or false
Enable/Disable monitoring commands for users in the user group
false
admin-rights
true or false
Enable/Disable admin commands for users in the user group
false

When a restriction/permission is ommited in the user group definition, the default value is used. If we were to add a 'Teachers' group to the example above, giving every restriction/permission an explicit value, here is how the user-groups section would look like (note that max-jobs = 0 means unlimited):
"user-groups" : {
    "Undergraduates" : {
        "max-memory"     : 20,
        "max-time"       : 60
    },
    
    "Teachers" : {
        "max-memory"     : 8000,
        "max-time"       : 480,
        "max-jobs"       : 0,
        "monitor-rights" : true,
        "admin-rights"   : false
    }
}
Restart the server to apply the changes.

Project Collections


You can group your project into collections to make it easier for you to find them. For instance, if you are a teacher, you may want to group your student's projects by their classes. Follow these steps to create and use project collections:

STEP 1. Select the projects you want to group.


STEP 2. On the top right, click on the button that says Add selected projects to collection. Click on Create New Collection and then give your collection a name.


STEP 3. Alternate between different collections using the In Collection filter.


Add project to collection: To add a new project to an existing collection, you can either 1) use the Add selected projects to collection button 1) put it in the collection you want at the moment of project creation.

Delete collection: To delete a collection, select it using the In Collection filter and then click on the trash can beside its name. This does not delete the projects inside the collection, just the collection per-se.

NOTE: Each user has their own collections. Adding/removing a project to/from a collection does not affect other users whatsoever.

AMPL Book Examples


You can view and run the examples found in the AMPL book. The files contains instructions on how to run the solver.

Example
Book Figure(s)
Basic production model | AMPL | GLPSOL | NEOS
1-2 and 1-3
Steel production model | AMPL | GLPSOL | NEOS
1-4a and 1-4b
Lower bounds on production | AMPL | GLPSOL | NEOS
1-5a and 1-5b
Additional resource constraints | AMPL | GLPSOL | NEOS
1-6a and 1-6b
Diet model | AMPL | GLPSOL | NEOS
2-1 to 2-3
Transportation model | AMPL
3-1a and 3-1b
Multicommodity transportation model | AMPL
4-1 and 4-2
Multiperiod production model | AMPL
4-4 and 4-5
Production-transportation model | AMPL
4-6 and 4-7
Diet model using union | AMPL
5-1 and 5-2
Production model with ordered sets | AMPL
5-3 and 5-4
Transportation model with all pairs | AMPL
6-1
Transportation model with selected pairs | AMPL
6-2a and 6-2b
Multiperiod production with indexed sets | AMPL
6-3 and 6-4
Multicommodity transportation with indexed sets | AMPL
6-5
Parameter sensitivity script | AMPL
13-1
Script for printing a sales table | AMPL
13-2
Script for recording sensitivity | AMPL
13-3
Testing conditions within a loop | AMPL
13-4
Using break and continue in a loop | AMPL
13-5
Sensitivity analysis with infeasibility test | AMPL
14-1
Pattern-based model for the cutting problem | AMPL
14-2 to 14-4
Defining named problems | AMPL
14-6
General transshipment model | AMPL
15-2a and 15-2b
Specialized transshipment model | AMPL
15-3a and 15-3b
Specialized transshipment model v2 | AMPL
15-4a and 15-4b
Maximum traffic flow | AMPL
15-6
Shortest path | AMPL
15-7
General transshipment model with node and arc | AMPL
15-10
Specialized transshipment model with node and arc | AMPL
15-11
Maximum flow model with node and arc | AMPL
15-12
Columnwise scheduling model | AMPL
16-4
Piecewise-linear model with three slopes | AMPL
17-2
Piecewise-linear model with indexed slopes | AMPL
17-3a and 17-3b
Piecewise-linear objective with penalty function | AMPL
17-5a and 17-5b
Nonlinear transportation model | AMPL
18-4 and 18-5
Production cost minimization model | AMPL
19-1 and 19-2
Production equilibrium model | AMPL
19-3
Bounded version of production equilibrium model | AMPL
19-4
Price-dependent demands | AMPL
19-5
Multicommodity model with fixed costs | AMPL
20-1a and 20-1b
Multicommodity model with fixed costs v2 | AMPL
section 20.2
Multicommodity model with further restrictions | AMPL
20-2a and 20-2b
LaModAl Solutions ©