Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Getting Double values of BoolVarArray

    Posted 03/10/16 03:15 PM

    Originally posted by: peeyushBHU


    Hi i have defined an array of bool variable in my optimization model as shown in the following code. The model consists an objective function and some constraints. When i solve the model it gives the value of Boolean variable (Emp[i].S[d][a] ) in double format (For Example:- 4.44089209850063E-16). I want it in the form of zero (0) or one (1) only for the further calculation in the model. Please suggest how do i solve this problem. I dont want floating point numbers, i only want values in 0 or 1 format that tha variable is defined for.

     

     internal class EmployeeInfo
        {
            internal INumVar[][] S;

        }

     public static void Main(string[] args)
        {

            Cplex cplex = new Cplex();

            EmployeeInfo[] Emp = new EmployeeInfo[50];

              for (int i = 0; i < Emp.Length; i++)

                    {
                        Emp[i] = new EmployeeInfo();
                        Emp[i].S = new INumVar[Days][];
                        for (int d = 0; d < Days; d++)
                        {
                            Emp[i].S[d] = cplex.BoolVarArray(45);
                        }

                    }

    }

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Getting Double values of BoolVarArray

    Posted 03/10/16 03:50 PM

    You could use Math.Round(), Convert.ToInt32(), or "cast" to boolean via (value > 0.5).


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Getting Double values of BoolVarArray

    Posted 03/10/16 04:48 PM

    Originally posted by: peeyushBHU


    Thank you very much Daniel, My problem is solved by using Convert.ToInt32()

     

     


    #CPLEXOptimizers
    #DecisionOptimization