Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  A little help in script!

    Posted 04/27/12 12:37 PM

    Originally posted by: meletis13forever


    Hello,

    I have these tuples in my model and I want to generate random variables near the base station for my terminals (base station is the first item in the tuple infratuple. The other are femtocells.) in a script block.

    tuple terminaltuple{
    key string name;
    int x;
    int y;
    float maxBW;
    {float} availBW;
    }
    {terminaltuple} terminal=...;
    terminaltuple dummy;

    tuple infratuple{
    key string name;
    int x;
    int y;
    {float} PL;
    float maxPower;
    float cap;
    }
    {infratuple} infra=...;

    The script block I have is this:

    execute{
    writeln(terminal);
    for(var t in terminal){
    dummy.x=100000;
    dummy.y=100000;
    while((infra(1).x-dummy.x)^2 + (infra(1).y-dummy.y)^2 >= 500.0){
    dummy.x=875+Opl.rand(30);
    dummy.y=268+Opl.rand(30);
    //writeln("testing- xter="+dummy.xter + ";yter="+dummy.yter);
    }
    t.x=dummy.x;
    t.y=dummy.y;
    writeln("success adding "t.name" "t.x" "+t.y);
    }
    }

    This script don't work. Can you help me?
    Here is the data file:

    terminal = { <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}>,
    <", 0, 0, 1024, {64, 128, 256, 384, 512, 1024}> };
    infra = { <", 885, 278, {1.0}, 60.0, 3700.0>,
    <", 835, 211, {0.5, 0.6, 0.7, 0.8, 0.9, 1}, 0.12, 10000.0>,
    <", 326, 426, {0.5, 0.6, 0.7, 0.8, 0.9, 1}, 0.12, 10000.0>,
    <", 825, 298, {0.5, 0.6, 0.7, 0.8, 0.9, 1}, 0.12, 10000.0>,
    <", 927, 334, {0.5, 0.6, 0.7, 0.8, 0.9, 1}, 0.12, 10000.0>,
    <", 933, 222, {0.5, 0.6, 0.7, 0.8, 0.9, 1}, 0.12, 10000.0>,
    <", 869, 358, {0.5, 0.6, 0.7, 0.8, 0.9, 1}, 0.12, 10000.0>,
    <", 938, 275, {0.5, 0.6, 0.7, 0.8, 0.9, 1}, 0.12, 10000.0>,
    <", 881, 276, {0.5, 0.6, 0.7, 0.8, 0.9, 1}, 0.12, 10000.0> };
    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: A little help in script!

    Posted 04/30/12 04:44 AM

    Originally posted by: meletis13forever


    In the while() I want to access the field int x (885) and the field int y (278) of my first element (<", 885, 278, {1.0}, 60.0, 3700.0>,) of my set infra!

    Can you help my with the declaration?
    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: A little help in script!

    Posted 05/01/12 11:57 AM

    Originally posted by: SystemAdmin


    You should probably ask this question on the OPL Forum.
    Also wrap your code into '{code}' tags. This way it is easier to read and not scrambled by the Forum software.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 4.  Re: A little help in script!

    Posted 05/03/12 12:17 PM

    Originally posted by: meletis13forever


    I found the solution. I inserted to the model these type of arrays to access my tuple element:
    terminaltuple terminalterminals = t in terminaldata ;
    infratuple infrainfrastructure = i in infradata ;

    Also I had to add 2 string sets for the infrastructure and the terminals:
    {string} infrastructure=...;
    {string} terminals=...;

    And in the while I wrote:
    while((infra.x-dummy.x)^2 + (infra.y-dummy.y)^2 >= 500.0){
    #DecisionOptimization
    #MathematicalProgramming-General


  • 5.  Re: A little help in script!

    Posted 05/03/12 12:18 PM

    Originally posted by: meletis13forever


    I found the solution. I inserted to the model these type of arrays to access my tuple element (with []):
    terminaltuple terminal terminals = t.name : t | t in terminaldata ;
    infratuple infra infrastructure = i.name : i | i in infradata ;

    Also I had to add 2 string sets for the infrastructure and the terminals:
    {string} infrastructure=...;
    {string} terminals=...;

    And in the while I wrote:
    while((infra.x-dummy.x)^2 + (infra.y-dummy.y)^2 >= 500.0){
    #DecisionOptimization
    #MathematicalProgramming-General