I still get an error......

Let's try again.. 

    num_PC=7

    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::Float64
    storia0UP::Float64
    storia0DW::Float64
    u0::Float64
    ton0::Float64
    toff0::Float64
end

generators = readdlm("$MyDataPath/gen" * "$NumBuses" * "_" * "$GenInstance" 
* ".dat") *#matrix of dimension 6*16*
nodeload   = readdlm("$MyDataPath/nodeload" * "$NumBuses" * "_" * 
"$NodeloadInstance" * ".dat")

    gmax=int(size(generators,1))
    hmax=int(size(nodeload,2))
    inf=generators[1:size(generators,1),5]
    sup=generators[1:size(generators,1),6]
    storia0=generators[1:size(generators,1),9]
    ton=generators[1:size(generators,1),7]
    toff=generators[1:size(generators,1),8]

    #here below I'm computing some other quantities, I want to add as 
attributes of the object TUnit, 
    #together with the ones in generators:

    *pt_l=([inf[j]+(r-1)*(sup[j]-inf[j])/(num_PC-1) for j=1:gmax, 
r=1:num_PC]) #matrix of dimensions (gmax=6)*(num_PC=7)*
*    storia0UP =  [max(storia0[j],0) for j=1:gmax] #vector of dimensions 
(gmax=6)*1*
*    storia0DW = -[min(storia0[j],0) for j=1:gmax] **#vector of dimensions 
(gmax=6)*1*
*    u0=[(storia0[j] > 0 ? 1 : 0) for j=1:gmax] **#vector of dimensions 
(gmax=6)*1*
*    ton0 = int16([min(hmax, max(0,(ton[j]-storia0UP[j])*u0[j])) for 
j=1:gmax]) **#vector of dimensions (gmax=6)*1*
*    toff0= int16([min(hmax, max(0,(toff[j]-storia0DW[j])*(1-u0[j]))) for 
j=1:gmax]) **#vector of dimensions (gmax=6)*1*

    generators = cat(2, generators, pt_l, storia0UP, storia0DW, u0, ton0, 
toff0) #matrix of dimensions (gmax=6)*28

    TUnitS = Array(TUnit,size(generators,1))

    for j in 1:size(generators,1)
        TUnitS[j]   = TUnit(generators[j,1:end]...)
    end

and I get:

*ERROR: `TUnit` has no method matching TUnit(::Float64, ::Float64, 
::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, 
::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, 
::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, 
::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Int64, ::Int16, 
::Int16)*

* in anonymous at no file:5*

How could I specify that pt_l, attribute of the object TUnit, is a Matrix 
and not a vector? 

Thanks in advance for any suggestion, 

Michela 





Il giorno martedì 9 giugno 2015 18:54:56 UTC+2, Tom Breloff ha scritto:
>
> 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