Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inventory all uses of indexing in the examples #3716

Open
JacquesCarette opened this issue May 3, 2024 · 13 comments
Open

Inventory all uses of indexing in the examples #3716

JacquesCarette opened this issue May 3, 2024 · 13 comments
Assignees

Comments

@JacquesCarette
Copy link
Owner

Before doing a full design of indexable structures, we should have a list of what already exists in our examples.

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented May 4, 2024

Yes! Thanks Dr. Carette. I will list all existing indexing-related examples in https://jacquescarette.github.io/Drasil/ before our full design.

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented May 22, 2024

I realized that the concept of “indexing” exists in the concrete examples rather than the concrete implementation, should we consider indexing in the general and examples-related data structure?

@JacquesCarette
Copy link
Owner Author

I'm not sure what you mean by the above comment? Can you expand on that please?

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented May 23, 2024

I think my comment above misunderstood the intent of your issue, so I want to make sure that what is expected to be done is to find out the use the concept of indexing in the current generated examples like DblPend (including SRS, generated code, generated code doc), that is to describe "where we are" in the application of indexing to the example, right?

@JacquesCarette
Copy link
Owner Author

We need to implement data-types that can be indexed (like vectors, matrices, but also lists, arrays, sequences, etc) in a general way. That is the problem to solve. We have current requirements for it, buried in the Drasil code base.

This is your project. It is non-trivial, which is why it can be a Master's level project if done correctly and properly.

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented May 23, 2024

I see, thanks for the explanation @JacquesCarette. What we want is a generalized solution.

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented Jul 10, 2024

Summary

Before designing the indexable data structure, we should list all the indexable structure types used in the current examples. Below is the summary information of my research:

List

The most common data structure in Haskell, whose elements can be accessed by index. Here are all the List types used in each example:

  • dblpend:
    • assumpDouble :: [ConceptInstance]
    • choices.lang :: [Lang]
  • gamephysics:
    • assumptions :: [ConceptInstance]
    • assumptionsListA :: [[Sentence]]
    • mkSRS :: SRSDecl
  • glassbr:
    • assumptions :: [ConceptInstance]
    • sysCtxUsrResp :: [Sentence]
    • abInputConstraints :: [(QuantityDict, Maybe (RealInterval Expr Expr))]
  • HGHC:
    • symbols :: [QuantityDict]
    • dataDefs :: [DataDefinition]
  • pdcontroller:
    • stdFields :: Fields
  • projectile:
    • assumptions :: [ConceptInstance]
  • ssp:
    • assumptions :: [ConceptInstance]
    • sysCtxList :: Contents (nested list)
  • swhs:
    • units :: [UnitDefn]
    • propsDeriv :: [Contents]
  • swhsnopcm:
    • units :: [UnitDefn]
    • symbols :: [DefinedQuantityDict]
    • symbolsAll :: [QuantityDict]
  • sqlbend:
    • dataDefs :: [DataDefinition]
    • genDefns :: [GenDefn]
    • velocityIXDerivSents :: [Sentence]
    • inputs :: [QuantityDict]
    • outputs :: [QuantityDict]
    • symbols :: [QuantityDict]
    • inConstraints :: [UncertQ]
    • outConstraints :: [UncertQ]
    • units :: [UnitalChunk]
    • unitalChunks :: [UnitalChunk]

Maps

The Map data structure in Haskell is used to store key-value pairs, and the keys allow for efficient indexed access. The use of Map in each example is as follows:

  • dblpend:
    • symbMap :: ChunkDB
    • usedDB :: ChunkDB
  • gamephysics:
    • symbMap :: ChunkDB
    • usedDB :: ChunkDB
  • glassbr:
    • usedDB :: ChunkDB
  • pdcontroller:
    • symbMap :: ChunkDB
    • usedDB :: ChunkDB
    • refDB :: ReferenceDB
  • projectile:
    • symbMap :: ChunkDB
    • usedDB :: ChunkDB
    • refDB :: ReferenceDB
  • ssp:
    • symbMap :: ChunkDB
    • usedDB :: ChunkDB
    • refDB :: ReferenceDB
  • swhsnopcm:
    • symbMap :: ChunkDB
    • usedDB :: ChunkDB
  • sqlbend:
    • symbMap :: ChunkDB
    • usedDB :: ChunkDB
    • refDB :: ReferenceDB

NonEmpty Lists

NonEmpty lists are guaranteed to have at least one element, which avoids the empty list problem and provides safer operations.

  • sqlbend:
    • defns(Using NonEmpty Lists in Code Segments)

Tuples

A tuple is a data structure that contains a fixed number of elements, and specific elements can be accessed by index.

  • glassbr:
    • slope :: (CodeExpr, CodeExpr) -> (CodeExpr, CodeExpr) -> CodeExpr
    • onLine :: (CodeExpr, CodeExpr) -> (CodeExpr, CodeExpr) -> CodeExpr -> CodeExpr
  • swhsnopcm:
    • qwC tempC $ UpFrom (Inc, sy tempInit)
  • ssp:
    • pages Indicates page numbers (as used in citations)

Records

The Records type contains multiple fields, each accessible by name.

  • dblpend:
    • choices :: Choices
  • gamephysics:
    • si :: SystemInformation
  • glassbr:
    • choices :: Choices
    • tolPre :: InstanceModel
  • pdcontroller:
    • codeChoices :: Choices
    • gdPowerPlant :: GenDefn
  • swhsnopcm:
    • si :: SystemInformation
    • Choices is a record

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented Jul 10, 2024

Currently, there is no implementation of vectors, matrices and sequences in our example.

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented Jul 10, 2024

The data types that already exist in the example include List, Maps, NonEmpty Lists, Tuples, and Records.

@JacquesCarette
Copy link
Owner Author

You are confusing the data types that exist at the Haskell-level implementation of the examples, and the data types that ought to exist in the target code implementation of the examples. For your work, we only care about the latter - so a lot of your data collection is not useful.

Also, it is important to understand (from the intent recorded in the SRS) what the data structures ought to be as opposed to the current implementations which may well use hacks to get the job done.

In other words this task involves actually understanding the intent, and cannot be done as a surface query.

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented Jul 10, 2024

I understand that the existing implementation may be in the form of walkaround. So what I'm going to do is actually divided into two steps, one superficial and the other deep.

  1. find out what data types are currently being implemented
  2. research the best implementation of the data types used in each example according to SRS, and determine whether the current implementation is the best (if there is one), and if not, how to implement it.

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented Jul 10, 2024

The list above is the first step, and what I need to do next is the second step.

@J1aM1ng
Copy link
Collaborator

J1aM1ng commented Jul 16, 2024

@JacquesCarette To confirm, our objectives are:

  1. To determine the best practice for data type design based on the existing examples, aiming for an ideal case scenario.
  2. To implement fundamental data types such as vectors and sequences, as demonstrated in the existing examples. This implementation should begin with a basic class (for instance, named 'IndexableStructure'). Classes like vector and sequence should then be derived from this IndexableStructure class. During the implementation process, it's crucial to consider and ensure compatibility with all edge cases present in the examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants