Topic
3 replies Latest Post - ‏2013-04-03T08:37:27Z by SystemAdmin
LindaKing
LindaKing
11 Posts
ACCEPTED ANSWER

Pinned topic Scripting runtime error: unknown property 'getValue'

‏2013-04-01T06:12:08Z |
Dear all,
I try to use cplex.getValue to access the value of decision variable after solving the MILP model.
But I get the error: Scripting runtime error: unknown property 'getValue'.
I also use the line: cplex.getObjValue(). There is no error.

Would you please tell me what the reason could be for this problem?
Updated on 2013-04-03T08:37:27Z at 2013-04-03T08:37:27Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    2130 Posts
    ACCEPTED ANSWER

    Re: Scripting runtime error: unknown property 'getValue'

    ‏2013-04-02T07:15:02Z  in response to LindaKing
    Hi,

    let me give you an example:

    dvar float+ Gas[1..1];
    dvar float+ Chloride[1..1];
     
    maximize
      40 * Gas[1] + 50 * Chloride[1];
    subject to {
      
      ctMaxTotal:     
        Gas[1] + Chloride[1] <= 50;
      ctMaxTotal2:    
        3 * Gas[1] + 4 * Chloride[1] <= 180;
      ctMaxChloride:  
        Chloride[1] <= 40;
    }
     
    execute
    {
      writeln(cplex.getObjValue());
      writeln(Gas[1]);
     
    }
    


    To display a value, you only have to use its name such as Gas here.

    regards
    Updated on 2014-03-26T05:49:53Z at 2014-03-26T05:49:53Z by iron-man
    • LindaKing
      LindaKing
      11 Posts
      ACCEPTED ANSWER

      Re: Scripting runtime error: unknown property 'getValue'

      ‏2013-04-03T07:10:33Z  in response to SystemAdmin
      Hi, thank you for your reply.
      Actually, the value of dvar should be passed to a variable and used in next iteration, not just displayed.
      But I found that accessing dvar after solving couldn't be realized by ILOG script. Is it right?
      • SystemAdmin
        SystemAdmin
        2130 Posts
        ACCEPTED ANSWER

        Re: Scripting runtime error: unknown property 'getValue'

        ‏2013-04-03T08:37:27Z  in response to LindaKing
        Hi,

        let me give you an example:

        dvar float+ Gas[1..1];
        dvar float+ Chloride[1..1];
         
        maximize
          40 * Gas[1] + 50 * Chloride[1];
        subject to {
          
          ctMaxTotal:     
            Gas[1] + Chloride[1] <= 50;
          ctMaxTotal2:    
            3 * Gas[1] + 4 * Chloride[1] <= 180;
          ctMaxChloride:  
            Chloride[1] <= 40;
        }
         
        main
        {
          thisOplModel.generate();
          cplex.solve();
          writeln(cplex.getObjValue());
          writeln(thisOplModel.Gas[1]);
                thisOplModel.Gas[1].UB=15;
                cplex.solve();
          writeln(cplex.getObjValue());
          writeln(thisOplModel.Gas[1]);
                
        }
        


        Here you can see that you can after a solve, get a value of a dvar and then say that this dvar should be less than 15 and solve again

        regards
        Updated on 2014-03-26T05:49:44Z at 2014-03-26T05:49:44Z by iron-man