data file is

set MINES := NORTH SOUTH EAST WEST ;

param nYears := 5 ;

param: royalties extractLimit oreQuality :=

NORTH 5e6 2.0e6 1.0

SOUTH 4e6 2.5e6 0.7

EAST 4e6 1.3e6 1.5

WEST 5e6 3.0e6 0.5 ;

param blendedQuality :=

1 0.9 2 0.8 3 1.2 4 0.6 5 1.0 ;

param minesLimit := 3 ;

param sellPrice := 10 ;

Model file is

set MINES ordered;

param nYears integer > 0;

set YEARS = 1..nYears;

param royalties {MINES};

param extractLimit {MINES};

param oreQuality {MINES};

param blendedQuality {YEARS};

param discount {y in YEARS} = (1/(1+1/10.0)) ** (y-1);

param minesLimit;

param sellPrice;

var Out {MINES,YEARS} >= 0;

var Quan {YEARS} >= 0;

var Work {MINES,YEARS} binary;

var Open {MINES,YEARS} binary;

maximize Profit:

sum {y in YEARS} sellPrice * discount[y] * Quan[y] –

sum {m in MINES, y in YEARS} royalties[m] * discount[y] * Open[m,y];

subject to AtMost3Mines {y in YEARS}:

sum {m in MINES} Work[m,y] <= minesLimit;

subject to Quality {y in YEARS}:

sum {m in MINES} oreQuality[m] * Out[m,y] = blendedQuality[y] * Quan[y];

subject to OutQty {y in YEARS}:

sum {m in MINES} Out[m,y] = Quan[y];

subject to ExtractLimit {m in MINES, y in YEARS}:

Out[m,y] <= extractLimit[m] * Work[m,y];

subject to WorkingOpen {m in MINES, y in YEARS}:

Work[m,y] <= Open[m,y];

subject to SubsequentOpen {m in MINES, y in 1..nYears-1}:

Open[m,y+1] <= Open[m,y];

I am trying to solve a MIP model (GMPL language), but I want to use the GLPSOL options to limit the search duration (by setting a gap tolerance).

I found this on the GLPK Wiki:

glpsol –cuts –fpump –mipgap 0.001 –model problem.mod –data problem.dat

How can I enter this –mingap functionality in Excel? Since I am here editing the .mod file I believe?

Thanks,

Alex

when I try to output a 1-dimensional parameter to my excel file, I keep getting errors. The syntax (from example file) works for a 2-dimensional array! Do you have an idea what is wrong with my syntax?

printf “” > “Sheet”; # Open output file

printf “Sourcing :=\n” >> “Sheet”;

printf {i in DistributionCenters, j in Customers}: “‘%s’ ‘%s’ ‘%s’\n”, i, j, Sourcing[i,j] >> “Sheet”;

printf “;\n” >> “Sheet”;

printf “DCCheckBinary :=\n” >> “Sheet”;

printf {i in DistributionCenters}: “‘%s’ ‘%s’ ‘%s’\n”, i, DCCheckBinary[i] >> “Sheet”;

printf “;\n” >> “Sheet”;

Here it works to output the Sourcing array (2-dim), but the DCCheckBinary array (1-dim) does not work.

Any help is welcome,

Thanks

Agnew

http://www.gurobi.com/resources/examples/mining

i am trying to replicate this example in solver studio but it doesn’t work. its meant to be python.

]]>