OptBio

This page lists the functions available in the OptBio module.

create_case

OptBio.create_caseFunction
OptBio.create_case(path_db::String; kwargs...)

Create a case for the OptBio model.

Arguments

  • path_db::String: Path to the database.

  • kwargs...: Keyword arguments for the database creation and study configurations.

    For the database creation, the following keyword arguments are available:

    • force::Bool: If true, the database is created even if it already exists. Default is false.
    • path_migrations_directory::String: Path to the migrations directory. Suggestions: use OptBio.optbio_migrations_dir() to get the migrations directory.

    For the study configurations, the following keyword arguments are available:

    • scenarios::Int: Number of uncertainty scenarios. Default is 1.
    • solution_method::Int: Solution method. Fulfill with 0 for deterministic equivalent, 1 for Benders decomposition. Default is 1.
    • minimum_iterations::Int: Minimum number of iterations for the Benders decomposition. Default is 3.
    • maximum_iterations::Int: Maximum number of iterations for the Benders decomposition. Default is 15.
    • write_lp: If 1, the LP files are written. Default is 0.

Returns

  • db::DatabaseSQLite: Database for the OptBio model.

Example

db = OptBio.create_case(
    "directory_of_the_case/my_case.optbio";
    force = true,
    path_migrations_directory = OptBio.optbio_migrations_dir(),
    scenarios = 3,
)

add_product!

OptBio.add_product!Function
OptBio.add_product!(db::DatabaseSQLite; kwargs...)

Add a product to the database.

Arguments

  • db::DatabaseSQLite: Database.
  • kwargs...: Keyword arguments with the product attributes.

The following attributes are available:

  • label::String: Product label.
  • unit::String: Product unit.
  • initial_availability::Float64: Initial availability of the product for a year. Default is 0.0.
  • sell_limit::Float64: Maximum amount of the product that can be sold within a year. Can be left empty.
  • sell_price::Float64: Price of the product, based on its unit. Default is 0.0, meaning the product is not for sale.
  • minimum_sell_quantity::Float64: Minimum amount of the product that can be sold within a year. Default is 0.0.
  • minimum_sell_violation_penalty::Float64: Penalty for violating the minimum sell quantity. Needs to be fulfilled if minimum_sell_quantity is greater than zero.

Example

OptBio.add_product!(
    db;
    label = "Sugar",
    sell_price = 5000.0,
    unit = "ton",
)

OptBio.add_product!(
    db;
    label = "Sugarcane",
    unit = "ton",
    initial_availability = 100.0,
)

add_plant!

OptBio.add_plant!Function
OptBio.add_plant!(db::DatabaseSQLite; kwargs...)

Add a plant to the database.

Arguments

  • db::DatabaseSQLite: Database.
  • kwargs...: Keyword arguments with the plant attributes.

The following attributes are available:

  • label::String: Plant label.
  • initial_capacity::Float64: Initial capacity of the plant for a year. Default is 0.0.
  • reference_capex::Float64: Capex of a reference plant.
  • reference_capacity::Float64: Capacity of the reference plant.
  • scaling_factor::Float64: Factor to scale the relation between capacity and capex according to the reference plant. Default is 0.7.
  • interest_rate::Float64: Annual interest rate for the Capex. Default is 0.1.
  • lifespan::Int: Years of lifespan for the plant. Defines the amount of installment payments for the Capex. Default is 20.
  • maximum_capacity::Float64: Maximum capacity of the plant for a year. Can be left empty.
  • maximum_capacity_for_scale::Float64: Maximum capacity of the plant at which the scaling factor is applied. After this capacity, the Capex is linearly scaled with the capacity. Can be left empty.

Example

OptBio.add_plant!(
    db;
    label = "Sugar Mill",
    reference_capacity = 100.0,
    reference_capex = 52000.0,
)

add_process!

OptBio.add_process!Function
add_process!(db::DatabaseSQLite; kwargs...)

Add a process to the database.

Arguments

  • db::DatabaseSQLite: Database.
  • kwargs...: Keyword arguments with the process attributes.

The following attributes are available:

  • label::String: Process label.
  • opex::Float64: Operating expense, based the amount of the first product in the input vector that is being processed.
  • product_input::Vector{String}: Input product labels.
  • factor_input::Vector{Float64}: Vector of factors at which the input products are consumed. Must be ordered according to product_input. Each factor is based on the unit of the corresponding product.
  • product_output::Vector{String}: Output product labels.
  • factor_output::Vector{Float64}: Vector of factors at which the output products are produced. Must be ordered according to product_output, and follow proportions to match inputs_factor. Each factor is based on the unit of the corresponding product.

Example

OptBio.add_process!(
    db;
    label = "Sugar Mill",
    opex = 0.0,
    product_input = ["Sugarcane"],
    factor_input = [1.0],
    product_output = ["Sugar"],
    factor_output = [0.75],
)

After creating the process, it is necessary to associate it with a plant. This can be done with the set_process_plant! function.

set_process_plant!

OptBio.set_process_plant!Function
OptBio.set_process_plant!(db::DatabaseSQLite, process_label::String, plant_label::String)

Set the plant associated with a process.

Example

OptBio.set_process_plant!(db, "Sugar Mill", "Sugar Mill")

add_sum_of_products_constraint!

OptBio.add_sum_of_products_constraint!Function
add_sum_of_products_constraint!(db::DatabaseSQLite; kwargs...)

Add a sum of products constraint to the database.

Arguments

  • db::DatabaseSQLite: Database
  • kwargs...: Keyword arguments with the sum of products constraint attributes.

The following attributes are available:

  • label::String: Sum of products constraint label.
  • product_id::Vector{String}: Vector with labels of products to be included in the sum of products constraint.
  • sell_limit::Float64: Sell limit for the sum of products in the vector.

Example

OptBio.add_sum_of_products_constraint!(
    db;
    label = "Ethanol",
    product_id = ["Ethanol 1G", "Ethanol 2G"],
    sell_limit = 2000.0,
)

write_scenarios

OptBio.write_scenariosFunction
OptBio.write_scenarios(
    product_label::Vector{String},
    product_unit::Vector{String},
    path::String,
    S::Int,
    initial_availability::Matrix{Float64},
    sell_price::Matrix{Float64},
)

Write scenarios attributes values to CSV files.

Arguments

  • product_label::Vector{String}: Product labels.
  • product_unit::Vector{String}: Product units.
  • path::String: The path of the directory where the CSV files will be written.
  • S::Int: Number of scenarios.
  • initial_availability::Matrix{Float64}: Initial availability of the products for each scenario.
  • sell_price::Matrix{Float64}: Sell price of the products for each scenario.

Example

product_label = ["Sugar", "Sugarcane"]
product_unit = ["ton", "ton"]

price_scenarios = [
    5000.0 0.0
    4000.0 0.0
    3000.0 0.0
]

initial_availability_scenarios = [
    0.0 100.0
    0.0 150.0
    0.0 80.0
]

OptBio.write_scenarios(
    product_label,
    product_unit,
    "directory_of_the_case",
    3,
    initial_availability_scenarios,
    price_scenarios,
)

main

OptBio.mainFunction
OptBio.main(args::Vector{String})

Main function to run the OptBio model.

Arguments

  • args::Vector{String}: Vector with arguments to be parsed. The only argument is the path to the database file.

Outputs

After running the model, a results folder will be created in the same directory as the database file. This folder will contain:

  • CSV files containing the solution of the optimization model.
  • A dashboard with the main results.
  • A flowchart with the whole production chain and the path chosen by the optimization model.

Example

OptBio.main(["directory_of_the_case/my_case.optbio"])