Seems like this would be much easier in a loop, rather than creating lots 
of temporaries only to extract them out later.
tunits = TUnit[]
for i in size(generators,1)
 pt_I = # create vector
 storia0UP = # create Float64
 # set other vars
 push!(tunits, TUnit(generators[j,:]..., pt_I, storia0UP, <other vars>))
end


On Tuesday, June 9, 2015 at 11:37:37 AM UTC-4, Michela Di Lullo wrote:
>
>
>
>     num_PC=7
>     generators = readdlm("$MyDataPath/gen" * "$NumBuses" * "_" * 
> "$GenInstance" * ".dat")
>     
>     inf=generators[1:size(generators,1),5]
>     sup=generators[1:size(generators,1),6]
>     pt_l=([inf[j]+(r-1)*(sup[j]-inf[j])/(num_PC-1) for j=1:gmax, 
> r=1:num_PC])
>     storia0=generators[1:size(generators,1),9]
>     ton=generators[1:size(generators,1),7]
>     toff=generators[1:size(generators,1),8]
>     storia0UP =  [max(storia0[j],0) for j=1:gmax]
>     storia0DW = -[min(storia0[j],0) for j=1:gmax]
>     u0=[(storia0[j] > 0 ? 1 : 0) for j=1:gmax]
>     ton0 = int16([min(hmax, max(0,(ton[j]-storia0UP[j])*u0[j])) for 
> j=1:gmax])
>     toff0= int16([min(hmax, max(0,(toff[j]-storia0DW[j])*(1-u0[j]))) for 
> j=1:gmax])
>
>     generators = cat(2, generators, pt_l, storia0UP, storia0DW, u0, ton0, 
> toff0)
>
>     immutable TUnit
>     Node::Int16
>     a::Float64
>     b::Float64
>     c::Float64
>     inf::Float64
>     sup::Float64
>     ton::Int16
>     toff::Int16
>     storia0::Int16
>     pt0::Float64
>     rampa_up::Float64
>     rampa_dwn::Float64
>     rampa_up_str::Float64
>     rampa_dwn_str::Float64
>     SUC_C::Float64
>     tau_max::Int16
>     pt_l
>     storia0UP::Float64
>     storia0DW::Float64
>     u0::Float64
>     ton0::Float64
>     toff0::Float64
>     end
>
>     TUnitS = Array(TUnit,size(generators,1))
>
>     for j in 1:size(generators,1)
>         TUnitS[j]   = TUnit(generators[j,1:end]...)
>     end
>
>     
>

Reply via email to