I need to optimize a selection of investments that have the highest total impact. The constraints are that the total Investments can be maximum of 8.0 An additional constrain is that each Category can only be assessed twice
The problem I face is that the constraint for max Investment does not work. Also I can not find how to implement the Category constraint. Links to related forms are also welcome.
My code is attached below
Many thanks
--
int NumberofProjects = 12;
range Project = 1..NumberofProjects; // 12 different projects
//Declaration of Parameters
float Impact[Project] = [0.1, 0.03, 0.07, 0.13, 0.01, 0.04, 0.07, 0.08, 0.15, 0.12, 0.02, 0.04]; // Impact to maximize
float Investment[Project] = [2.0, 1.6, 2.5, 12.0, 10.3, 0.6, 1.2, 1.9, 4.0, 5.0, 0.2, 0.5]; // costs --> can be max 8.0
string Category[Project] = [1,1,1,1,1,2,2,2,3,3,3,3]
float Budget = 8.0;
// Declaration of Parameters
//Expression of Decision
dexpr float Reduction = sum(p in Project) Impact[p];
//Objective Function
maximize Reduction;
//Constraints
constraint ctCapResources[Project];
subject to {
forall (p in Project)
ctCapResources[p]: sum(p in Project)
Investment[p] <= Budget;
}