Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  CPLEX(Default) cannot extract expression

    Posted 10/19/16 09:30 PM

    Originally posted by: jon.rosen


    CPLEX Errors out when i try running the following: 

     

    tuple dist_job {
       key string name; 
       float lower_emp_limit; // minimum labor hours that can be assigned to Employees
       float upper_emp_limit;
    }
    {dist_job} dist_jobs = ...;

    // individual record of historical work request or forecast file
    tuple aggregated_work_request {
       
       string Date;
       string install_wo;
       string wr_no;
       string job_type_code;
       string dist_job;
       string district_wr;
       string staffing;
       float fte_adder;
       float fte_sub;
       float total_cost;
       float labor_hours;
       float asb_hours;
       float asb_labor;
       float emp_avg;
       float con_avg;
       float emp_stddev;
       float con_stddev;
       float emp_stderror;
       float con_stderror;
    }
    {aggregated_work_request} AggregatedWorkRequests = ...;

    dvar boolean assign_job_to_contr_time[a in AggregatedWorkRequests];  // 1 if true 0 if false
    dvar boolean assign_job_to_company[a in AggregatedWorkRequests];     // 1 if true 0 if false


    dexpr float  ak = sum (t in dist_jobs) 
                      (
                         sum(a in AggregatedWorkRequests: a.dist_job == t.name) ( a.con_avg  * a.asb_hours * assign_job_to_contr_time[a] + a.emp_avg  * a.asb_hours * assign_job_to_company[a] ) + // mean cost
                         1.645 * sqrt( 
                                       (sum(a in AggregatedWorkRequests:  a.dist_job == t.name) (a.asb_hours * assign_job_to_contr_time[a]))^2 * (max(a in AggregatedWorkRequests:  a.job_type_code == t.name) (a.con_stderror))^2 +  // variance of contractor mean cost
                                       (sum(a in AggregatedWorkRequests:  a.dist_job == t.name) (a.asb_hours * assign_job_to_contr_time[a]))^2 * (max(a in AggregatedWorkRequests:  a.job_type_code == t.name) (a.emp_stderror))^2 +
                                        sum(a in AggregatedWorkRequests:  a.dist_job == t.name)
                                        (
                                           a.asb_hours^2 * assign_job_to_contr_time[a] * a.con_stddev^2 + // variance of cost for jobs assigned to contractors
                                           a.asb_hours^2 * assign_job_to_company[a] * a.emp_stddev^2      // variance of cost for jobs assigned to employees
                                        )   
                                     )                     
                      ); 


    // minimize total cost of performing all jobs
    minimize ak;


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: CPLEX(Default) cannot extract expression

    Posted 10/20/16 03:03 AM

    Hi,

    Can you attach your .dat too ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: CPLEX(Default) cannot extract expression

    Posted 10/20/16 08:48 AM

    Originally posted by: jon.rosen


    dist_jobs = {
    <  "Athens-S107BB" 0 1.0 >
    <  "Athens-S107BB-30" 0 1.0 >
    <  "Athens-S107BBCKT" 0 1.0 >

     

    AggregatedWorkRequests = {
    <  "03/12/2015"  "DOP0230816"  "56534990"  "S107RBN"  "Newark-S107RBN"  "Newark"  "Employee"  0  1  7736.85  79.685  25.48  2.07113091626428  184.76672392638  157.295  82.0238227  0.00000000  4.54287938  0.00000000  >
    <  "01/28/2015"  "DOP0229556"  "56348447"  "S185CO"  "West Ohio-S185CO"  "West Ohio"  "Employee"  0  1  1835.976  22.906  8.59  2.11296073498852  179.765625  1000000  85.2683642  1.00000000  21.3170910  1.00000000  >
    <  "11/20/2015"  "DOP0245448"  "59873635"  "S107CBA"  "Athens-S107CBA"  "Athens"  "Employee"  0  1  4791.692  54.771  20.85  1.73955852279562  136.826701298701  255.309  72.1413078  91.9450947  8.22126502  65.0149999  >
    <  "06/22/2015"  "DOP0236238"  "57605425"  "S107BBSAI"  "Newark-S107BBSAI"  "Newark"  "Employee"  0  1  461.291  6.45  2.25  2.19677699132251  192.587443897638  235.424166666667  96.3503296  129.029292  3.02277868  26.3379939  >

     

    here is a sample

     

    Thanks!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: CPLEX(Default) cannot extract expression

    Posted 10/20/16 10:38 AM

    Hi,

    I see two issues in your model:

    1) sqrt is not linear so I would rather use CPO

    2) max could lead to some issues since if the set is empty the max will be -maxint, so I would protect that with maxl(0,  )

    So in a nutshell, I would rewrite your model into

     using CP;
     
     tuple dist_job {
       key string name;
       float lower_emp_limit; // minimum labor hours that can be assigned to Employees
       float upper_emp_limit;
    }
    {dist_job} dist_jobs = ...;

    // individual record of historical work request or forecast file
    tuple aggregated_work_request {
       
       string Date;
       string install_wo;
       string wr_no;
       string job_type_code;
       string dist_job;
       string district_wr;
       string staffing;
       float fte_adder;
       float fte_sub;
       float total_cost;
       float labor_hours;
       float asb_hours;
       float asb_labor;
       float emp_avg;
       float con_avg;
       float emp_stddev;
       float con_stddev;
       float emp_stderror;
       float con_stderror;
    }
    {aggregated_work_request} AggregatedWorkRequests = ...;

    dvar boolean assign_job_to_contr_time[a in AggregatedWorkRequests];  // 1 if true 0 if false
    dvar boolean assign_job_to_company[a in AggregatedWorkRequests];     // 1 if true 0 if false

     


    dexpr float  ak = sum (t in dist_jobs)
                      (
                         sum(a in AggregatedWorkRequests: a.dist_job == t.name) ( a.con_avg  * a.asb_hours * assign_job_to_contr_time[a] + a.emp_avg  * a.asb_hours * assign_job_to_company[a] )+ // mean cost
                         1.645 * sqrt(
                                       (sum(a in AggregatedWorkRequests:  a.dist_job == t.name) (a.asb_hours * assign_job_to_contr_time[a]))^2 * (maxl(0,max(a in AggregatedWorkRequests:  a.job_type_code == t.name) (a.con_stderror)))^2 +  // variance of contractor mean cost
                                       (sum(a in AggregatedWorkRequests:  a.dist_job == t.name) (a.asb_hours * assign_job_to_contr_time[a]))^2 * (maxl(0,max(a in AggregatedWorkRequests:  a.job_type_code == t.name) (a.emp_stderror)))^2 +
                                        sum(a in AggregatedWorkRequests:  a.dist_job == t.name)
                                        (
                                           a.asb_hours^2 * assign_job_to_contr_time[a] * a.con_stddev^2 + // variance of cost for jobs assigned to contractors
                                           a.asb_hours^2 * assign_job_to_company[a] * a.emp_stddev^2      // variance of cost for jobs assigned to employees
                                        )   
                                     )                     
                      );


    // minimize total cost of performing all jobs
    minimize ak;

    subject to
    {

    }

    execute
    {
    writeln(ak);
    }

     

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: CPLEX(Default) cannot extract expression

    Posted 10/20/16 11:50 AM

    Originally posted by: jon.rosen


    Thanks, for the quick response, I had a feeling the SQRT would be a problem for the default engine.

     

    I made the suggested changes, my follow up error is as follows

     

     

    dexpr float  ak = sum (t in dist_jobs)
                      (
                         sum(a in AggregatedWorkRequests: a.dist_job == t.name)

     

    Is it a problem with the matching the t to the a?

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: CPLEX(Default) cannot extract expression

    Posted 10/20/16 12:01 PM

    Well, can you post your .mod and .dat ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: CPLEX(Default) cannot extract expression

    Posted 10/20/16 12:43 PM

    Originally posted by: jon.rosen


    Here they are


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: CPLEX(Default) cannot extract expression

    Posted 10/21/16 03:59 AM

    Hi,

    which CPLEX version do you use ?

    With 12.6.3 this model runs fine

    If you add

    execute
     {
     cp.param.timelimit=120;
     }

    at the top of your model, you ll get a csv file after 2 minutes

    Are you a researcher ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: CPLEX(Default) cannot extract expression

    Posted 10/21/16 09:10 AM

    Originally posted by: jon.rosen


    Operations research post grad,

     

    Im on 12.6.0.... still get the same empty array error.

     

    org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
        at org.eclipse.swt.SWT.error(SWT.java:4361)
        at org.eclipse.swt.SWT.error(SWT.java:4276)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4144)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
        at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: CPLEX(Default) cannot extract expression

    Posted 10/21/16 10:17 AM


  • 11.  Re: CPLEX(Default) cannot extract expression

    Posted 10/21/16 10:24 AM

    Originally posted by: jon.rosen


    You believe that this issue (possibly eclipse java?) can be solved by getting the latest version?

     

    Thanks again,

     

    Jon Rosen


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: CPLEX(Default) cannot extract expression

    Posted 10/21/16 10:44 AM

    I dunno but I cannot reproduce your issue with the latest version.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer