Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
3 replies Latest Post - ‏2013-02-21T14:42:06Z by SystemAdmin
SystemAdmin
SystemAdmin
7929 Posts
ACCEPTED ANSWER

Pinned topic sutracting number from IloNumExpr java cplex

‏2013-02-21T14:01:32Z |
Hello! What I want to do is to subtract an IloNumExpr from a number. I want to put to an expression the following thing:
\{
for i
for j
for k
n-(n-k-1)*y[i][j]
\}
n is an integer and y is a decision variable

Cplex does not let me subtract a number in the addTerm method of the expression.
Updated on 2013-02-21T14:42:06Z at 2013-02-21T14:42:06Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    7929 Posts
    ACCEPTED ANSWER

    Re: sutracting number from IloNumExpr java cplex

    ‏2013-02-21T14:16:45Z  in response to SystemAdmin
    You need to use the setConstant() member function to change the constant part of an expression.
    • SystemAdmin
      SystemAdmin
      7929 Posts
      ACCEPTED ANSWER

      Re: sutracting number from IloNumExpr java cplex

      ‏2013-02-21T14:28:51Z  in response to SystemAdmin
      Thanks, Daniel. But then how will I subtract the expression from this constant part. I will say \{setConstant(n) \} and how will I say the \{ -(n-k+1)y[i][j] \}?
      • SystemAdmin
        SystemAdmin
        7929 Posts
        ACCEPTED ANSWER

        Re: sutracting number from IloNumExpr java cplex

        ‏2013-02-21T14:42:06Z  in response to SystemAdmin
        I suggest you take a good look at the IloCplexModeler class reference documentation. That is the superclass of IloCplex that provides the modeling API.
        There you can find for example member function
        IloNumExpr sum(double v, IloNumExpr e1);
        

        that produces the sum of a constant and an expression.
        Updated on 2014-03-24T22:39:33Z at 2014-03-24T22:39:33Z by iron-man