Book Example: prod

prod.ipynb Open In Colab Kaggle Gradient Open In SageMaker Studio Lab Hits

Description: book example autogenerated using prod.mod, prod.dat, and

Tags: ampl-only, ampl-book

Notebook author: N/A

Model author: N/A

# Install dependencies
%pip install -q amplpy
# Google Colab & Kaggle integration
from amplpy import AMPL, ampl_notebook

ampl = ampl_notebook(
    modules=["coin"],  # modules to install
    license_uuid="default",  # license to use
)  # instantiate AMPL object and register magics

Example: prod

autogenerated using prod.mod, prod.dat, and

%%writefile prod.mod
set P;

param a {j in P};
param b;
param c {j in P};
param u {j in P};

var X {j in P};

maximize Total_Profit: sum {j in P} c[j] * X[j];

subject to Time: sum {j in P} (1/a[j]) * X[j] <= b;

subject to Limit {j in P}: 0 <= X[j] <= u[j];
%%writefile prod.dat

set P := bands coils;

param:     a     c     u  :=
  bands   200   25   6000
  coils   140   30   4000 ;

param b := 40;
model prod.mod;
data prod.dat;
option solver cbc;
display X;