[julia-users] random number generation

2016-06-01 Thread Michela Di Lullo
How can I do to generate 6 *different* integer random numbers between 1 and 
14?

Thanks in advance to who will answer, 

M.

-- 
___
INVESTI SUL FUTURO, FAI CRESCERE L’UNIVERSITÀ:

*DONA IL 5 PER MILLE ALLA SAPIENZA*

CODICE FISCALE *80209930587*


[julia-users] write julia consolle output in a text file

2016-01-29 Thread Michela Di Lullo
How do I write the julia consolle output in a txt file? 

Thanks 

Michela


[julia-users] how to get gurobi log file

2016-01-28 Thread Michela Di Lullo
Hello, 

does anyone know how to get the gurobi log on a txt file when using julia?

Thanks for any suggestion,

Michela


[julia-users] how to get back the objective value, the number of explored nodes, number of simplex iterations from gurobi solver

2016-01-28 Thread Michela Di Lullo
Hello everyone, 

I'm solving iteratively a problem using gurobi solver and adding once a 
time a new violated constraint to the model. 

I want to iterate this procedure until the number of violated inequalities 
is zero and also I want to print for each iteration some informations I 
would like to analyze later (such as: 

   - the objective value
   - number of explored nodes
   - number of simplex iterations
   - best objective
   - best bound
   - first gap
   - final gap
   - resolution time

How do I make it in julia? 

Thanks for any suggestion, 

Michela


[julia-users] how to reset variables

2015-11-17 Thread Michela Di Lullo
Hello, 

I solve my model to find a LP solution, then I want to renew a binary 
constraint, then *reset* all the variables and solve the model again with 
some found violated constraints.

How do I *reset *variables? 

Thank you for any info,

Michela


Re: [julia-users] mixed arrays

2015-10-27 Thread Michela Di Lullo
 #step1: cycle definition
  ciclo=[(0,0,0)]
  for j=1:(size(Cb,2))
if (Cb[i,j]!=0)
  push!(ciclo,(BrancheS[j].line, BrancheS[j].from, BrancheS[j].to))
end
  end
  ciclo=ciclo[2:end]

  #step3: cycle capacity
  y=0
  for f=1:length(ciclo)
  y+=BrancheS[ciclo[f][1]].p_flow_max
  end

  #step2: subcycle definition and preliminary filtering on subcycles
  sottociclo=collect(combinations(ciclo,0))
  for z=1:length(ciclo)
if(2*BrancheS[ciclo[z][1]].p_flow_max>y)
  sottociclo=union(sottociclo,[ciclo[z]])
end
  end
for f=2:length(ciclo)
  sottociclo=union(sottociclo,combinations(ciclo,f))
end
  sottociclo=sottociclo[2:end]

Il giorno martedì 27 ottobre 2015 16:12:51 UTC+1, Tom Breloff ha scritto:
>
> The first row should be a vector of tuples, just like the other elements.  
> Please 
> post the code which generates sottociclo and maybe we can help further. 
>
> On Tuesday, October 27, 2015, Michela Di Lullo  > wrote:
>
>> Hello everyone,
>>
>> I have: 
>>
>> *sottociclo*
>>
>> *5-element Array{Any,1}:*
>>
>> * (1,2,5)  *
>>
>> * [(1,1,2),(2,1,5)]*
>>
>> * [(1,1,2),(5,2,5)]*
>>
>> * [(2,1,5),(5,2,5)]*
>>
>> * [(1,1,2),(2,1,5),(5,2,5)]*
>>
>>
>> *julia> **length(sottociclo[1])*
>>
>> *3*
>>
>>
>> *julia> **length(sottociclo[2])*
>>
>> *2*
>>
>> How might I modify the code such that *length(sottociclo[1])=1? *
>> I need length(sottociclo[*]) be equal to the number of tuple in row *...
>> Thanks in advance for any help,
>>
>> Michela 
>>
>

[julia-users] mixed arrays

2015-10-27 Thread Michela Di Lullo
Hello everyone,

I have: 

*sottociclo*

*5-element Array{Any,1}:*

* (1,2,5)  *

* [(1,1,2),(2,1,5)]*

* [(1,1,2),(5,2,5)]*

* [(2,1,5),(5,2,5)]*

* [(1,1,2),(2,1,5),(5,2,5)]*


*julia> **length(sottociclo[1])*

*3*


*julia> **length(sottociclo[2])*

*2*

How might I modify the code such that *length(sottociclo[1])=1? *
I need length(sottociclo[*]) be equal to the number of tuple in row *...
Thanks in advance for any help,

Michela 


[julia-users] ERROR: AssertionError: x.head == :escape

2015-10-25 Thread Michela Di Lullo
After the JuMP Package checkout
I get this error

*ERROR: AssertionError: x.head == :escape*


while declaring some functions.

what does it means? 

Michela



[julia-users] new function to calculate cycle basis in connected graphs

2015-10-13 Thread Michela Di Lullo
Hello,

I would share into the Graphs.jl package a new function to calculate cycle 
basis in connected graphs.

I looked at the source codes of some functions in the package and actually 
they use a specific language that is not exhaustively explained anywhere 
(as far as I know).
 
So my question is, when making a pull request, should I adapt my function 
to the package's standards or it is not necessary?
If yes, where could I find something about the language used for the 
functions in Graphs.jl? 

Thank you very much,

Michela


[julia-users] Re: issue with "plot"

2015-10-01 Thread Michela Di Lullo
Now I got:

*julia> **Format: "x11" not recognized. Use one of: bmp canon cgimage cmap 
cmapx cmapx_np dot eps exr fig gif gv icns ico imap imap_np ismap jp2 jpe 
jpeg jpg pct pdf pic pict plain plain-ext png pov ps ps2 psd sgi svg svgz 
tga tif tiff tk vml vmlz xdot xdot1.2 xdot1.4*




Il giorno giovedì 1 ottobre 2015 01:28:04 UTC+2, Tony Kelman ha scritto:
>
> I believe neato is a command from graphviz. On mac that would be easiest 
> to install via homebrew, brew install graphviz



[julia-users] issue with "plot"

2015-09-30 Thread Michela Di Lullo
Hello everyone, 

When I try to use the *plot* command from Graphs.jl I got this error:

*plot(g)*

*ERROR: could not spawn `neato -Tx11`: no such file or directory (ENOENT)*

* in _jl_spawn at process.jl:217*

* in spawn at process.jl:348*

* in open at 
/Applications/Julia-0.3.11.app/Contents/Resources/julia/lib/julia/sys.dylib*

* in plot at /Users/micheladilullo/.julia/v0.3/Graphs/src/dot.jl:91*


Could someone help me? 


Thank you in advance, 


Michela 


[julia-users] how to submit a new function?

2015-09-18 Thread Michela Di Lullo
Hello everyone,

I wrote a new julia function that calculates (a) cycle basis of a connected 
graph with m edges and n nodes, starting from its edge-node incidence matrix.

How could I share it with the julia community? 

I think it could perfectly stay in the Graphs.jl package.

Thank you in advance for any info,

Michela 

[julia-users] elements' ordering in a set

2015-09-16 Thread Michela Di Lullo
Hello everyone, 

does someone know why when I create a set, (sometimes) it automatically 
re-orders the elements in it? 
in example, if I have: 

*vector1=[1,2]*
*vector2=[3,4]*
*vector3=[5,6]*
*vector4=[7,8]*

*vector=Set({vector1, vector2, vector3, vector4})*

Set{Any}({[7,8],[1,2],[3,4],[5,6]})

*for i in vector*

*   @show i  *

* end*

i => [7,8]

i => [1,2]

i => [3,4]

i => [5,6]


How could I force it not to re-order the elements in the set? 


Thank you in advance for any information,


Michela 


[julia-users] lu factorization with partial pivoting

2015-09-09 Thread Michela Di Lullo
Hello everyone, 

I need to LU factorize a squared matrix A.
Specifically I need to make an LU decomposition with PARTIAL PIVOTING (only 
rows permutations, if needed). 

I found commands lufact(A) and lu(A), but I don't read anything about 
PARTIAL PIVOTING on the guide. 

Any idea about how to perform this partial pivoting LU factorization? 

Thank you very much for any info, 

Michela


[julia-users] error while trying to plot a graph when using Graph.jl and GraphViz.jl

2015-06-26 Thread Michela Di Lullo
Hello, 

this is the procedure I'm following: 

*Pkg.add("Graphs")*

*using Graphs*


*Pkg.add("GraphViz")*

*using GraphViz*


*g=simple_graph(3)*

*add_edge!(g,1,2)*

*add_edge!(g,3,2)*

*add_edge!(g,3,1)*


*plot(g)*


and this is the error I get: 


*julia> **plot(g)*

*ERROR: `to_dot` has no method matching 
to_dot(::GenericGraph{Int64,Edge{Int64},UnitRange{Int64},Array{Edge{Int64},1},Array{Array{Edge{Int64},1},1}},
 
::Pipe)*

* in plot at /Users/michela/.julia/v0.3/Graphs/src/dot.jl:86*


*julia> **Format: "x11" not recognized. Use one of: bmp canon cgimage cmap 
cmapx cmapx_np dot eps exr fig gif gv icns ico imap imap_np ismap jp2 jpe 
jpeg jpg pct pdf pic pict plain plain-ext png pov ps ps2 psd sgi svg svgz 
tga tif tiff tk vml vmlz xdot xdot1.2 xdot1.4*


does someone know what does it mean and how could I handle it? 

Thank you,


Michela

-- 
___
INVESTI SUL FUTURO, FAI CRESCERE L’UNIVERSITÀ:

*DONA IL 5 PER MILLE ALLA SAPIENZA*

CODICE FISCALE *80209930587*


[julia-users] cycle detection and cycle basis

2015-06-22 Thread Michela Di Lullo
Hi, 

does anyone know if there is any algorithm for cycle detection or cycle 
basis computation (for directed graphs) in julia? 

Thank you in advance

Michela Di Lullo

-- 
___
INVESTI SUL FUTURO, FAI CRESCERE L’UNIVERSITÀ:

*DONA IL 5 PER MILLE ALLA SAPIENZA*

CODICE FISCALE *80209930587*


Re: [julia-users] Re: issue defining a type's attribute..

2015-06-10 Thread Michela Di Lullo
Tom, I read about typealias and solved the problem.

Thank you very much for your help :)

