Drasil icon indicating copy to clipboard operation
Drasil copied to clipboard

SSP Data Defs and Table of Symbols cannot index

Open njericha opened this issue 8 years ago • 10 comments

I'm creating a new issue that stemmed from #265 being mostly fixed for clarity on what is still an issue.

The way Index works is that it is built into Expr. This works well for most cases except for two. Data Defs used an index-ed variable as the output such as the example given below. But the QDefinition takes a Quantity s, SymbolForm s and Expr to equate them. This means I cannot index the quantity becuase Index returns an Expr. 2017-07-20

The second issue is that I need to remove the subscript i from the symbols otherwise we would get duplicated is when index-ing them. This means the table of symbols displays the symbol without the subscript i.

I'm not sure what the best solution would involve. We could;

  • create a new data constructor for Symbol that can be a special index which would get ignored by Expr
  • change the type of Index
  • change the type of QDefinition and Table of Symbol constructors

njericha avatar Jul 20 '17 19:07 njericha

Making a note that @AKM11 has a similar issue in NoPCM.

njericha avatar Jul 21 '17 13:07 njericha

Can't we use some kind of pair as Index, to index by more than one thing "at once"? [This is different than double-indexing].

JacquesCarette avatar Jul 22 '17 15:07 JacquesCarette

@JacquesCarette I'm not sure what you mean by "some kind of pair". Do you mean, "Can we index the whole equation, rather than just the individual quantities?"

njericha avatar Jul 24 '17 12:07 njericha

I mean something that would mean the same as a[i,j], i.e. Index(a, Pair(i,j)) as an Expr. I don't know if we have the Pair constructor (or something like it) in Expr yet.

JacquesCarette avatar Jul 24 '17 17:07 JacquesCarette

We do not have something like that in Expr yet. That is not part this issue though. Right now, I'm treating "Ut,i" as "(Ut)i" where Ut is the symbol for the quantity and I am indexing it at i. The issue is that I cannot use Index on the left hand side of a QDefinition because you cannot index a symbol, only an Expr.

njericha avatar Jul 24 '17 17:07 njericha

I see, that is a rather different issue indeed.

QDefinition really is for defining single values (depending on an arbitrary number of other things, which do not need to be single values). Whether QDefinition can also be used to define vectors, arrays, tables, etc, is quite unclear to me. That will need some design.

JacquesCarette avatar Jul 24 '17 19:07 JacquesCarette

This needs to be solved for #397 to be fixed, as half of the current "duplicate" symbols are actually symbols that need to be indexed at some variable.

szymczdm avatar Nov 24 '17 04:11 szymczdm

As I revisit this: the correct fix is to add 'indexing' to Expr. It's a bit of a cheat, since indexing is really not very different from application (vectors, for example, can be seen as functions from [0..n-1] -> Space). But we want to display them differently. And they are typed (slightly) differently. So, for now, adding indexing to Expr is the best way to go about it.

JacquesCarette avatar Dec 02 '17 13:12 JacquesCarette

@JacquesCarette I know you looked at this in a lot more depth recently, have you made any headway on how indexing should be handled particularly?

szymczdm avatar May 04 '18 21:05 szymczdm

Nope, unfortunately not. I'll push it up on my priority list.

JacquesCarette avatar May 04 '18 22:05 JacquesCarette