### GitHub Actions CI/CD Setup Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/cicd.md Example GitHub Actions workflow to set up Python, install dependencies including amplpy and solvers, install the project package, and run tests. ```yaml name: Test run-name: ${{ github.actor }} is building "${{ github.ref_name }}" on: [push] jobs: Test: runs-on: ubuntu-latest strategy: matrix: python-version: ["3.10"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | set -ex python -m pip install -r requirements.txt python -m pip install amplpy python -m amplpy.modules install python -m amplpy.activate - name: Install package run: | python -m pip install . - name: Test package run: | python -m .tests ``` -------------------------------- ### Azure Pipelines CI/CD Setup Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/cicd.md Example Azure Pipelines configuration to set up Python, install dependencies including amplpy and solvers, install the project package, and run tests. ```yaml jobs: - job: Test pool: {vmImage: 'ubuntu-latest'} strategy: matrix: Python 3.10: PYTHON_VERSION: 3.10 steps: - task: UsePythonVersion@0 inputs: versionSpec: $(PYTHON_VERSION) - bash: python --version displayName: Check python version - bash: | set -ex python -m pip install -r requirements.txt python -m pip install amplpy python -m amplpy.modules install python -m amplpy.activate displayName: Install dependencies - bash: | python -m pip install . displayName: Install package - bash: | python -m .tests displayName: Test package ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/pyinstaller.md Install all necessary project dependencies listed in requirements.txt within the activated virtual environment. ```bash python -m pip install -r requirements.txt ``` -------------------------------- ### Install and Activate LOQO with amplpy Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/loqo/index.md Installs the amplpy Python API, the LOQO solver module, and activates a license. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install loqo # install LOQO # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Trivial Example with Presolve Disabled Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/minos/changes.md This example demonstrates a fault that occurs with a trivial problem when the presolve option is disabled. ```none var x; minimize o: x; s.t. c: x >= 42; ``` -------------------------------- ### Install AMPL and Modules in Non-Root Python Docker Image Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/docker.md This Dockerfile example demonstrates setting up a Python Docker image for AMPL with a non-root user. It includes steps for creating a user and switching to their privileges. ```Dockerfile FROM python:3.9-slim-bullseye # Install amplpy and all necessary amplpy.modules: RUN python -m pip install amplpy --no-cache-dir # Install amplpy RUN python -m amplpy.modules install highs gurobi --no-cache-dir # Install modules # Add non-root user (optional) ARG USERNAME=guest ARG USER_UID=1000 ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME # Change to non-root privilege USER ${USERNAME} ``` -------------------------------- ### Install MINOS with amplpy Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/minos/index.md Install the Python API for AMPL and the MINOS solver module. Activate your license using your UUID. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install minos # install MINOS # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Install amplpy and Kestrel module Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/kestrel/index.md Install the Python API for AMPL and the Kestrel solver module. Ensure to activate your license afterward. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install gokestrel # install Kestrel # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Example of Setting a Specific XPRESS Option Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/xpress/options.md Shows a concrete example of setting the 'mipgap' option for the XPRESS solver in AMPL. ```ampl ampl: option xpress_options 'mipgap=1e-6'; ``` -------------------------------- ### Install LGO Solver with amplpy Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/lgo/index.md Installs the Python API for AMPL, the LGO solver module, and activates a license. Ensure you have Python installed and replace '' with your actual license identifier. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install lgo # install LGO # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Install IPOPT with amplpy Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/ipopt/index.md Install the Python API for AMPL and the IPOPT solver module. Activate your license using its UUID. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install coin # install IPOPT # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Install COUENNE with amplpy Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/couenne/index.md Installs the Python API for AMPL and the COUENNE solver module. Ensure you activate your license afterward. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install coin # install COUENNE # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Dockerfile for AMPL Installation Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/docker.md This Dockerfile demonstrates a multi-stage build to create a smaller image containing AMPL. It installs necessary modules and copies the AMPL installation directory from a previous stage. ```docker # Use any image as base image FROM debian:stable-slim # Install curl in order to download the modules necessary RUN apt-get update && apt-get install -y curl # Install individual modules (alternative to installing the full bundle) ARG MODULES_URL=https://ampl.com/dl/modules # Download ampl-module.linux64.tgz RUN cd /opt/ && curl -OL ${MODULES_URL}/ampl-module.linux64.tgz && \ tar oxzvf ampl-module.linux64.tgz && rm ampl-module.linux64.tgz # Download gurobi-module.linux64.tgz RUN cd /opt/ && curl -OL ${MODULES_URL}/gurobi-module.linux64.tgz && \ tar oxzvf gurobi-module.linux64.tgz && rm gurobi-module.linux64.tgz # Download copt-module.linux64.tgz RUN cd /opt/ && curl -OL ${MODULES_URL}/copt-module.linux64.tgz && \ tar oxzvf copt-module.linux64.tgz && rm copt-module.linux64.tgz # Download coin-module.linux64.tgz RUN cd /opt/ && curl -OL ${MODULES_URL}/coin-module.linux64.tgz && \ tar oxzvf coin-module.linux64.tgz && rm coin-module.linux64.tgz # Download highs-module.linux64.tgz RUN cd /opt/ && curl -OL ${MODULES_URL}/highs-module.linux64.tgz && \ tar oxzvf highs-module.linux64.tgz && rm highs-module.linux64.tgz # Start a second stage copying just ampl.linux-intel64 FROM debian:stable-slim COPY --from=0 /opt/ampl.linux-intel64 /opt/ampl.linux-intel64 # Add installation directory to the environment variable PATH ENV PATH="/opt/ampl.linux-intel64/:${PATH}" ``` -------------------------------- ### Install and Activate amplpy with CBC Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/cbc/index.md Commands to install the amplpy Python package and the CBC solver module. Ensure to activate your license. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install cbc # install CBC # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Install amplpy and Gurobi Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/gurobi/index.md Install the Python API for AMPL and the Gurobi solver module. Activate your license using the provided UUID. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install gurobi # install Gurobi # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Running AMPL Container and Activating License Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/docker.md This example shows how to build the Docker image and run a container, including activating the AMPL license using `amplkey activate` and then launching an AMPL session. ```bash docker build . --tag ampl-container ``` ```bash $ docker run --rm -it -e AMPLKEY_UUID=xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx ampl-container bash guest@2b5e38badc9f:/$ amplkey activate 2022/05/12 14:42:08 Wrote 958 bytes to /tmp/ampl/ampl.lic guest@2b5e38badc9f:/$ ampl ampl: option version; option version 'AMPL Version 20220505 (Linux-5.4.0-1077-azure, 64-bit) Licensed to AMPL Community Edition License. Temporary license expires 20220531. Using license file "/tmp/ampl/ampl.lic". '; ampl: quit; ``` -------------------------------- ### Get AMPL Module Path Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/modules.md Retrieve the path that needs to be appended to the environment variable PATH to access installed modules. ```bash $ python -m amplpy.modules path ``` ```bash export PATH=$PATH:`python -m amplpy.modules path` ``` -------------------------------- ### Fix Complementarity Constraint Bug in AMPL Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/releases/ampl.md Addresses an issue where fixing variables involved in complementarity constraints could lead to their incorrect removal by presolve. This example demonstrates the data and constraint setup that triggered the bug. ```ampl data; var x{1..7}; data;s.t. c{i in 1..6}: x[i] >= 0 complements x[i+1] >= 0; data;fix{i in 1..3} x[i]; data;solve; # gave error message “presolve has k = 6, P.nfc = 7” ``` -------------------------------- ### Decoded AMPL Fingerprint Content Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/help/get-fingerprint.md This is the content of the example AMPL fingerprint after being decoded from base64. It shows the computer name, Ethernet addresses, and C: drive label (for Windows). Lines starting with '#' are comments and ignored for trial licenses. ```default # user "Robert" Fingerprint(20140523) = 1-2-1-613fa1e 4erYoga13 00-50-B6-0D-A0-91 20-16-D8-A6-BF-3B 348A-EB35 # 2 sockets. ``` -------------------------------- ### Invoking Kestrel with LOQO Solver Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/kestrel/index.md Example of how to set up and run the Kestrel client to use the LOQO solver remotely via the NEOS Server. This includes setting the solver, Kestrel options, LOQO-specific options, and an email address. ```ampl ampl: model steelT.mod; ampl: data steelT.dat; ampl: option solver kestrel; ampl: option kestrel_options 'solver=loqo'; ampl: option loqo_options 'minlocfil sigfig=8 outlev=2'; ampl: option email "neos@ampl.com"; ampl: solve; ``` -------------------------------- ### Install AMPL Modules Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/modules.md Install specified AMPL solver modules. You can install multiple modules at once. ```bash $ python -m amplpy.modules install ... ``` ```bash $ python -m amplpy.modules install highs gurobi ``` -------------------------------- ### Install R AMPL API Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/reference/apis.md Install the R AMPL API by first installing Rcpp from source, then installing the R package from a local tarball. Ensure R and Rcpp are set up correctly. ```r install.packages("Rcpp", type="source") install.packages("https://ampl.com/dl/API/rAMPL.tar.gz", repos=NULL) ``` -------------------------------- ### Example of Setting CBC Options Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/cbc/options.md Illustrates how to set a specific CBC solver option, 'presolve', to 'more' using the `cbc_options` parameter in AMPL. ```ampl ampl: option cbc_options 'presolve=more'; ``` -------------------------------- ### New keywords for ramp-up and configuration Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/cplex/changesasl.md Keywords rampup_duration, rampup_timelim, rampup_walltimelim, and vmconf are now available. Check the 'cplex -=' output for more information. ```none See the output of “cplex -=” for details. ``` -------------------------------- ### Install amplpy Package Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/best-practices/amplpy-best-practices.md Installs or upgrades the amplpy package to the latest version. Ensure you have the latest version of pip installed. ```python python -m pip install amplpy --upgrade ``` ```python python -m pip install --upgrade pip ``` -------------------------------- ### List AMPL Module Usage Instructions Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/modules.md Display usage instructions for the `amplpy.modules` command. ```bash $ python -m amplpy.modules usage ``` -------------------------------- ### Install amplpy and MOSEK solver Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/mosek/index.md Installs the Python API for AMPL, the MOSEK solver module, and activates a license. Ensure you have Python installed. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install mosek # install MOSEK # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Install Python AMPL API Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/reference/apis.md Use this command to install the AMPL Python API using pip. Ensure you have Python and pip installed. ```bash python -m pip install amplpy ``` -------------------------------- ### CPLEXASL Option: baralg Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/cplex/cplexasl.md Specifies how the barrier algorithm is initiated. Options include automatic choice (default), infeasibility-estimate start, infeasibility-constant start, and standard start. ```default baralg How to start the barrier algorithm: 0 (default) = 1 for MIP subproblems, else 3 1 = infeasibility-estimate start 2 = infeasibility-constant start 3 = standard start. ``` -------------------------------- ### Install XPRESS Solver using amplpy Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/xpress/index.md Installs the XPRESS solver module for AMPL using the Python API. Ensure you have amplpy installed and activate your license afterward. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install xpress # install XPRESS # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### List All Xpress Solver Options Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/xpress/index.md Execute this command to display a full list of all supported Xpress solver options and their aliases. This is useful for understanding the available configurations. ```default xpress -= ``` -------------------------------- ### Install AMPL Python API Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/install.md Installs the AMPL Python API and specified solver modules. This command-line installation is for general Python environments on Windows, Linux, and macOS. ```bash # Install Python API for AMPL $ python -m pip install amplpy --upgrade ``` -------------------------------- ### Solve MINLP Problem with BONMIN in Python Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/bonmin/index.md Demonstrates how to initialize the AMPL object and solve a problem using the BONMIN solver with custom options. ```python from amplpy import AMPL ampl = AMPL() ... ampl.solve(solver="bonmin", bonmin_options="option1=value1 option2=value2") ``` -------------------------------- ### Install ILOG CP Solver Module Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/ilogcp/index.md Installs the ILOG CP solver module for AMPL using the amplpy Python package. Ensure AMPL and the solver are installed before activating your license. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install ilogcp # install ILOG CP # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Install BONMIN Solver with Amplpy Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/bonmin/index.md Installs the Python API for AMPL and the BONMIN solver module. Ensure to activate your license afterward. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install coin # install BONMIN # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### AMPL Conditional Model Command Example Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/releases/ampl.md Shows examples of the 'model' command using conditional logic to select model files. These examples highlight a bug fix related to the evaluation of such conditional commands. ```ampl model (if t == 1 then ‘a.mod’ else ‘b.mod’) ``` ```ampl model (if t == 1 then ‘a.mod’ else if t == 2 then ‘b.mod’) ``` -------------------------------- ### Install and Activate CONOPT with amplpy Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/solvers/conopt/index.md Install the amplpy Python package and the CONOPT solver module. Activate your license using a provided UUID. ```bash # Install Python API for AMPL: $ python -m pip install amplpy --upgrade # Install AMPL & solver modules: $ python -m amplpy.modules install conopt # install CONOPT # Activate your license (e.g., free ampl.com/ce or ampl.com/courses licenses): $ python -m amplpy.modules activate ``` -------------------------------- ### Install AMPL and Modules in Python Docker Image Source: https://github.com/ampl/ampl.github.io/blob/master/docs/source/ampl/python/docker.md Use this Dockerfile snippet to install amplpy and specific solver modules (e.g., highs, gurobi) within a Python-based Docker image. It utilizes pip for installation. ```Dockerfile FROM python:3.9-slim-bullseye # Install amplpy and all necessary amplpy.modules: RUN python -m pip install amplpy --no-cache-dir # Install amplpy RUN python -m amplpy.modules install highs gurobi --no-cache-dir # Install modules ```