Hi Andrew,

Cool that you found JuMP! Please have a look at the docs: 
https://jump.readthedocs.org/en/latest/jump.html

Some of the differences that you will encounter coming from AMPL are:
- JuMP doesn't separate the model and the data, you just use the data 
directly in the model.
- JuMP variables can be indexed over a numeric range or any set of hashable 
objects in an arbitrary number of dimensions. The only catch is that the 
full cartesian product of possible variables will be created. It looks like 
this isn't the case for the model below. Instead you can directly use a set 
of tuples:
indexset = [(1,1),(3,5),(6,1)]
@defVar(m, x[indexset])
# then access with:
x[(1,1)]
# or 
for s in indexset
   @addConstraint(m, ... x[s] ... == ...)
end
- There's no special JuMP syntax for creating the index sets, just use 
Julia's own functions.
- The sum{} syntax lets you sum over sets, optionally with conditionals. 
This is described in the docs.
- There's no special syntax (yet) for adding a set of constraints; instead, 
create them in a loop. Duals are accessible if you store constraint 
references.

Hopefully that should get you started. If you run into any issues at all, 
have specific questions about the syntax, or don't get the performance you 
expected, feel free to open an issue on our project's github 
page: https://github.com/JuliaOpt/JuMP.jl/issues.

Thanks!
Miles

On Wednesday, January 15, 2014 2:44:49 PM UTC-3, Andrew B. Martin wrote:
>
> Hi Iain,
>
> Awesome! Yes, JuMP is what I had in mind when I said using julia to code 
> my models.
>
> The following code snippet is representative of 90% of the code in my AMPL 
> models.
>
> How would I code the following AMPL variable, CC_OWN, and its support, in 
> JuMP/julia? 
>
> # Mapping of stand_type, timber_yield_type and period to timber yield 
> generated.
> # Derived from the set yields and param Yield
> set timber_yields:= setof{ (i,y,t) in yields: y in timber_yield_types } 
> (i,y,t);
> param Timber_Yield{ (i,y,t) in timber_yields }, default Yield[i,y,t];
>
> # All stands and prescriptions belonging to ownership u with a clearcut 
> intervention
> # scheduled for period t
> set clearcuts_own{u in ownerships, t in 0..Own_Periods}:= 
> setof{ (i,j) in harvestable[t] : (Harv_Types[ISA[i],j,t] = 11 or 
> Harv_Types[ISA[i],j,t] = 8) and Stand_Ownership[i] = u } (i,j);
>
> # Clearcuts take all volume off a stand. Clearcut volume
> # of type y, from ownership u, timbershed r, and period t.
> s.t. cc_own{u in ownerships, y in timber_yield_types, r in tsheds, t in 
> 0..Own_Periods}:
> CC_OWN[u,y,r,t] = (sum{ (i,j) in clearcuts_own[u,t] : Stand_Tshed[i] = r } 
> (Timber_Yield[Stand_Type[i,j,t],y, Stand_Age[ISA[i],j,t]]*x[i,j]));
>
>
> Andrew
>
> On Tuesday, January 14, 2014 5:49:13 PM UTC-5, Iain Dunning wrote:
>>
>> Hi Andrew,
>>
>> JuMP is exactly what you are looking for.
>> https://github.com/JuliaOpt/JuMP.jl
>> https://jump.readthedocs.org/en/release-0.2/jump.html
>>
>> The documentation is quite comprehensive, and there is a lot of example 
>> code. The code base is stable too, its ready for use (I use it for my own 
>> research).
>> Feel free to file issues for anything you might want to know.
>> We achieve near-AMPL speeds if you use our @addConstraint macros, and 
>> support directly calling CPLEX, Gurobi, GLPK, Cbc as well as output to LP 
>> and MPS file formats.
>> It blows PuLP out of the water - I recommend JuMP over PuLP for people in 
>> my department now. See http://www.mit.edu/~mlubin/juliacomputing.pdf for 
>> benchmarks.
>>
>> We don't have the full "helper" capabilities of AMPL but we'd be happy to 
>> help translate those to Julia equivalents if you need help.
>>
>> Cheers,
>> Iain
>>
>> On Tuesday, January 14, 2014 3:35:55 PM UTC-5, João Felipe Santos wrote:
>>>
>>> Did you have a look at JuMP? I believe it is equivalent to PuLP, but 
>>> written in Julia: https://github.com/JuliaOpt/JuMP.jl
>>>
>>> --
>>> João Felipe Santos
>>>
>>>
>>> On Tue, Jan 14, 2014 at 2:52 PM, Andrew B. Martin <
>>> [email protected]> wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm new to julia; I discovered it when I posted in the python pulp-or 
>>>> google group about generating large LP models.
>>>>
>>>> I currently use AMPL for model generation, but I'd like to switch to an 
>>>> open-source alternative. I first went to pulp-or because I'm familiar with 
>>>> python, but it's too slow; julia looks promising, but I'm concerned that 
>>>> since I don't have a solid grasp of the language I might code the 
>>>> constraints very inefficiently.
>>>>
>>>> The LP models I'm generating are about 1.5Gb as .lp files and take ~20 
>>>> minutes to generate on an 8Gb machine using AMPL.
>>>>
>>>> It would help me get started if someone here could translate a piece of 
>>>> my AMPL code to julia. I think I can translate the whole model if I have 
>>>> an 
>>>> example to compare against.
>>>>
>>>> Anyone here interested? It would be about 10 lines of AMPL code, 
>>>> describing a variable defined by two derived sets.
>>>>
>>>> Regards,
>>>> Andrew
>>>>
>>>
>>> 

Reply via email to