Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Help me create random coordinates for my model

    Posted 11/30/11 10:21 AM

    Originally posted by: meletis13forever


    Hello,

    I am newbie in Ilog and I can not find a solution to my problem.

    You don't have to look all my model. As you can see in the beggining of my model I have terminals, macroBS( like telecommunication antenna) and femtocells. I give coordinates for femtos and macroBS in the data file but I want to give random coordinates to the terminals and to be in the coverage area (covBS) of the macroBS. I want to write something like this:

    do{
    xterm=random;
    yterm=random;
    }while((xbs-xterm)^2 + (ybs-yterm)^2>=covBS)

    This is my model:

    {string} terminal =...;
    {string} macroBS =...;
    {string} femto =...;

    tuple positionBS{
    int xbs;
    int ybs;
    }
    positionBS posBSmacroBS =...;

    tuple positionfemto{
    int xfem;
    int yfem;
    }
    positionfemto posfemtofemto=...;

    int covBS =...;
    int BWterminal =...;
    int capfemtofemto=...;
    int capBSmacroBS=...;
    int powerfemto=...;
    int NbPL=...;
    range PL = 0..NbPL-1;
    float lPL=...;

    dvar boolean xterminalmacroBS union femto;
    dvar boolean yPLfemto;
    dvar boolean NterminalfemtoPL;

    dexpr int loadj in femto union macroBS = sum(i in terminal) x[i][j] * BW[i];
    dexpr float CpPLj in femto = sum(k in PL) y[k][j] * l[k] * power[j];
    dexpr float covj in femto, k in PL = 10^((Cp[k][j]/20) + 1.96);

    minimize
    sum(j in femto, k in PL) Cp[k][j] +
    sum(j in femto, j2 in femto : j2!=j) (load[j] - loadj2)^2 +
    sum(i in terminal, j in macroBS union femto) x[i][j] * d[i][j] +
    sum(j in macroBS union femto) load[j];

    subject to{

    forall(i in terminal)
    sum(j in macroBS union femto)
    x[i][j] == 1;

    forall(j in femto)
    sum(k in PL)
    y[k][j] == 1;

    forall(i in terminal, j in femto, k in PL)
    N[i][j][k] <= y[k][j];

    forall(i in terminal, j in femto, k in PL)
    x[i][j] <= N[i][j][k] * y[k][j];

    forall(j in femto union macroBS)
    load[j] <= capBS[j];
    }

    And my data file:

    terminal = { "terminal1", "terminal2", "terminal3", "terminal4","terminal5", "terminal6", "terminal7", "terminal8", "terminal9", "terminal10","terminal11", "terminal12", "terminal13", "terminal14", "terminal15","terminal16", "terminal17", "terminal18", "terminal19", "terminal20"};
    macroBS = { "macroBS1"};
    femto = { "femto1", "femto2", "femto3", "femto4","femto5", "femto6", "femto7", "femto8" };

    posBS = <885,278>;
    posfemto = <835,211, 326,426, 825,298, 927,334, 933,222, 869,358, 938,275, 881,276>;

    covBS = 500;
    BW = http://64, 256, 12.2, 12.2, 128, 384, 64, 64, 12.2, 512, 128, 12.2, 64, 64, 1024, 128, 64, 12.2, 512, 384;
    capfemto = 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000;
    capBS = 3700;
    power = http://0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12;
    NbPL = 6;
    l = http://0.5, 0.6, 0.7, 0.8, 0.9, 1;
    Please can you help me?
    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: Help me create random coordinates for my model

    Posted 11/30/11 07:13 PM

    Originally posted by: SystemAdmin


    Since what you're asking is basically a question about IBM's scripting language for OPL and not about CPLEX, I suggest you post this to the OPL forum.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: Help me create random coordinates for my model

    Posted 11/30/11 09:45 PM

    Originally posted by: SystemAdmin


    As Paul suggests, its best that you post your OPL questions in the OPL forum- that ways you will be reaching folks who could answer it better. In any case, based on your description, here's a way to accommodate your requirements- it uses OPL scripts in an 'execute' block to populate an indexed tuple if the random # generated meets the condition:

    
    ... range PL = 0..NbPL-1; 
    
    float l[PL]=...;   tuple positionterminal
    { 
    
    int xter; 
    
    int yter; 
    } positionterminal posterminal[terminal]; positionterminal dummy; execute
    { 
    
    for(var t in terminal)
    { dummy.xter=100000; dummy.yter=100000; 
    
    while((posBS[
    "macroBS1"].xbs-dummy.xter)^2 + (posBS[
    "macroBS1"].ybs-dummy.yter)^2 >= covBS)
    { dummy.xter=875+Opl.rand(30); dummy.yter=268+Opl.rand(30); 
    //writeln("testing- xter="+dummy.xter + ";yter="+dummy.yter); 
    } posterminal[t]=dummy; writeln(
    "success adding - posterminal["+t+
    "]="+posterminal[t]); 
    } writeln(
    "posterminal="+posterminal); 
    }   dvar 
    
    boolean x[terminal,macroBS union femto]; dvar 
    
    boolean y[PL,femto]; ....
    


    Please note that the 'Opl.rand(30);' code essentially generates a random integer between 0 and 30 and the reason I use 'dummy.xter=875+Opl.rand(30);' is so that the chances of meeting your condition requirements are improved, otherwise, it may take a while before you get a valid xter and yter.

    Hope this helps.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 4.  Re: Help me create random coordinates for my model

    Posted 12/05/11 07:38 AM

    Originally posted by: meletis13forever


    Thank you very much for your answers.
    #DecisionOptimization
    #MathematicalProgramming-General