Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Problem with "adddDiversityFilter"

    Posted 03/31/10 03:50 PM

    Originally posted by: SystemAdmin


    Hi everybody,

    I am having problem with "addDiversityFilter".
    I do the following

    IloNumArray filterVal(*m_env);
    IloNumArray weight(*m_env);
    IloBoolVarArray filterVar(*m_env);
    m_cplexMP.solve();
    // fill out filterVar, weight and filterVal
    m_cplexMP.addDiversityFilter(1, IloInfinity, filterVar, weight, filterVal);
    m_cplexMP.populate();
    

    All the variables added to filterVar are binary variables of type ILOBOOL. This has been checked through a loop and getType() which confirms they are ILOBOOL type.

    When populate or even solve() instead of that is invoked I get:
    ERROR: CPLEX Error 3414: Diversity filter has non-binary variable.

    any comments?
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Problem with "adddDiversityFilter"

    Posted 04/07/10 01:58 PM

    Originally posted by: RWunderling


    Shahin,

    from this code snippet it is very hard to determine what might be going on. In particular there is no way
    to see how the arrays have been populated. Ideally you would provide a full example that shows your problem.
    The only thing that comes to mind without looking at a concrete example is that if IloConversion objects are involved, the type returned by getType() is different from what IloCplex eventually sees for a variable which
    could trigger such an exception.

    Roland
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Problem with "adddDiversityFilter"

    Posted 04/07/10 03:05 PM

    Originally posted by: SystemAdmin


    Hi Ronald,

    If the code would have been not so huge and messy I would have passed it definitely.
    I can say that, there is no iloconversion involved. The funny thing is that from a 3d matrix only particular indexes like x[i][4][j], x[i][9][j] has been.

    Anyway as I have written her before (and I dont know why disappeared now) I managed to assure that all the getTypes return 3 everything was fine. Again no conversion has been made.
    right before invoking solve() or populate everything was fine. I even exported lp file and checked it.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Problem with "adddDiversityFilter"

    Posted 04/08/10 01:30 PM

    Originally posted by: SystemAdmin


    You wrote that information on this different thread :-) I guess the two threads are related. I still could not reproduce your problem here. When I try what you describe everything is fine.
    Could you export the problem into a .sav file right before the solve and then post that file here and tell what variables are in the filter? Maybe this would allow me to reproduce the problem.
    Could you also do something like this:
    // Create filters and store the return values from
    // addDiversityFilter() into the filters array.
    IloArray<IloCplex::FilterIndex> filters;
    ...
     
    // Check filter variables.
    for (int f = 0; f < filters.getSize(); ++f) {
       IloNumVarArray filterVars(env);
       cplex.getFilterVars(filters[f], filterVars);
       for (int v = 0; v < filterVars.getSize(); ++v) {
          if (filterVars[v].getType() != ILOBOOL) {
             std::cerr << "Filter variable " << filterVars[v]
                       << " not binary!" << std::endl;
             ::abort();
          }
       }
    }
     
    // Solve model.
    try { cplex.solve(); }
    catch (IloException& e) { std::cerr << e << std::endl; }
     
    // Check filter variables again.
    for (int f = 0; f < filters.getSize(); ++f) {
       IloNumVarArray filterVars(env);
       cplex.getFilterVars(filters[f], filterVars);
       for (int v = 0; v < filterVars.getSize(); ++v) {
          if (filterVars[v].getType() != ILOBOOL) {
             std::cerr << "Filter variable " << filterVars[v]
                       << " not binary!" << std::endl;
             ::abort();
           }
       }
    }
    

    That is, check the filters right before and after the solve (ignoring the exception that is thrown by solve()).
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Problem with "adddDiversityFilter"

    Posted 04/08/10 02:14 PM

    Originally posted by: SystemAdmin


    Daniel,

    I cannot touch the cplex objet. when I try "m_cplexMP.exportModel("res.sav");" it tels me:

    ERROR: CPLEX Error 3414: Diversity filter has non-binary variable.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Problem with "adddDiversityFilter"

    Posted 04/08/10 02:27 PM

    Originally posted by: SystemAdmin


    Damn it!
    Have you tried that other code snippet I posted. The one that checks the type of the filter variables? I guess it doesn't cause any trouble?
    I have one more idea how to try to reproduce the problem:
    // Setup the model
    ...
    cplex.exportModel("model.sav");
     
    // Create the filters
    ...
    cplex.writeFilters("filters");
     
    // Solve to make sure we get the exception.
    cplex.solve();
    

    Then post files model.sav and filters here.
    Of course you should not change the model after exporting it.
    By the way, did you run your binary through valgrind or something similar? These spurious changes in type may also be caused by writing to invalid memory areas.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Problem with "adddDiversityFilter"

    Posted 04/08/10 02:42 PM

    Originally posted by: SystemAdmin


    Hi Daniel,

    I think I need to explain you more things;
    I solve the problem to optimality and then use the same objective value to creat a filter which pools customized solutions.
    In this was the first time I solve it then I add the filter and then I cannot touch cplex object anymore.

    Lets do it this way. I have an EXTREMELY dirty and messy copy of my code I can send it all to you together with data file. Just let me have a secure canal as I am not supposed to publicly disclose it.
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Problem with "adddDiversityFilter"

    Posted 04/08/10 02:51 PM

    Originally posted by: SystemAdmin


    Okay, can you please send the stuff to daniel(dot)junglas(at)de(dot)ibm(dot)com.
    Please don't forget to tell me how build/run it. And can you once more list your exact environment (CPLEX version and operating system).
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Problem with "adddDiversityFilter"

    Posted 04/08/10 02:58 PM

    Originally posted by: SystemAdmin


    I sent it. Just plz confirm if you received.
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Problem with "adddDiversityFilter"

    Posted 04/13/10 01:14 AM

    Originally posted by: SystemAdmin


    Just to keep you updated: I got your files and ran them here. However, I could not reproduce the exception you report. I will keep trying.
    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: Problem with "adddDiversityFilter"

    Posted 04/13/10 11:27 AM

    Originally posted by: SystemAdmin


    Thanks!
    Interesting that does not occur on your machine!
    I have tried it on windows as well as linux both it crashed.
    #CPLEXOptimizers
    #DecisionOptimization