A Mathematical Programming Language, aka A Mathematical Programming Language, is an actively used programming language created in 1985.

 34Years Old 2,660Users 0Jobs

### Example code from the web:

```set PROD;  # products

param rate {PROD} > 0;     # tons produced per hour
param avail >= 0;          # hours available in week

param profit {PROD};       # profit per ton
param market {PROD} >= 0;  # limit on tons sold in week

var Make {p in PROD} >= 0, <= market[p]; # tons produced

maximize Total_Profit: sum {p in PROD} profit[p] * Make[p];

subject to Time: sum {p in PROD} (1/rate[p]) * Make[p] <= avail;

# Constraint: total of hours used by all
# products may not exceed hours available```

### Example code from Linguist:

```# A toy knapsack problem from the LocalSolver docs written in AMPL.

set I;
param Value{I};
param Weight{I};
param KnapsackBound;
var Take{I} binary;

maximize TotalValue: sum{i in I} Take[i] * Value[i];
s.t. WeightLimit: sum{i in I} Take[i] * Weight[i] <= KnapsackBound;

data;

param:
I: Weight Value :=
0    10     1
1    60    10
2    30    15
3    40    40
4    30    60
5    20    90
6    20   100
7     2    15;

param KnapsackBound := 102;
```

### Example code from Wikipedia:

```set Plants;
set Markets;

# Capacity of plant p in cases
param Capacity{p in Plants};

# Demand at market m in cases
param Demand{m in Markets};

# Distance in thousands of miles
param Distance{Plants, Markets};

# Freight in dollars per case per thousand miles
param Freight;

# Transport cost in thousands of dollars per case
param TransportCost{p in Plants, m in Markets} :=
Freight * Distance[p, m] / 1000;

# Shipment quantities in cases
var shipment{Plants, Markets} >= 0;

# Total transportation costs in thousands of dollars
minimize cost:
sum{p in Plants, m in Markets} TransportCost[p, m] * shipment[p, m];

# Observe supply limit at plant p
s.t. supply{p in Plants}: sum{m in Markets} shipment[p, m] <= Capacity[p];

# Satisfy demand at market m
s.t. demand{m in Markets}: sum{p in Plants} shipment[p, m] >= Demand[m];

data;

set Plants := seattle san-diego;
set Markets := new-york chicago topeka;

param Capacity :=
seattle   350
san-diego 600;

param Demand :=
new-york 325
chicago  300
topeka   275;

param Distance : new-york chicago topeka :=
seattle        2.5      1.7     1.8
san-diego      2.5      1.8     1.4;

param Freight := 90;```
Edit

Last updated February 11th, 2019