Skip to content

Instantly share code, notes, and snippets.

Created December 5, 2016 10:38
  • 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
range cargos = 1..n;
range comps = 1..m;
float profit[cargos] = [310,380,350,285];
float weight[cargos] = [19,16,23,13];
float volume[cargos] = [480,650,580,390];
float weight_cap[comps] = [10,16,8];
float volume_cap[comps] = [6800,8700,5300];
// variables
dvar float+ x[cargos][comps];
dvar float+ y;
// objective
maximize sum (i in cargos, j in comps) profit[i] * x[i][j];
subject to{
forall(i in cargos)
sum(j in comps) x[i][j] <= weight[i];
forall(j in comps)
sum(i in cargos) x[i][j] <= weight_cap[j];
forall(j in comps)
sum(i in cargos) x[i][j]*volume[i] <= volume_cap[j];
forall(j in comps)
sum(i in cargos) x[i][j]/weight_cap[j] == y;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment