Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Why this update has failed - 3D array

    Posted 11/16/11 07:13 AM

    Originally posted by: SystemAdmin


    This code doesnt work,

    int a[1][1][0]=10;
    int t=10;
    int a[1][1]http://i in 0..t=round (a[1][1][0]/(1+d)^i);

    Please help
    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: Why this update has failed - 3D array

    Posted 11/16/11 01:47 PM

    Originally posted by: SystemAdmin


    I am not sure if I understand your variable structures completely, but the following seems to work in a .mod file:

    
    range r1=1..1; range r2=1..1; range r3=0..10; 
    
    int a[r1][r2][r3]; 
    
    int d=2; 
    
    int t=10; range t_range = 0..t; execute
    { a[1][1][0]=10; 
    
    for(var x in t_range)
    { a[1][1][x]=Opl.round(a[1][1][0]/Opl.pow((1+d),x)); 
    } 
    }
    


    If you are still having problems using the above approach, please provide the relevant code in {code} tags.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: Why this update has failed - 3D array

    Posted 11/16/11 06:09 PM

    Originally posted by: SystemAdmin


    I need to write a code which update 3D array like below,
    X,Y,Z p q r and d are given, each element should be integer.
    int Ohttp://i in 1..phttp://j in 1..qhttp://k in 1..r=[[http://X,X/(1+d)^1,X/(1+d)^2,....,X/(1+d)^r],[http:// Y,Y/(1+d)^1,Y/(1+d)^2,....,Y/(1+d)^r],[http:// Z,Z/(1+d)^1,Z/(1+d)^2,....,Z/(1+d)^r]],
    Actually final one would be like this,we know
    O[1][1][1]=X;
    O[1][1][k]=X/(1+d)^k
    Also
    O[2][1][1]=Y;
    O[2][1][k]=Y/(1+d)^k

    Similarly
    O[1][2][1]=Z;
    O[1][2][k]=Z/(1+d)^k;
    Which means each time O[1][1][1],O[1][2][1],O[1][3][1],....,O[1][q][1] and O[2][1][1],O[2][2][1],...O[p][q][1] given
    Which means O[m][n][k]=O[m][n][0]/(1+d)^k
    For all m and n;
    0[m][n][0] are given. I need do update other elements like above, other elements change as a function of K.

    Thanks.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 4.  Re: Why this update has failed - 3D array

    Posted 11/16/11 06:15 PM

    Originally posted by: SystemAdmin


    Sorry It appeared with errors

    I need to write a code which update 3D array like below,
    X,Y,Z p q r and d are given, each element should be integer.
    int Ohttp://i in 1..phttp://j in 1..qhttp://k in 1..r=[[ http://X,X/(1+d)^1,X/(1+d)^2,....,X/(1+d)^r],[http:// Y,Y/(1+d)^1,Y/(1+d)^2,....,Y/(1+d)^r],[http:// Z,Z/(1+d)^1,Z/(1+d)^2,....,Z/(1+d)^r]],
    Actually final one would be like this,we know
    O[1][1][1]=X;
    O[1][1][k]=X/(1+d)^k
    Also
    O[2][1][1]=Y;
    O[2][1][k]=Y/(1+d)^k

    Similarly
    O[1][2][1]=Z;
    O[1][2][k]=Z/(1+d)^k;
    Which means each time O[1][1][1],O[1][2][1],O[1][3][1],....,O[1][q][1] and O[2][1][1],O[2][2][1],...O[p][q][1] given
    Which means O[m][n][k]=O[m][n][0]/(1+d)^k
    For all m and n;
    0[m][n][0] are given. I need do update other elements like above, other elements change as a function of K.
    Thanks
    #DecisionOptimization
    #MathematicalProgramming-General


  • 5.  Re: Why this update has failed - 3D array

    Posted 11/16/11 08:42 PM

    Originally posted by: SystemAdmin


    Could you please surround your code with {code} tags? This will preserve their formatting.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 6.  Re: Why this update has failed - 3D array

    Posted 11/16/11 09:32 PM

    Originally posted by: SystemAdmin


    I need to write a code which update 3D array like below,
    X,Y,Z p q r and d are given, each element should be integer.
    int O{i in 1..p}{j in 1..q}{k in 1..r}={{{X,X/(1+d)^1,X/(1+d)^2,....,X/(1+d)^r}},{{ Y,Y/(1+d)^1,Y/(1+d)^2,....,Y/(1+d)^r}},{{ Z,Z/(1+d)^1,Z/(1+d)^2,....,Z/(1+d)^r}}},
    Actually final one would be like this,we know
    O{1}{1}{1}=X;
    O{1}{1}{k}=X/(1+d)^k
    Also
    O{2}{1}{1}=Y;
    O{2}{1}{k}=Y/(1+d)^k

    Similarly
    O{1}{2}{1}=Z;
    O{1}{2}{k}=Z/(1+d)^k;
    Which means each time O{1}{1}{1},O{1}{2}{1},O{1}{3}{1},....,O{1}{q}{1} and O{2}{1}{1},O{2}{2}{1},...O{p}{q}{1} given
    Which means O{m}{n}{k}=O{m}{n}{0}/(1+d)^k
    For all m and n;
    0{m}{n}{0} are given. I need do update other elements like above, other elements change as a function of k.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 7.  Re: Why this update has failed - 3D array

    Posted 11/16/11 10:25 PM

    Originally posted by: SystemAdmin


    I am sorry, if I wasn't clear in my last comment about '{code}' tags . It will be great if you could simply attach your original code.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 8.  Re: Why this update has failed - 3D array

    Posted 11/16/11 11:50 PM

    Originally posted by: SystemAdmin


    int m=3;
    int n=3;
    int t=3;

    range r1=1..m;
    range r2=1..n;
    range r3=0..t;
    int ar1r2r3;
    float d=0.2;

    execute{
    a[1][1][0]=100;
    a[1][2][0]=143;
    a[1][3][0]=190;
    a[2][1][0]=121;
    a[2][2][0]=146;
    a[2][3][0]=176;
    a[3][1][0]=132;
    a[3][2][0]=98;
    a[3][3][0]=143;
    for(var r1 in m)
    for(var r2 in n)
    for(var r3 in t-1){
    a[m][n][k]=Opl.round(a[m][n][0]/(1+d)^k);
    }
    #DecisionOptimization
    #MathematicalProgramming-General


  • 9.  Re: Why this update has failed - 3D array

    Posted 11/17/11 12:02 AM

    Originally posted by: SystemAdmin


    Sorry this is the corrected code

    int m=3;
    int n=3;
    int t=3;

    range r1=1..m;
    range r2=1..n;
    range r3=0..t;
    int a r1 r2 r3;
    float d=0.2;

    execute{
    a[1][1][0]=100;
    a[1][2][0]=143;
    a[1][3][0]=190;
    a[2][1][0]=121;
    a[2][2][0]=146;
    a[2][3][0]=176;
    a[3][1][0]=132;
    a[3][2][0]=98;
    a[3][3][0]=143;
    for(var r1 in m)
    for(var r2 in n)
    for(var r3 in t-1){
    a[m][n]r3=round(a[m][n][0]/(1+d)^r3);
    }
    }
    #DecisionOptimization
    #MathematicalProgramming-General


  • 10.  Re: Why this update has failed - 3D array

    Posted 11/17/11 12:36 AM

    Originally posted by: SystemAdmin


    Hey
    This is the matlab code which is working perfectly,Same code i need to build in CPLEX studio as well

    This is the matlab code;

    clear all,close all,clc;
    l=3;
    m=3;
    n=3;
    a=zeros(l,m,n);
    d=0.1;

    for i=1:l;
    for j=1:m;
    for k=1:n-1;
    a(1,1,1)=10;
    a(2,1,1)=20;
    a(3,1,1)=30;
    a(1,2,1)=40;
    a(2,2,1)=50;
    a(3,2,1)=60;
    a(1,3,1)=70;
    a(2,3,1)=80;
    a(3,3,1)=90;

    a(i,j,k+1)= round(a(i,j,1) / (1+d)^k);
    end
    end
    end
    #DecisionOptimization
    #MathematicalProgramming-General


  • 11.  Re: Why this update has failed - 3D array

    Posted 11/17/11 11:50 AM

    Originally posted by: SystemAdmin


    Here is the Matlab equivalent of your code:

    
    
    
    int l=3; 
    
    int m=3; 
    
    int n=3;   range r1=1..l; range r2=1..m; range r3=1..n-1; 
    
    int a[1..l][1..m][1..n]; 
    
    float d=0.1;   execute
    { a[1][1][1]=10; a[1][2][1]=20; a[1][3][1]=30; a[2][1][1]=40; a[2][2][1]=50; a[2][3][1]=60; a[3][1][1]=70; a[3][2][1]=80; a[3][3][1]=90; 
    
    for(var i in r1) 
    
    for(var j in r2) 
    
    for(var k in r3)
    { a[i][j][k+1]=Opl.round(a[i][j][1]/Opl.pow((1+d),k)); 
    } 
    }
    


    I hope this helps.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 12.  Re: Why this update has failed - 3D array

    Posted 11/23/11 06:57 PM

    Originally posted by: SystemAdmin


    Thanks for the answer
    #DecisionOptimization
    #MathematicalProgramming-General