Skip to content

Commit

Permalink
Add 1e6 value benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Oct 1, 2024
1 parent 4fb9741 commit c6b29b9
Show file tree
Hide file tree
Showing 5 changed files with 2,000,056 additions and 25 deletions.
56 changes: 34 additions & 22 deletions tests/fixtures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,18 @@ def load_dataset(cls, platform: ixmp4.Platform):


class BigOptimizationDataset:
units = pd.read_csv(here / "big/units.csv")
# For big data
# indexsets = pd.read_csv(here / "big/indexsets.csv")
# parameter_data = pd.read_csv(here / "big/parameterdata.csv")
# TODO
# To troubleshoot the big data, hijack this structure for small data temporarily
indexsets = pd.read_csv(here / "small/indexsets.csv")
parameter_data = pd.read_csv(here / "small/parameterdata.csv")
units = pd.read_csv(here / "big/units.csv")
# indexsets = pd.read_csv(here / "small/indexsets.csv")
# parameter_data = pd.read_csv(here / "small/parameterdata.csv")
# For special case requested by Volker:
indexsets = pd.read_csv(here / "big/indexsets_vk.csv")
InsertParameterData = pd.read_csv(here / "big/insert_parameterdata_vk.csv")
UpsertParameterData = pd.read_csv(here / "big/upsert_parameterdata_vk.csv")

@classmethod
def load_units(cls, platform: ixmp4.Platform):
Expand All @@ -276,7 +280,7 @@ def load_indexsets(cls, platform: ixmp4.Platform):
for _, name, elements in cls.indexsets.itertuples():
indexset = run.optimization.indexsets.create(name)
# TODO figure out how to store/parse lists from csv properly
indexset.add(elements=[x for x in range(1000)])
indexset.add(elements=[x for x in range(50)])

@classmethod
def load_parameter(cls, platform: ixmp4.Platform):
Expand All @@ -293,48 +297,56 @@ def load_parameter(cls, platform: ixmp4.Platform):
# TODO clean up after finalizing the implementation
@classmethod
def insert_parameter_data(cls, platform: ixmp4.Platform, parameter_id: int):
cls.parameter_data["values"] = [x for x in range(len(cls.parameter_data))]
cls.parameter_data["units"] = random.choices(
[unit.name for unit in platform.units.list()], k=len(cls.parameter_data)
cls.InsertParameterData["values"] = [
x for x in range(len(cls.InsertParameterData))
]
cls.InsertParameterData["units"] = random.choices(
[unit.name for unit in platform.units.list()],
k=len(cls.InsertParameterData),
)
platform.backend.optimization.parameters.add_data(
parameter_id, cls.parameter_data
parameter_id, cls.InsertParameterData
)

@classmethod
def insert_parameter_data_json(cls, platform: ixmp4.Platform, parameter_id: int):
cls.parameter_data["values"] = [x for x in range(len(cls.parameter_data))]
cls.parameter_data["units"] = random.choices(
[unit.name for unit in platform.units.list()], k=len(cls.parameter_data)
cls.InsertParameterData["values"] = [
x for x in range(len(cls.InsertParameterData))
]
cls.InsertParameterData["units"] = random.choices(
[unit.name for unit in platform.units.list()],
k=len(cls.InsertParameterData),
)
# TODO add add_data_json to abstract layer once implementation is complete
platform.backend.optimization.parameters.add_data_json( # type: ignore[attr-defined]
parameter_id, cls.parameter_data
parameter_id, cls.InsertParameterData
)

@classmethod
def upsert_parameter_data(cls, platform: ixmp4.Platform, parameter_id: int):
cls.parameter_data["values"] = [
x for x in range(1, len(cls.parameter_data) + 1)
cls.UpsertParameterData["values"] = [
x for x in range(1, len(cls.UpsertParameterData) + 1)
]
cls.parameter_data["units"] = random.choices(
[unit.name for unit in platform.units.list()], k=len(cls.parameter_data)
cls.UpsertParameterData["units"] = random.choices(
[unit.name for unit in platform.units.list()],
k=len(cls.UpsertParameterData),
)
platform.backend.optimization.parameters.add_data(
parameter_id, cls.parameter_data
parameter_id, cls.UpsertParameterData
)

@classmethod
def upsert_parameter_data_json(cls, platform: ixmp4.Platform, parameter_id: int):
cls.parameter_data["values"] = [
x for x in range(1, len(cls.parameter_data) + 1)
cls.UpsertParameterData["values"] = [
x for x in range(1, len(cls.UpsertParameterData) + 1)
]
cls.parameter_data["units"] = random.choices(
[unit.name for unit in platform.units.list()], k=len(cls.parameter_data)
cls.UpsertParameterData["units"] = random.choices(
[unit.name for unit in platform.units.list()],
k=len(cls.UpsertParameterData),
)
# TODO add add_data_json to abstract layer once implementation is complete
platform.backend.optimization.parameters.add_data_json( # type: ignore[attr-defined]
parameter_id, cls.parameter_data
parameter_id, cls.UpsertParameterData
)

@classmethod
Expand Down
13 changes: 13 additions & 0 deletions tests/fixtures/big/indexsets_vk.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name,elements
Indexset 0,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 1,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 2,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 3,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 4,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 5,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 6,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 7,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 8,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 9,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 10,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Indexset 11,"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"
Loading

0 comments on commit c6b29b9

Please sign in to comment.