Michela

2015-06-10 17:23 GMT+02:00 Tom Breloff :

> If I understand, you want:
>  pt_l::Vector{Float64}
> in your definition, which is equivalent to:
>  pt_l::Array{Float64,1}
>
> Vector is just an alias for a 1-dimensional array.  Somewhere in base
> julia, there's a line that looks something like:
> typealias Vector{T} Array{T,1}
>
>
> When you're constructing TUnit, you can't do it by splatting one giant
> vector "generators[j,:]...".  You'll have to pass in "pt_l" as its own
> argument, so you can control that it's a Vector{Float64}.
>
>
>
>
>
> On Wednesday, June 10, 2015 at 11:02:52 AM UTC-4, Michela Di Lullo wrote:
>
>> Thank you very much Tom.
>>
>> I tried the way you say, but I still get an error:
>>
>> *ERROR: `convert` has no method matching convert(::Type{Float64},
>> ::Array{Float64,2})*
>>
>> * in TUnit at no file*
>>
>> * in anonymous at no file:11*
>>
>>
>> Is it correct the way I define pt_l in TUnit?
>>
>>
>> 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::Array{Float64,7}
>>
>> pt_l::Matrix{Float64}
>>
>> #pt_l::Array{Float64,2}
>>
>> storia0UP::Float64
>>
>> storia0DW::Float64
>>
>> u0::Float64
>>
>> ton0::Float64
>>
>> toff0::Float64
>>
>> #function foo(args)
>>
>> ##function body
>>
>> #end
>>
>> end
>>
>> 2015-06-10 16:36 GMT+02:00 Tom Breloff :
>>
>>> I can't be completely sure of your goal and why you can't use a loop,
>>> but if you need to create those matrices/vectors, this is much cleaner:
>>>
>>> gmax = size(generators, 1)
>>> hmax = size(nodeload, 1)
>>> inf, sup, ton, toff, storia0 = [generators[:,i] for i in 5:9]
>>>
>>> # pt_l here will be a Matrix{Float64} (which is equivalent to
>>> Array{Float64,2})
>>> pt_l = inf .+ (sup - inf) * (0:num_PC-1)' / (num_PC-1)   # note: the
>>> ".+" operator broadcasts the column
>>>  # vector inf to
>>> the (gmax x num_PC) matrix
>>>
>>> # the following will be Vector{Float64} (which is equivalent to
>>> Array{Float64,1})
>>> storia0UP = max(storia0, 0.0)  # there's a version of max/min which
>>> operate on vectors... no need to use comprehensions
>>> storia0DW = min(storia0, 0.0)
>>> u0 = float(map(x -> x>0, storia0))   # mapping an anonymous function to
>>> the vector, then converting a Vector{Bool} to Vector{Float64} which are 1's
>>> and 0's
>>>
>>> bound0 = x -> max(0.0, min(x, hmax))   # attaching an anonymous function
>>> to a variable
>>> ton0 = map(bound0, (ton - storia0UP) .* u0)   # mapping that function
>>> toff0 = map(bound0, (toff - storia0DW) .* (1.0 - u0))
>>>
>>> # note you can splat the row from generators first then fill in the
>>> remaining args
>>> # no need to do the "cat" step (plus you should use hcat instead of
>>> cat(2, ...))
>>> tunits = [TUnit(generators[j,:]..., vec(pt_l[j,:]), storia0UP[j],
>>> storia0DW[j], u0[j], ton0[j], toff0[j]) for j in 1:gmax]
>>>
>>>
>>> However I still thing you should do:
>>>
>>> tunits = TUnit[]
>>> for j in 1:gmax
>>>  pt_l = ???
>>>  storia0UP = ???
>>>  storia0DW = ???
>>>  u0 = ???
>>>  ton0 = ???
>>>  toff0 = ???
>>>
>>>  push!(tunits, TUnit(generators[j,:]..., pt_l, storia0UP, storia0DW, u0,
>>> ton0, toff0))
>>> end
>>>
>>> Let me know if you have any questions.
>>>
>>>
>>>
>>>
>>> On Wednesday, June 10, 2015 at 8:16:10 AM UTC-4, Michela Di Lullo wrote:
>>>>
>>>> I still get an

Re: [julia-users] Re: issue defining a type's attribute..

2015-06-10 Thread Michela Di Lullo
Thank you very much Tom.

I tried the way you say, but I still get an error:

*ERROR: `convert` has no method matching convert(::Type{Float64},
::Array{Float64,2})*

* in TUnit at no file*

* in anonymous at no file:11*


Is it correct the way I define pt_l in TUnit?


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::Array{Float64,7}

pt_l::Matrix{Float64}

#pt_l::Array{Float64,2}

storia0UP::Float64

storia0DW::Float64

u0::Float64

ton0::Float64

toff0::Float64

#function foo(args)

##function body

#end

end

2015-06-10 16:36 GMT+02:00 Tom Breloff :

> I can't be completely sure of your goal and why you can't use a loop, but
> if you need to create those matrices/vectors, this is much cleaner:
>
> gmax = size(generators, 1)
> hmax = size(nodeload, 1)
> inf, sup, ton, toff, storia0 = [generators[:,i] for i in 5:9]
>
> # pt_l here will be a Matrix{Float64} (which is equivalent to
> Array{Float64,2})
> pt_l = inf .+ (sup - inf) * (0:num_PC-1)' / (num_PC-1)   # note: the ".+"
> operator broadcasts the column
>  # vector inf to
> the (gmax x num_PC) matrix
>
> # the following will be Vector{Float64} (which is equivalent to
> Array{Float64,1})
> storia0UP = max(storia0, 0.0)  # there's a version of max/min which
> operate on vectors... no need to use comprehensions
> storia0DW = min(storia0, 0.0)
> u0 = float(map(x -> x>0, storia0))   # mapping an anonymous function to
> the vector, then converting a Vector{Bool} to Vector{Float64} which are 1's
> and 0's
>
> bound0 = x -> max(0.0, min(x, hmax))   # attaching an anonymous function
> to a variable
> ton0 = map(bound0, (ton - storia0UP) .* u0)   # mapping that function
> toff0 = map(bound0, (toff - storia0DW) .* (1.0 - u0))
>
> # note you can splat the row from generators first then fill in the
> remaining args
> # no need to do the "cat" step (plus you should use hcat instead of cat(2,
> ...))
> tunits = [TUnit(generators[j,:]..., vec(pt_l[j,:]), storia0UP[j],
> storia0DW[j], u0[j], ton0[j], toff0[j]) for j in 1:gmax]
>
>
> However I still thing you should do:
>
> tunits = TUnit[]
> for j in 1:gmax
>  pt_l = ???
>  storia0UP = ???
>  storia0DW = ???
>  u0 = ???
>  ton0 = ???
>  toff0 = ???
>
>  push!(tunits, TUnit(generators[j,:]..., pt_l, storia0UP, storia0DW, u0,
> ton0, toff0))
> end
>
> Let me know if you have any questions.
>
>
>
>
> On Wednesday, June 10, 2015 at 8:16:10 AM UTC-4, Michela Di Lullo wrote:
>>
>> 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(storia

Re: [julia-users] Re: issue defining a type's attribute..

2015-06-10 Thread Michela Di Lullo
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, ))
> 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
>>
>> 
>>
>

