Skip to content

Instantly share code, notes, and snippets.

@Strernd
Created Dec 5, 2016
Embed
What would you like to do?
/*********************************************
* 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