Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Same question,

    Posted 06/18/10 08:49 AM

    Originally posted by: Lamber1


    Dear professors

    I just couldn't understand how Ilog define and use their interfaces. In his manual: the statements is as below:

    "Modeling Variables
    A modeling variable in Concert Technology is represented by an object of type IloNumVar
    or one of its extensions. You can choose from a variety of methods defined in IloModeler
    and IloMPModeler to create one or multiple modeling variable objects. An example of the
    method is:
    
    IloNumVar x = cplex.numVar(lb, ub, IloNumVarType.Float, 
    "xname");
    

    This constructor method allows you to set all the attributes of a variable: its lower and upper
    bounds, its type, and its name. Names are optional in the sense that null strings are
    considered to be valid as well."

    What's the meaning of "type"?

    but in java.lang, an interface, for example: cloneable, need to be implemented
    I just wonder is this interface in ilog is the same as that interface in java API. and an interface can be used by the way as an object of type IloNumVar
    or one of its extensions; what is the meaning of "Type"? Does it mean that we can create an object implements the interface without defining the class that implements the interface first. it seems IloNumVar is used everywhere more like a class instead of an general instance.

    Thank you!

    I know I am low in java, but if I have a confirmation, I would be happy to move forward.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: Same question,

    Posted 06/18/10 08:51 AM

    Originally posted by: Lamber1


    sorry, the last sentence should be more like "an interface"
    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: Same question,

    Posted 06/18/10 11:42 AM

    Originally posted by: SystemAdmin


    > Lamber1 wrote:
    >
    
    IloNumVar x = cplex.numVar(lb, ub, IloNumVarType.Float, 
    "xname");
    

    > This constructor method allows you to set all the attributes of a variable: its lower and upper
    > bounds, its type, and its name. Names are optional in the sense that null strings are
    > considered to be valid as well."
    >
    > What's the meaning of "type"?

    Variables can have type Float (double precision real), Int (integer) or Bool (0-1). IloNumVarType is an enumeration that indicates the type of a variable. Think of it as enumerating a particular interface that the object will implement.
    >
    >
    >
    > but in java.lang, an interface, for example: cloneable, need to be implemented

    It is, but the class (classes?) implementing it are somewhat hidden. (More below.)
    >
    >
    > I just wonder is this interface in ilog is the same as that interface in java API.

    Yes, "interface" here has standard Java meaning.

    > and an interface can be used by the way as an object of type IloNumVar
    > or one of its extensions; what is the meaning of "Type"? Does it mean that we can create an object implements the interface without defining the class that implements the interface first. it seems IloNumVar is used everywhere more like a class instead of an general instance.

    It looks that way, but the appearance is a bit deceptive. Here is my understanding, with the caveat that I could be wrong about it (since I'm not privy to the internal workings of CPLEX). In the C++ API, variables can be freestanding objects that are "owned" by particular environments (which means that multiple models can use the same variables). In the Java API, there are no explicit "environments" (they are created implicitly when you create an instance of IloCplex). As a consequence, variables cannot be freestanding; they have to be "owned" by a specific instance of IloCplex (and cannot be shared across instances). Although I don't recall seeing it stated anywhere, I'm pretty sure that means each variable is a member of the owning IloCplex instance.

    Assuming that much is correct, a variable must be an instance of some subclass derived ultimately from the Java Object class, and that subclass implements one of the three variable type interfaces (IloNumVar, IloIntVar, IloSemiContVar). As it turns out, you never need to use the precise subclass itself, just the relevant interface, so CPLEX does not publish the subclass (which might be a private inner class of IloCplex).

    You are correct that an interface cannot be instantiated. When you create a variable in the Java API, you create an object which is a member of an instance of IloCplex and implements an interface.

    Hope that helps,
    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #DecisionOptimization
    #MathematicalProgramming-General


  • 4.  Re: Same question,

    Posted 06/18/10 02:16 PM

    Originally posted by: Lamber1


    Thank you professor. I guess that is the best tutorial I have. I am happy to move on.

    Thank you very much!
    #DecisionOptimization
    #MathematicalProgramming-General