Re: [julia-users] Re: issue defining a type's attribute..

2015-06-09 Thread Michela Di Lullo


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




[julia-users] Re: issue defining a type's attribute..

2015-06-09 Thread Michela Di Lullo
The problem is for attribute *pt_l::Float64*

that is a matrix (of float values) of dimension size(generators,1). 
I guess I've to say somehow that pt_l is a matrix... while node, a, ..., 
toff are vectors. 



Il giorno martedì 9 giugno 2015 17:14:33 UTC+2, Tom Breloff ha scritto:
>
> I think you want to create a constructor:
> TUnit(node::Float64,a::Float64,...,toff0::Float64) = TUnit(round(Int16,
> node),a,...,toff0)
>
>
>
> On Tuesday, June 9, 2015 at 10:50:06 AM UTC-4, Michela Di Lullo wrote:
>>
>> My type is: 
>>
>> 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
>>
>> Then I have:
>>
>> TUnitS = Array(TUnit,size(generators,1))
>>
>> for j in 1:size(generators,1)
>> TUnitS[j]   = TUnit(generators[j,1:end]...)
>> end
>>
>> Now, pt_l is a matrix of float numbers, and so 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)*
>>
>> How can I declare it properly? 
>>
>

[julia-users] issue defining a type's attribute..

2015-06-09 Thread Michela Di Lullo
My type is: 

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

Then I have:

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

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

Now, pt_l is a matrix of float numbers, and so 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)*

How can I declare it properly? 


[julia-users] how to compute the maximum value of an object's attribute

2015-05-07 Thread Michela Di Lullo
Hello everyone, 

I have to compute the maximum value of tau_max, attribute of TUnit which is 
declared as follows:

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

end


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


for j in 1:size(generators,1)

#println(generators[j,1:end])

#FL:This call the contructor, see all the discussion in the manual 
"Parametric Constructors" section

#to understand the whole (complex story) of the syntax with "..."

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

println("TUnit = ", j, "\t Node[$j]= ", TUnitS[j].Node, "\t a[$j] = ", 
TUnitS[j].a, "\t ...", "\t tau_max[$j] = ", TUnitS[j].tau_max)

end


I tried with both maximum(TUnitS.tau_max) and maximum(TUnitS[j].tau_max, 
j=[1:gmax]), but it doesn't work..


Any idea about how to make it? 


Thank you very much for any suggestion,


Michela


[julia-users] how to display the whole model

2015-04-24 Thread Michela Di Lullo
Hello everyone,

I'm new to julia and I was wondering how to display the whole model. 
I tried with: 

mod=Model(...)
...

display(mod)


Feasibility problem with:

 * 144 linear constraints

 * 2822 variables: 1514 binary

Solver set to Gurobi


but it only says the *number* of variables and constraints in the model.. 
while I want to see the constraints/objective in its/their expanded forms.  


Any idea about how to make it? 

Thank you all for any suggestion :)


[julia-users] Re: susceptance matrix

2015-04-24 Thread Michela Di Lullo
Thank you very much Patrick and ST. I'm really grateful to you for your 
help. 

I finally have my susceptance matrix. 

Best regards,

Michela 

