Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  IloForAllRange vs IloRange

    Posted 02/06/09 08:30 PM

    Originally posted by: SystemAdmin


    [dgravot@noos.fr said:]

    Hello,

    I'm running my OPL model from JAVA and creates new variables [i]after[/i] the model has been generated.

    While accessing named constraints of my OPL model, I get IloConstraintMap object that i'm able to query with related indexed "key" , such as :


    IloForAllRange rangeOneFraction = (IloForAllRange) ctrOneFraction.getSub(tk).get(t);


    Apparently, I'm not able to create an IloColumn on a collection of IloForAllRange objects, which is possible on the IloRange objects.  The only way that seems available is using the setLinearCoeff api :


    IloNumVar FVar = cplex.numVar(0, Double.MAX_VALUE,"FVAR_"+nbColums);
    IloForAllRange rangeOneFraction = (IloForAllRange) ctrOneFraction.getSub(tk).get(t);
    cplex.setLinearCoef(rangeOneFraction, FVar, 1.0 );


    For performance issues, however, I'd like to be able to use IloColumn instead

    Is there a way to achieve that ?

    Thank you
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: IloForAllRange vs IloRange

    Posted 03/03/10 07:03 AM

    Originally posted by: davidoff


    Hi

    Is OPL still unable to fulfill this (through JAVA/C/C# API) ?

    I can see that one can query cplex.getDual on an IloForAllRange, but this is apparently still impossible to create a column with a given coefficient on such constraint, as one would do with an IloRange instead.

    David Gravot
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: IloForAllRange vs IloRange

    Posted 04/18/11 05:31 AM

    Originally posted by: davidoff


    I' m facing the same problem with Cplex Optimization Studio V12.2 : it seems impossible to use the IloColumn API to add new variables on a model generated by opl due to the IloForAllRange type of the constraints.

    Any workaround ?

    Thanks

    David
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: IloForAllRange vs IloRange

    Posted 11/02/11 09:46 AM

    Originally posted by: ubrannlund


    I have a related question: I am using .NET (C#) and have something similar to you.

    INumVar FVar = opl.GetElement("F").AsNumVar();
    IForAllRange rangeOneFraction = (IForAllRange) opl.GetElement("rangeOneFraction").AsConstraint();
    However, I would like to get the coefficient of the variable FVar in constraint rangeOneFraction, i.e. something like:

    double coeff = cplex.getLinearCoef(rangeOneFraction, FVar);

    How do I do that?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: IloForAllRange vs IloRange

    Posted 11/02/11 07:11 PM

    Originally posted by: SystemAdmin


    > INumVar FVar = opl.GetElement("F").AsNumVar();
    > IForAllRange rangeOneFraction = (IForAllRange)
    > opl.GetElement("rangeOneFraction").AsConstraint();
    > However, I would like to get the coefficient of the variable FVar in
    > constraint rangeOneFraction, i.e. something like:
    > double coeff = cplex.getLinearCoef(rangeOneFraction, FVar);

    If rangeOneFraction is just one constraint and not a range of constraints (say in a forall block), then you could use something like the following:

    INumVar FVar = opl.GetElement("F").AsNumVar();
    IRange rangeOneFraction = (IRange)opl.GetElement("rangeOneFraction").AsConstraint();
    ILinearNumExpr expr = (ILinearNumExpr)rangeOneFraction.Expr;
    ILinearNumExprEnumerator exprEnum = expr.GetLinearEnumerator();
    while (exprEnum.MoveNext())
    {
      if (exprEnum.NumVar.Equals((object)FVar))
      {
        double coeff = exprEnum.Value;
        Console.Out.WriteLine("Coefficient of variable " + FVar.Name + " in "+rangeOneFraction+" = " + coeff);
      }
    }
    

    #DecisionOptimization
    #OPLusingCPLEXOptimizer