Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  lp feasibility test

    Posted 11/29/11 03:48 AM

    Originally posted by: JFYY_yaohua_tang


    hello, everyone.

    I have a two lp model A and B, model A is a subproblem of model B, which means A have a subset of B's constraint list, but they have the same variable list. Now I have solved model A by CPLEX(C++) and want to test the solution's feasibility to model B, is there any hint?

    thankyou.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: lp feasibility test

    Posted 11/29/11 07:04 AM

    Originally posted by: SystemAdmin


    If you have the extra constraints of model B stored in some array, then you can use
    IloNum IloCplex::getValue(const IloExprArg expr) const;
    

    on model A to evaluate the constraints for the optimal solution of model A.

    Tobias
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: lp feasibility test

    Posted 11/29/11 07:11 AM

    Originally posted by: SystemAdmin


    And if you do not have the constraint stored in an array then use IloModel::Iterator:
    bool feasible = true;
    for (IloModel::Iterator it(B); it.ok(); ++it) {
      IloExtractable e = *it;
      if (e.isConstraint() && A.getValue(e.asConstraint()) < 0.5) {
        feasible = false;
        break;
      }
    }
    if (feasible)
      std::cout << "Solution satisfies all constraints in B" << std::endl;
    else
      std::cout << "Solution is not feasible for B" << std::endl;
    

    The code-snippet above exploits the fact that you can give an arbitrary constraint as argument to IloCplex::getValue(). The function will return 1 if the current solution satisfies the constraint and 0 otherwise.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: lp feasibility test

    Posted 11/29/11 11:43 AM

    Originally posted by: JFYY_yaohua_tang


    I have a ilorangearray for the constraints, but you still teach me something new, thanks very much.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: lp feasibility test

    Posted 11/29/11 11:42 AM

    Originally posted by: JFYY_yaohua_tang


    thanks very much, it works quiet very.

    a litter question about this function is that it will give me a bool value for the constraint.if conflicts,returns 0 and otherwise 1. Is there any function can directly return the difference between the ilorange.getExpr() and it's bouds?
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: lp feasibility test

    Posted 11/29/11 01:46 PM

    Originally posted by: SystemAdmin


    IloCplex::getSlack() should do what you want.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: lp feasibility test

    Posted 11/30/11 02:20 AM

    Originally posted by: JFYY_yaohua_tang


    thank you.
    #CPLEXOptimizers
    #DecisionOptimization