Skip to content

Julia module memory and global variable issue #95

@ShubhamGoel96

Description

@ShubhamGoel96

How to add memory feature in this reserve calculation or add a global variable type in a Julia module structure-

Code-
function reserves_calc(projection::Projection)
max_t = policy_term(projection)* 12
annual_disc_rate = 0.08
#monthly_disc_rate = maximum(BasicTerm_ME.disc_rate(t,projection)) #0.0064

    res_l = zeros(max_t + 1)  # Preallocate array for inc_in_res

    for t in max_t:-1:0
        if t == max_t
            res_l[t+1] = 0#BasicTerm_ME.reserves(t, projection)
        elseif t > proj_len(projection)[] 
            res_l[t+1] = 0.0
        else
            res_l[t+1] = max(-10000000,(val_net_cashflow(t+1, projection) .+ res_l[t+2]) / (1 .+ maximum(disc_rate(t,projection))))#BasicTerm_ME.reserves(t, projection) #- BasicTerm_ME.reserves((t-1), projection)
        end
    end
    return res_l
end


function reserves(t,projection)#, projection::Projection)
    x = reserves_calc(projection)
    return x[t]
end    

I want to use the results of res_l array in reserves function without running reserves_calc function each time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions