Book Example: prod#
Description: book example autogenerated using prod.mod, prod.dat, and prod.run
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 prod.run
%%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
data;
set P := bands coils;
param: a c u :=
bands 200 25 6000
coils 140 30 4000 ;
param b := 40;
%%ampl_eval
model prod.mod;
data prod.dat;
option solver cbc;
solve;
display X;