Skip to content

Instantly share code, notes, and snippets.

Created December 10, 2016 21:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
* OPL Model
* Author: BAT4769
* Creation Date: Dec 5, 2016 at 11:14:35 AM
int n=4; // cargos
int m=3; // compartments
int a=2; // aircrafts
range cargos = 1..n;
range comps = 1..m;
range acs = 1..a;
float profit[cargos] = [310,380,350,285];
float weight[cargos] = [19,16,23,13];
float volume[cargos] = [480,650,580,390];
float weight_cap[acs][comps] = [[5,6,8],[10,16,8]];
float volume_cap[acs][comps] = [[6800,8700,5300],[6800,8700,5300]];
// variables
dvar float+ x[acs][cargos][comps];
dvar float+ y[acs];
// objective
dexpr float obj = sum (h in acs, i in cargos, j in comps) profit[i] * x[h][i][j];
maximize obj;
subject to{
forall(i in cargos)
sum(h in acs, j in comps) x[h][i][j] <= weight[i];
forall(h in acs)
forall(j in comps)
sum(i in cargos) x[h][i][j] <= weight_cap[h][j];
forall(j in comps)
sum(i in cargos) x[h][i][j]*volume[i] <= volume_cap[h][j];
forall(j in comps)
sum(i in cargos) x[h][i][j]/weight_cap[h][j] == y[h];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment