Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  No solutions found when I change the objective

    Posted 01/19/18 03:26 AM

    Originally posted by: Zefeng


    Hi, I encountered a strange problem. I was using CP to solve a problem and feasible solutions could be found. But when I changed the objective, with the other parts unchanged, no solutions could be found. I think changing the objective has nothing to do with the solution space, so such a thing should not happen. What might be the reason? 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: No solutions found when I change the objective

    Posted 01/19/18 03:46 AM

    Hi,

    you get no solution because of time limit ?

    If yes, can you increase the time limit ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: No solutions found when I change the objective

    Posted 01/19/18 08:25 AM

    Originally posted by: Zefeng


    In fact, I did not set time limit for the problem. 

    These are the .mod file and the .dat file. 

    .mod file:

    using CP;

    int numfac=...;
    int xnumgrid=...;
    int ynumgrid=...;

    int gridlength=...;
    int gridwidth=...;

    int roadwidth=...;

    int faclength[i in 1..numfac][j in 1..2]=...;

    float cost[i in 1..numfac][j in 1..numfac]=...;

    dvar interval facits[i in 1..numfac][j in 1..2] size faclength[i][j];

    dvar boolean atx[i in 1..numfac][x in 1..xnumgrid];
    dvar boolean aty[i in 1..numfac][y in 1..ynumgrid];

    int ust[y in 1..ynumgrid]=y*(roadwidth+gridwidth);
    int dst[y in 1..ynumgrid]=y*(roadwidth+gridwidth)-gridwidth;
    int rst[x in 1..xnumgrid]=x*(roadwidth+gridlength);
    int lst[x in 1..xnumgrid]=x*(roadwidth+gridlength)-gridlength;

    dexpr int uedge[i in 1..numfac]=sum(y in 1..ynumgrid) ust[y]*aty[i][y];
    dexpr int dedge[i in 1..numfac]=sum(y in 1..ynumgrid) dst[y]*aty[i][y];
    dexpr int redge[i in 1..numfac]=sum(x in 1..xnumgrid) rst[x]*atx[i][x];
    dexpr int ledge[i in 1..numfac]=sum(x in 1..xnumgrid) lst[x]*atx[i][x];

    dvar boolean direc[i in 1..numfac];
    dexpr int ufac[i in 1..numfac]=endOf(facits[i][1])*(1-direc[i])+endOf(facits[i][2])*direc[i];
    dexpr int dfac[i in 1..numfac]=startOf(facits[i][1])*(1-direc[i])+startOf(facits[i][2])*direc[i];
    dexpr int rfac[i in 1..numfac]=endOf(facits[i][2])*(1-direc[i])+endOf(facits[i][1])*direc[i];
    dexpr int lfac[i in 1..numfac]=startOf(facits[i][2])*(1-direc[i])+startOf(facits[i][1])*direc[i];

    dvar boolean fac[i in 1..numfac];
    dexpr int fx[i in 1..numfac]=(direc[i])*(startOf(facits[i][1])+endOf(facits[i][1])) div 2+
        (1-direc[i])*((endOf(facits[i][2])+roadwidth div 2)*fac[i]+(startOf(facits[i][2])-roadwidth div 2)*(1-fac[i]));
    dexpr int fy[i in 1..numfac]=(1-direc[i])*(startOf(facits[i][1])+endOf(facits[i][1])) div 2+
        (direc[i])*((endOf(facits[i][2])+roadwidth div 2)*fac[i]+(startOf(facits[i][2])-roadwidth div 2)*(1-fac[i]));

    dexpr int samex[i in 1..numfac][j in 1..numfac]=sum(x in 1..xnumgrid) (atx[i][x]*atx[j][x]);
    dexpr int samey[i in 1..numfac][j in 1..numfac]=sum(y in 1..ynumgrid) (aty[i][y]*aty[j][y]);

    dexpr int spcountx[i in 1..numfac][j in 1..numfac]=samex[i][j]*direc[i]*direc[j]*(fy[i]!=fy[j]);
    dexpr int spcounty[i in 1..numfac][j in 1..numfac]=samey[i][j]*(1-direc[i])*(1-direc[j])*(fx[i]!=fx[j]);

    dexpr int absx[i in 1..numfac][j in 1..numfac]=(fx[i]+fx[j]-ledge[i]-redge[i]>=0)*(fx[i]+fx[j]-ledge[i]-redge[i])
                                                   +(fx[i]+fx[j]-ledge[i]-redge[i]<0)*(ledge[i]+redge[i]-fx[i]-fx[j]);
    dexpr int absy[i in 1..numfac][j in 1..numfac]=(fy[i]+fy[j]-dedge[i]-uedge[i]>=0)*(fy[i]+fy[j]-dedge[i]-uedge[i])
                                                   +(fy[i]+fy[j]-dedge[i]-uedge[i]<0)*(dedge[i]+uedge[i]-fy[i]-fy[j]);

    dexpr int spdistancex[i in 1..numfac][j in 1..numfac]=roadwidth-absx[i][j]-ledge[i]+redge[i];
    dexpr int spdistancey[i in 1..numfac][j in 1..numfac]=roadwidth-absy[i][j]-dedge[i]+uedge[i];

    /*    after adding search phases, both objective 1 and objective 2 has solutions
    execute {
       cp.param.TimeMode = "ElapsedTime";
       cp.param.TimeLimit = 6000;
       var f = cp.factory;
       cp.setSearchPhases(f.searchPhase(atx),f.searchPhase(aty),
                               f.searchPhase(direc),f.searchPhase(fac),
                               f.searchPhase(facits));
    }
    */

    /*    objective 1, no solutions found with this objective
    minimize sum(i,j in 1..numfac:i<j) cost[i][j]*(
        abs(fx[i]-fx[j])*(1-spcountx[i][j])+spdistancex[i][j]*spcountx[i][j]+
        abs(fy[i]-fy[j])*(1-spcounty[i][j])+spdistancey[i][j]*spcounty[i][j]
    );
    */

    //    objective 2, solutions can be found with this objective
    minimize sum(i,j in 1..numfac:i<j) cost[i][j]*(
        abs(fx[i]-fx[j])*(1-spcountx[i][j])+
        abs(fy[i]-fy[j])*(1-spcounty[i][j])
    );
    //

    subject to
    {
        forall(ordered i,j in 1..numfac)
            or(k in 1..2) (direc[i]==direc[j])*overlapLength(facits[i][k],facits[j][k])+
                          (direc[i]!=direc[j])*overlapLength(facits[i][k],facits[j][3-k])==0;

        forall(i in 1..numfac){
            sum(j in 1..xnumgrid) atx[i][j]==1;
            sum(j in 1..ynumgrid) aty[i][j]==1;
            ufac[i]<=uedge[i];
            dfac[i]>=dedge[i];
            rfac[i]<=redge[i];
            lfac[i]>=ledge[i];
        }

        forall(i in 1..numfac){
            (endOf(facits[i][2])*fac[i]+startOf(facits[i][2])*(1-fac[i]))==
            (uedge[i]*fac[i]+dedge[i]*(1-fac[i]))*direc[i]+
            (redge[i]*fac[i]+ledge[i]*(1-fac[i]))*(1-direc[i]);
        }
    }

    .dat file:

    numfac=6;
    xnumgrid=1;
    ynumgrid=1;
    gridlength=1000000;
    gridwidth=1000000;
    roadwidth=100000;

    faclength=[
    [62150 105700]
    [76400 369000]
    [147000 39300]
    [354950 178550]
    [179450 370200]
    [323600 347050]
    ];

    cost=[
    [0 7.092 3.7 9.366 2.613 4.305]
    [7.092 0 0.038 9.803 5.282 5.054]
    [3.7 0.038 0 0.582 3.428 8.622]
    [9.366 9.803 0.582 0 6.153 1.28]
    [2.613 5.282 3.428 6.153 0 0.525]
    [4.305 5.054 8.622 1.28 0.525 0]
    ];


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: No solutions found when I change the objective

    Posted 01/19/18 08:49 AM

    Hi,

    then can you post your model here so that other users could have a look ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer