On Aug 26, 2009, at 3:47 PM, William Stein wrote:

> On Wed, Aug 26, 2009 at 2:39 PM, Jason Grout<jason- 
> s...@creativetrax.com> wrote:
>>
>> Nathann Cohen wrote:
>>>> Yes, you can use indexation like some_oovar[i] or some_oofun[i]
>>>> (probably with several indexes, or negative ones that are start  
>>>> from
>>>> array end), however, I think it should be avoided if possible  
>>>> (you'd
>>>> better split your oovar into several oovars).http:// 
>>>> www.openopt.org/FuncDesignerDoc#Some_issues_to_be_aware
>>>
>>> I sent a message on sage-support to know to which extent I could use
>>> multivariate Polynomials in Sage to represent constraints and Linear
>>> functions, but it seems to be troublesome... This said, there is no
>>> way for me to use Linear Programming if I can not use indexed
>>> variables... At the moment, even though the syntax could be
>>> tremendously improved, I can use any hashable Sage object as a
>>> variable, and most of the time in Graph theoretic function my
>>> variables are edges, vertices, or arbitrary tuples and strings.
>>> Anyway, most of the Linear Programs are generated from graphs and I
>>> have to find a way to let a computer create as many variables as
>>> possible :-/
>>> The current syntax, though, is not nearly satisfying.
>>>
>>
>> I should mention that at various times, people have proposed that you
>> could create symbolic variables x[1], x[2], etc.  As far as I know,
>> these proposals have just been ideas and have never been  
>> implemented or
>> experimented with.
>>
>> Maybe we could make x[1] a symbolic variable automatically.  We would
>> have to make an indexing function for symbolic variables that would
>> return a symbolic variable that would be cached somewhere (so that  
>> x[1]
>> always referred to the same variable).  That would also give us  
>> nested
>> indices, as x[1][1] would take a symbolic variable x, create a new  
>> one
>> x[1], and then x[1] would create another symbolic variable x[1][1].
>>
>
> That sounds pretty easy to implement by defining __getitem__ for
> symbolic variables, and making it cache its answer using a dictionary.

I've advocated for this before--I think it's a great idea.

>  Should one only allow x[integer] or more generally x[anything
> hashable]?

I would say x[anything symbolic]. Thus one could do

sage: var('x,a')
sage: x[a]
x[a]
sage: x[a].subs(a=1)
x[1]

I don't think x[a].subs(x=y) should be y[a], but you should be able  
to sub for x[...] as a normal variable.

- Robert


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to