Array randomization issue

In reply to nedicm:


    class Simple;
        
        typedef struct {
               string name;
               rand int unsigned param_1;
               rand int unsigned param_2;
        } traffic_t;
        
        traffic_t trafic[];
        rand traffic_t new_array[];
        rand int N[]; //helper
        int SUM_OF_PARAM_1 = 50;
        int SUM_OF_PARAM_2 = 25;
 
        function new();
             trafic = new[1000];
             foreach(trafic[i]) begin
                 $sformat(trafic[i].name,"name_%0d",i);
                 trafic[i].param_1 = $urandom_range(0,20);
                 trafic[i].param_2 = $urandom_range(0,20);
             end
        endfunction

        constraint c1 {
                new_array.size() inside {[1:10]};
                N.size() == new_array.size();
                foreach(N[i]) N[i] inside {[0:trafic.size()-1]};  
                foreach(new_array[i]) { 
                    new_array[i].param_1 == trafic[N[i]].param_1; 
                    new_array[i].param_2 == trafic[N[i]].param_2; 
                } 
                new_array.sum() with(int'(item.param_1)) == SUM_OF_PARAM_1;
                new_array.sum() with(int'(item.param_2)) <= SUM_OF_PARAM_2;
        }

        function void post_randomize();
                foreach(new_array[i]) begin new_array[i].name = trafic[N[i]].name; end
        endfunction 
    
    endclass



https://www.linkedin.com/in/patel-rahulkumar/