Skip to content

Commit

Permalink
'portfolio' model: fix time constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
sirfoga committed Oct 18, 2017
1 parent 5cfe2cf commit c971989
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
3 changes: 1 addition & 2 deletions models/portfolio/portfolio.dat
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ param minPublicFunds := 0.4;
param minAForE := 10000;
param maxTime := 5;
param maxRisk := 1.5;
param budget := 100000;
param bigM := 1000000;
param budget := 100000;
18 changes: 7 additions & 11 deletions models/portfolio/portfolio.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ param moodys_rating{FUNDS};
param time{FUNDS};
param profit{FUNDS};
param tax{FUNDS};

param minPublicFunds;
param minAForE;
param maxTime;
param maxRisk;
param budget;
param bigM; # very large constant

var x{FUNDS} >= 0; # how much to invest in each fund
var y{FUNDS} binary; # 1 iff invest in fund
Expand All @@ -25,15 +23,13 @@ maximize total_profit: sum{f in FUNDS} x[f] * profit[f] * (1 - tax[f]);

s.t. available_money: sum{f in FUNDS} x[f] <= budget;
s.t. average_risk: sum{f in FUNDS} x[f] * moodys_rating[f] <= maxRisk * sum{f in FUNDS} x[f];
s.t. average_time: sum{f in FUNDS} x[f] * time[f] <= maxRisk * sum{f in FUNDS} x[f];
s.t. average_time: sum{f in FUNDS} x[f] * time[f] <= maxTime * sum{f in FUNDS} x[f];
s.t. public_investment: sum{f in FUNDS} x[f] * is_state_public[f] >= budget * minPublicFunds;

# activate logic constraint C - D
s.t. logicCD_0: x["C"] <= bigM * y["C"];
s.t. logicCD_1: x["D"] <= bigM * y["D"];
s.t. logicCD_2: y["C"] + y["D"] <= 1;
s.t. logicCD_0: x["C"] <= budget * y["C"]; # logic constraint C - D
s.t. logicCD_1: x["D"] <= budget * y["D"];
s.t. logicCD_2: y["C"] + y["D"] <= 1; # C nand D

# activate logic constraint A - E
s.t. logicAE_0: x["A"] >= minAForE * y["A"];
s.t. logicAE_1: x["E"] <= bigM * y["E"];
s.t. logicAE_2: y["E"] <= y["A"];
s.t. logicAE_0: x["A"] >= minAForE * y["A"]; # logic constraint A - E
s.t. logicAE_1: x["E"] <= budget * y["E"];
s.t. logicAE_2: y["E"] <= y["A"]; # E if A >= 10000
2 changes: 1 addition & 1 deletion models/portfolio/portfolio.run
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ reset; # remove cached vars
model portfolio.mod; # set model and data
data portfolio.dat;

option solver cplex; # select solver
option solver "/home/stefano/bin/amplide.linux64/cplex"; # select solver
solve; # solve

display x, total_profit; # display solution

0 comments on commit c971989

Please sign in to comment.