0

I'm actually using IBM ILOG CPLEX to solve some optimization problem, And I had a problem with binary variable I think I'm not using it in the right way.In fact I want to set Here my mod file :

{string} Investments = ...;
float Return[Investments] = ...;
float Covariance[Investments][Investments] = ...;
float Wealth = ...;

/******************************************************************************
 * MODEL DECLARATIONS
 ******************************************************************************/

range float FloatRange = 0.0..Wealth;
dvar int  Binary[Investments] in 0..1;
dvar float  Allocation[Investments] in FloatRange;  // Investment Level


/******************************************************************************
 * MODEL
 ******************************************************************************/

dexpr float Objective =(sum(i,j in Investments) Covariance[i][j]*Allocation[i]*Binary[i]*Allocation[j]);

minimize Objective;

subject to {
    allocate1:   (sum(i in Investments) Return[i]*Allocation[i]*Binary[i])>= 0.02;
  // sum of allocations equals amount to be invested
  allocate2: (sum (i in Investments) (Allocation[i]*Binary[i])) == Wealth;
  //allocate3: (sum (i in Investments) Binary[i]) == 20;


}


float TotalReturn = sum(i in Investments) Return[i]*Allocation[i]*Binary[i];
float TotalVariance = sum(i,j in Investments) Covariance[i][j]*Allocation[i]*Allocation[j]*Binary[i];

0 Answers0