Skip to content

Instantly share code, notes, and snippets.

@Strernd
Created December 5, 2016 10:38
Show Gist options
  • Save Strernd/66387d8cd7d4a937c893b15b1692e0b9 to your computer and use it in GitHub Desktop.
Save Strernd/66387d8cd7d4a937c893b15b1692e0b9 to your computer and use it in GitHub Desktop.
/*********************************************
* OPL 12.5.1.0 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];
//consraints
subject to{
forall(i in cargos)
available_weight:
sum(j in comps) x[i][j] <= weight[i];
forall(j in comps)
weight_capacity:
sum(i in cargos) x[i][j] <= weight_cap[j];
forall(j in comps)
volume_capacity:
sum(i in cargos) x[i][j]*volume[i] <= volume_cap[j];
forall(j in comps)
balancing_constraint:
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