Il giorno giovedì 23 aprile 2015 13:51:05 UTC+2, Michela Di Lullo ha 
scritto:
>
> Hello everyone, 
>
> I'm pretty new to the julia programming language and I'm having issues 
> while trying to declare a susceptance matrix in a unit commitment problem.
>
> I have the following elements: 
>
> BUS=[1:14]
>
> LINES=[1:20]
>
> NODE_FROM=[1 1 2 2 2 3 4 4 4 5 6 6 6 7 7 9 9 10 12 13]
>
> NODE_TO=[2 5 3 4 5 4 5 7 9 6 11 12 13 8 9 10 14 11 13 14]
>
> BRANCH=[(LINES[l], NODE_FROM[l], NODE_TO[l]) for l=1:length(LINES)]
>
> s1=[(i,i) for i in BUS]
>
> s2=[(m,k) for (l,m,k) in BRANCH]
>
> s3=[(k,m) for (l,m,k) in BRANCH]
>
> Y_BUS=union(s1,s2,s3)
>
> branch_x=[0.05917, 0.22304, 0.19797, 0.17632, 0.17388, 0.17103, 0.04211, 
> 0.20912, 0.55618, 0.25202, 0.1989, 0.25581, 0.13027, 0.17615, 0.11001, 
> 0.0845, 0.27038, 0.19207, 0.19988, 0.34802]
>
> and I need to declare the B susceptance matrix defined, in AMPL, as:
>
> param B{(k,m) in YBUS} := if(k == m)  then sum{(l,k,i) in BRANCH}  
> 1/branch_x[l,k,i] 
>  
> +sum{(l,i,k) in BRANCH}  1/branch_x[l,i,k]
>   else if(k != m) then 
> 
> sum{(l,k,m) in BRANCH}  1/branch_x[l,k,m]
>   
> +sum{(l,m,k) in BRANCH}  1/branch_x[l,m,k];
>
> I'm trying to make it but it's not working because of the indexes. I don't 
> know how to declare the parameter branch_x indexed by (n,b_from,b_to).
>
> Any idea about how to declare the B matrix correctly? 
>
> Thank you for any suggestion, 
>
> Michela
>


[julia-users] susceptance matrix

2015-04-23 Thread Michela Di Lullo
Hello everyone, 

I'm pretty new to the julia programming language and I'm having issues 
while trying to declare a susceptance matrix in a unit commitment problem.

I have the following elements: 

BUS=[1:14]

LINES=[1:20]

NODE_FROM=[1 1 2 2 2 3 4 4 4 5 6 6 6 7 7 9 9 10 12 13]

NODE_TO=[2 5 3 4 5 4 5 7 9 6 11 12 13 8 9 10 14 11 13 14]

BRANCH=[(LINES[l], NODE_FROM[l], NODE_TO[l]) for l=1:length(LINES)]

s1=[(i,i) for i in BUS]

s2=[(m,k) for (l,m,k) in BRANCH]

s3=[(k,m) for (l,m,k) in BRANCH]

Y_BUS=union(s1,s2,s3)

branch_x=[0.05917, 0.22304, 0.19797, 0.17632, 0.17388, 0.17103, 0.04211, 
0.20912, 0.55618, 0.25202, 0.1989, 0.25581, 0.13027, 0.17615, 0.11001, 
0.0845, 0.27038, 0.19207, 0.19988, 0.34802]

and I need to declare the B susceptance matrix defined, in AMPL, as:

param B{(k,m) in YBUS} := if(k == m)  then sum{(l,k,i) in BRANCH}  
1/branch_x[l,k,i] 
 
+sum{(l,i,k) in BRANCH}  1/branch_x[l,i,k]
  else if(k != m) then 

sum{(l,k,m) in BRANCH}  1/branch_x[l,k,m]
  
+sum{(l,m,k) in BRANCH}  1/branch_x[l,m,k];

I'm trying to make it but it's not working because of the indexes. I don't 
know how to declare the parameter branch_x indexed by (n,b_from,b_to).

Any idea about how to declare the B matrix correctly? 

Thank you for any suggestion, 

Michela


Re: [julia-users] How to declare correctly this matrix?

2015-04-21 Thread Michela Di Lullo
Dear Andreas,

you are right. I forgot to define gmax. It's my fault :)

Anyway the solution you suggested in your previous post works perfectly, so 
thank you very much for answering. 

Michela



