Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
datejada committed Feb 26, 2025
1 parent 5baa36c commit 80fc0fe
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DuckDB = "d2f5444f-75bc-4fdf-ac35-56f514c445e1"
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
TulipaEnergyModel = "5d7bd171-d18e-45a5-9111-f1f11ac5d04d"
TulipaIO = "7b3808b7-0819-42d4-885c-978ba173db11"
64 changes: 53 additions & 11 deletions docs/src/50-schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The optimization model parameters with the input data must follow the schema below for each table. To create these tables we currently use CSV files that follow this same schema and then convert them into tables using TulipaIO, as shown in the basic example of the [Tutorials](@ref basic-example) section.

The schemas can be accessed at any time after loading the package by typing `TulipaEnergyModel.schema_per_table_name` in the Julia console. Here is the complete list of model parameters in the schemas per table (or CSV file):
The schemas can be found in the `input-schemas.json` or can be accessed at any time after loading the package by typing `TulipaEnergyModel.schema_per_table_name` in the Julia console. Here is the complete list of model parameters in the schemas per table (or CSV file):

!!! info "Optional tables/files and their defaults"
The following tables/files are allowed to be missing: "assets\_rep\_periods\_partitions", "assets\_timeframe\_partitions", "assets\_timeframe\_profiles", "flows\_rep\_periods\_partitions", "group\_asset", "profiles\_timeframe".
Expand All @@ -11,14 +11,56 @@ The schemas can be accessed at any time after loading the package by typing `Tul
- If no group table/file is available there will be no group constraints in the model

```@eval
using Markdown, TulipaEnergyModel
Markdown.parse(
join(["- **`$filename`**\n" *
join(
[" - `$f: $t`" for (f, t) in schema],
"\n",
) for (filename, schema) in TulipaEnergyModel.schema_per_table_name
] |> sort, "\n")
)
"""
The output of the following code is a Markdown text with the following structure:
TABLE_NAME
=========
PARAMETER_NAME
• Description: Lorem ipsum
• Type: SQL type of the parameter
• Default: a value or "No default"
• Unit of measure: a value or "-"
• Constraints: a table or "No constraints"
"""
using Markdown, JSON
using OrderedCollections: OrderedDict
input_schemas = JSON.parsefile("../../src/input-schemas.json"; dicttype = OrderedDict)
let buffer = IOBuffer()
for (i,(table_name, fields)) in enumerate(input_schemas)
write(buffer, "## Table $i : `$table_name`\n\n")
for (field_name, field_info) in fields
desc = get(field_info, "description", "No description provided")
typ = get(field_info, "type", "Unknown type")
unit = get(field_info, "UoM", "-")
default = get(field_info, "default", "No default")
constraints_val = get(field_info, "constraints", nothing)
write(buffer, "**`$field_name`**\n\n")
write(buffer, "- Description: $desc\n\n")
write(buffer, "- Type: `$typ`\n")
write(buffer, "- Unit of measure: `$unit` \n")
write(buffer, "- Default: `$default`\n")
if constraints_val === nothing
write(buffer, "- Constraints: No constraints\n")
elseif isa(constraints_val, OrderedDict)
write(buffer, "| Constraints | Value |\n| --- | --- |\n")
for (key, value) in constraints_val
write(buffer, "| $key | `$value` |\n")
end
write(buffer, "\n")
else
write(buffer, "- Constraints: `$(string(constraints_val))`\n")
end
end
end
Markdown.parse(String(take!(buffer)))
end
```

0 comments on commit 80fc0fe

Please sign in to comment.