Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  python accessing sparsepair items and printing them

    Posted 12/19/14 02:28 AM

    Originally posted by: prashanw


    In the python API, Can I access sparsepair items and print them? ...Apparantly I am not able to use __getattribute__ for sparsepair.(http://www-01.ibm.com/support/knowledgecenter/SSSA5P_12.2.0/ilog.odms.cplex.help/html/refpythoncplex/html/cplex._internal._matrices.SparsePair-class.html?lang=en)  

    I have seen examples of items added but not accessed/indexed.

    I would appreciate any help!

    I wou

    I hav


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: python accessing sparsepair items and printing them

    Posted 12/23/14 11:34 AM

    Hi,

    one your CPLEX matrix is built you may use

    c.linear_constraints.set_linear_components("c1", [["assign_1_1"], [1.0]]);

    in order to edit an item

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: python accessing sparsepair items and printing them

    Posted 12/24/14 11:05 AM

    Originally posted by: prashanw


    Thanks for your reply but what I want is to access an item and print it. for example access the 3rd (ind, val) tuple and print it,


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: python accessing sparsepair items and printing them

    Posted 12/24/14 12:44 PM

    Hi

    Have you tried

    print(c.linear_constraints.get_rows(2));

    ?

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: python accessing sparsepair items and printing them

    Posted 12/31/14 11:16 AM

    Originally posted by: prashanw


    Hi  Alex,

     

    Thanks for your help. So the .__getattribute__('ind'), .__getattribute__('val'), .__getattribute__('names') seems to work for SparsePair so I am actually able to access and based on the sparse pair indexing.

    Thanks for your help!


    #CPLEXOptimizers
    #DecisionOptimization