Il giorno martedì 21 aprile 2015 18:35:28 UTC+2, Andreas Noack ha scritto:
>
> Hi Michela
>
> It is easier to help if your example is complete such that it can just be 
> pasted into the terminal. The variable gmax is not defined in your example, 
> but I guess it is equal to length(SUC_C). It is also useful to provide the 
> exact error message.
>
> That said, I think the root of the problem is the dependency between the 
> loop variable in the comprehension. The loop variable r depends on the 
> other loop variable j which is not allowed in comprehension. A solution 
> could be to preallocate suc, e.g. something like
>
> suc = zeros(length(SUC_C), length(tau_max))
> for j = 1:length(SUC_C)
> for r = 1:tau_max[j]
> suc[j,r] = SUC_C[j]*(1 - 1/(r+1))
>     end
> end
>
> 2015-04-21 12:21 GMT-04:00 Michela Di Lullo  >:
>
>> Hello everyone, 
>>
>> I'm trying to declare the following matrix:
>>
>> suc=[SUC_C[j]*(1-1/(r+1)) for j=1:gmax, r=1:tau_max[j]]
>>
>> whereas: 
>>
>> SUC_C=[6661.09, 8236.1, 7619.48, 8462.68, 5705.73, 6040.87]
>>
>> tau_max=[4,4,3,2,1,4]
>>
>> but it's not working. 
>>
>> Any idea about how to make it correctly? 
>>
>> Thanks for any info,
>>
>> Michela
>>
>
>

[julia-users] How to declare correctly this matrix?

2015-04-21 Thread Michela Di Lullo
Hello everyone, 

I'm trying to declare the following matrix:

suc=[SUC_C[j]*(1-1/(r+1)) for j=1:gmax, r=1:tau_max[j]]

whereas: 

SUC_C=[6661.09, 8236.1, 7619.48, 8462.68, 5705.73, 6040.87]

tau_max=[4,4,3,2,1,4]

but it's not working. 

Any idea about how to make it correctly? 

Thanks for any info,

Michela


Re: [julia-users] how to model semicontinuous variables in Julia

2015-03-30 Thread Michela Di Lullo


Il giorno lunedì 30 marzo 2015 21:45:13 UTC+2, Miles Lubin ha scritto:
>
> Hi Michela, 
>

> It looks like you're referring to JuMP, in which case:
>
> @defVar(m, a <= x <= b, SemiCont)
>
> should do the trick. See also the documentation: 
> http://jump.readthedocs.org/en/release-0.8/refvariable.html?highlight=semicontinuous
>
> We prefer to direct optimization-related questions to julia-opt 
> <https://groups.google.com/forum/#!forum/julia-opt>, for future reference.
>
> Best,
> Miles
>
> On Monday, March 30, 2015 at 3:36:15 PM UTC-4, Kevin Squire wrote:
>>
>> Hi Michela,
>>
>> I think you're going to need to provide some additional information.  Are 
>> you modeling this in JuMP by chance?  
>>
>> Cheers,
>>Kevin
>>
>> On Mon, Mar 30, 2015 at 12:25 PM, Michela Di Lullo <
>> michela...@uniroma1.it> wrote:
>>
>>> Hallo everyone! 
>>>
>>> how do I model a variable (array of variables) that can either be zero 
>>> or in some range not containing zero?  
>>> e.g. x∈0∪[a,b] where a>0
>>>
>>> Thank you in advance for any information!
>>>
>>
>>> Michela
>>>
>>
>>
Yes, exactly..
I'm working with JuMP. 

I need to model a matrix of semicontinuos power variables p[i,j] that 
assume values in *0 union [pt_min,pt_max]*
In other words it's: 

for i=1:gmax

{@defVar(m, inf[i]<= pt[1:hmax] <=sup[i], SemiCont)}

end 
but pt can also be equal to 0 !!
How do I model it? 

Thanks to anyone will answer 


[julia-users] how to model semicontinuous variables in Julia

2015-03-30 Thread Michela Di Lullo
Hallo everyone! 

how do I model a variable (array of variables) that can either be zero or 
in some range not containing zero?  
e.g. x∈0∪[a,b] where a>0

Thank you in advance for any information!

Michela


[julia-users] semicontinuous variables

2015-03-30 Thread Michela Di Lullo
how do I model in Julia a variable that can be either zero or in some range 
non containing zero? e.g. x \in 0 \cup [a,b] where a>0. 

Thanks in advance for any information!

Michela