Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Formulating an MIP using CPLEX in Java

    Posted 01/09/10 05:54 AM

    Originally posted by: StephanR


    Hello all,

    I just started using CPLEX 11 on Java with Eclipse. I have defined my deterministic model but I don't know how to ensure that an IloNumVar has a specific Type, ie how to make sure it returns an integer rather a double.

    IloNumVar][[] Build = new IloNumVarnNodesnFactories[1];// Only at time = 0
    for (int i = 0; i < nNodes; i++) {
    for (int j = 0; j < nFactories; j++) {
    Build[i][j][0] = cplex.numVar(0, 1);
    }
    }

    That's how I define my variable Build, but at the moment I'm building .75 of a factory. In CPLEX you use "generals" if I'm not mistaken but I can't seem to figure out how it works in Java. So I was wondering how to enforce that it has to return an integer.

    Thank you very much
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Formulating an MIP using CPLEX in Java

    Posted 01/09/10 11:04 AM

    Originally posted by: SystemAdmin


    > StephanR wrote:
    > Hello all,
    >
    > I just started using CPLEX 11 on Java with Eclipse. I have defined my deterministic model but I don't know how to ensure that an IloNumVar has a specific Type, ie how to make sure it returns an integer rather a double.
    >
    > IloNumVar][[] Build = new IloNumVarnNodesnFactories[1];// Only at time = 0
    > for (int i = 0; i < nNodes; i++) {
    > for (int j = 0; j < nFactories; j++) {
    > Build[i][j][0] = cplex.numVar(0, 1);
    > }
    > }
    >
    > That's how I define my variable Build, but at the moment I'm building .75 of a factory. In CPLEX you use "generals" if I'm not mistaken but I can't seem to figure out how it works in Java. So I was wondering how to enforce that it has to return an integer.
    >

    You can add a third argument to numVar() specifying the type (IloNumVarType.Int for general integer, IloNumVarType.Bool for 0/1; the default is IloNumVarType.Float).

    /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)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Formulating an MIP using CPLEX in Java

    Posted 01/09/10 02:38 PM

    Originally posted by: StephanR


    Thanks! I knew that NumVar() had different types but I didn't notice the additional arguments you could specify.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Formulating an MIP using CPLEX in Java

    Posted 05/13/10 06:37 AM

    Originally posted by: IHK


    Hello,

    please can you tell me how to install the cplex library (cplex.jar) in eclipse. Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Formulating an MIP using CPLEX in Java

    Posted 05/13/10 08:24 AM

    Originally posted by: SystemAdmin


    Select Project -> Properties -> Java Build Path, then click "Add External JAR" and select the cplex.jar.
    If you also want to run from eclipse make sure that the java.library.path contains the path to the cplex.dll.
    To set this property open the "Run configurations" dialog (Run -> Run Configurations) and select the run configuration for your project. Go to the "Arguments" tab and add something like this to the VM arguments line
    -Djava.library.path=/path/to/dll
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Formulating an MIP using CPLEX in Java

    Posted 05/13/10 09:11 AM

    Originally posted by: IHK


    Thank you for your help but I have not find a link in the web to download the cplex.jar. Please have you the link to do that. Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Formulating an MIP using CPLEX in Java

    Posted 05/13/10 11:27 AM

    Originally posted by: SystemAdmin


    > IHK wrote:
    > Thank you for your help but I have not find a link in the web to download the cplex.jar. Please have you the link to do that. Thanks

    Your CPLEX installation should already contain cplex.jar. Look in the lib/ folder under the CPLEX installation directory.

    /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)
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Formulating an MIP using CPLEX in Java

    Posted 05/13/10 11:37 AM

    Originally posted by: IHK


    I used AMPL cplex because I haven't find Ilog Cplex and there isn't the library folder.
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Formulating an MIP using CPLEX in Java

    Posted 05/13/10 11:58 AM

    Originally posted by: SystemAdmin


    If you are an academic (faculty), you can obtain a full version of CPLEX (including the JAR file) free; see the thread at http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14437157&tstart=0#14437157. If you are a student, you would need a professor to register and obtain the software; he or she could then provide you access to it.

    The version of CPLEX that normally ships with AMPL not only does not contain cplex.jar, it also has an executable that has been customized to work with AMPL. Even if you had access to cplex.jar, I don't think you would be able to link your Java code to the executable to run the program.

    /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)
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Formulating an MIP using CPLEX in Java

    Posted 05/13/10 02:15 PM

    Originally posted by: IHK


    Thank you for your help.
    #CPLEXOptimizers
    #DecisionOptimization