Decision Optimization

 View Only
  • 1.  Copy 4D dvar into 4D parameter

    Posted Tue March 26, 2024 12:27 PM

    Hello, 

    I need to copy a 4D matrix solution dvar boolean  into a 4D int  in C++, and then solve again.

    I found the getValues functions in IloCplex that might work, but there is no case where both members of the functions are Integer Arrays...

    any suggestions?

    Thank you in advance! :) 

    Sam



    ------------------------------
    Samuele Viaro
    ------------------------------


  • 2.  RE: Copy 4D dvar into 4D parameter

    IBM Champion
    Posted Tue March 26, 2024 02:03 PM

    Loop through the returned array of doubles, rounding each entry and then casting it to int.



    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 3.  RE: Copy 4D dvar into 4D parameter

    Posted Wed March 27, 2024 05:30 AM

    Thank you for the quick response...

    I did think about that...I was hoping there would be a function for Int2Int... ;)



    ------------------------------
    Samuele Viaro
    ------------------------------



  • 4.  RE: Copy 4D dvar into 4D parameter

    IBM Champion
    Posted Wed March 27, 2024 11:17 AM

    There's no conversion function in CPLEX that I'm aware of. When working with binary variables (in the Java API), I usually loop through them with the logic "if x < 0.5 then y = 0 else y = 1" rather than using the rounding function. I haven't checked to see which is faster, since it typically doesn't matter: the time extracting the solution is negligible compared to the time finding the solution.



    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------