Decision Optimization

Decision Optimization

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

 View Only
  • 1.  getting dual values of constraints

    Posted Sat February 09, 2013 06:35 AM

    Originally posted by: SystemAdmin


    Thanks...
    I have declared a constraint as shown below, how can i get the dual values of it?

    for(int i = 0; i < RCT.CarriorTruck.size(); i++ ){
    IloLinearNumExpr sum3 = RMPcplex.linearNumExpr();
    for(int j =0; j<RRC.Route_Cost.size(); j++)
    {
    if(RCT.Get_Temp_Carrier_Id(i) == RRC.Get_Temp_Carrier_Id(j) &&
    RCT.Get_Temp_Warehouse_Id(i) == RRC.Get_Temp_Warehouse_Id(j) &&
    RCT.Get_Truck_Type(i) == RRC.Get_Truck_Type(j))
    {
    sum3.add((IloLinearNumExpr) route_selected[j]);

    }
    }
    RMPcplex.addLe(sum3, RCT.Get_Maximum_trucks_available(i), "ca_wr_max_truck");
    //sum3.clear();
    }

    Regards
    Arun Lila
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: getting dual values of constraints

    Posted Sat February 09, 2013 08:16 AM

    Originally posted by: SystemAdmin


    Function IloCplex.addLe() returns a reference to the constraint that was added. You can use that reference as argument for function IloCplex.getDual() to get the dual value of the constraint.
    I suggest you take a good look at the reference documentation as well as the Java examples that are shipped with cplex (look at directory cplex/examples/src/java). That will answer most (if not all) the questions you ask here.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: getting dual values of constraints

    Posted Wed February 13, 2013 02:46 AM

    Originally posted by: SystemAdmin


    Thanks for suggestion , I will definitely look into most of the examples.

    Thanks
    Arun Lila
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: getting dual values of constraints

    Posted Wed February 13, 2013 04:59 AM

    Originally posted by: SystemAdmin


    As stated in most of the examples I have defined my constraint in following way
    IloRange [] order_wt;
    for(int i = 0; i < RO11.Order11.size(); i++ )
    {
    IloLinearNumExpr sum1 = RMPcplex.linearNumExpr();

    for(int j =0; j<RRO.Route_Order.size(); j++)
    {
    if(RO11.Get_temp_Customer_Id(i)==RRO.Get_Customer_id(j) && RO11.Get_Order_Type_Id(i)==RRO.Get_Order_Type(j))
    {
    sum1.add((IloLinearNumExpr) RMPcplex.prod(RRO.Get_Weight(j), route_selectedhttp://RRC.Get_Id_By_Value(RRO.Get_Route_Id(j))));
    }
    }
    order_wt[i] = RMPcplex.addGe(sum1,RO11.Get_Weight(i),"order_weight");
    }

    the same constraint i created in opl studio , when i run my problem in java and OPl i get the same objective and variable values ,
    but the dual values of the constraints RMPcplex.getduals{order_wt} are different.

    Can I have reason, or am I modelling in wrong sense.

    Thanks
    Arun Lila
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: getting dual values of constraints

    Posted Wed February 13, 2013 04:59 AM

    Originally posted by: SystemAdmin


    As stated in most of the examples I have defined my constraint in following way
    IloRange [] order_wt;
    for(int i = 0; i < RO11.Order11.size(); i++ )
    {
    IloLinearNumExpr sum1 = RMPcplex.linearNumExpr();

    for(int j =0; j<RRO.Route_Order.size(); j++)
    {
    if(RO11.Get_temp_Customer_Id(i)==RRO.Get_Customer_id(j) && RO11.Get_Order_Type_Id(i)==RRO.Get_Order_Type(j))
    {
    sum1.add((IloLinearNumExpr) RMPcplex.prod(RRO.Get_Weight(j), route_selectedhttp://RRC.Get_Id_By_Value(RRO.Get_Route_Id(j))));
    }
    }
    order_wt[i] = RMPcplex.addGe(sum1,RO11.Get_Weight(i),"order_weight");
    }

    the same constraint i created in opl studio , when i run my problem in java and OPl i get the same objective and variable values ,
    but the dual values of the constraints RMPcplex.getduals{order_wt} are different.

    Can I have reason, or am I modelling in wrong sense.

    Thanks
    Arun Lila
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: getting dual values of constraints

    Posted Thu February 14, 2013 08:12 AM

    Originally posted by: SystemAdmin


    Like primal solution vectors, dual solution vector are not necessarily unique. So in general it is possible that you get different dual solution vectors. Do the vectors look wrong in some way? Or are they just different?
    You could also try to export your model into an LP file from OPL and from Java and check whether the two files are exactly the same. If they are not (for example because the order of constraints differs) then it is even more likely that you get different solution vectors.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: getting dual values of constraints

    Posted Wed March 13, 2013 12:54 PM

    Originally posted by: SystemAdmin


    Thanks , It was very Helpful
    #CPLEXOptimizers
    #DecisionOptimization