Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Java API needs setObject()

    Posted 01/03/15 10:05 PM

    Originally posted by: IrvL


    In the C++ API, there is the method IloExtractable::setObject()

    In the Java API, there is no equivalent on IloAddable.  This is needed because it is useful to create a new IloIntVar from cplex.intVar(), and then associate a Java object to that variable, so that when you are looking at the variable, you know the associated object.

    Why is this not implemented?


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Java API needs setObject()

    Posted 01/06/15 06:52 AM

    Irv, I think this warrants an RFE. Can you please file one here?

    Until this gets implemented, I'm afraid you will have to emulate with something like HashMap<IloAddable,Object>.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Java API needs setObject()

    Posted 01/06/15 09:42 AM

    Originally posted by: IrvL


    Daniel:

    I've submitted the RFE.

    Do all Java classes implementing the IloAddable interface have a reasonable implementation of hashCode() so that HashMap<IloAddable,Object> will be efficient? Is equals() also implemented for all of those classes? I couldn't figure that out from the JavaDocs.

        -Irv


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Java API needs setObject()

    Posted 01/09/15 02:52 AM

    I did not check all classes that implement IloAddable but the following is true for IloNumVar:

    1. equals() is not overloaded since there is no need for doing that. Two instances of IloNumVar only refer to the same variable if they refer to the same instance.
    2. hashCode() is not overloaded either since there is not necessarily anything on which a reasonable (and constant) hash code could be build. So you are stuck with System.identityHashCode() but so far I never observed performance problems with that.

    In cases in which I need performance guarantees because map operations are in tight loops I usually assign very short but unique names to the IloAddables and then use a TreeMap<IloAddable, Object> with a comparator that compares the names of the IloAddable keys.


    #CPLEXOptimizers
    #DecisionOptimization