From 591439e634d7f3aa837e165f52515db07a4ea6aa Mon Sep 17 00:00:00 2001
From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
Date: Fri, 26 Jan 2024 21:34:51 +0000
Subject: [PATCH] Remove InsertedBuildingBlocks

---
 src/containers/sequences.jl     |  1 -
 src/inserted_building_blocks.jl | 64 ---------------------------------
 2 files changed, 65 deletions(-)
 delete mode 100644 src/inserted_building_blocks.jl

diff --git a/src/containers/sequences.jl b/src/containers/sequences.jl
index 5dc31a0..0e53c13 100644
--- a/src/containers/sequences.jl
+++ b/src/containers/sequences.jl
@@ -3,7 +3,6 @@ import JuMP: Model
 import ...GlobalModel: @global_model_constructor
 import ...Variables: variables, start_time, duration, VariableType
 import ...BuildingBlocks: BuildingBlock
-import ...InsertedBuildingBlocks: InsertedBuildingBlock
 
 """
     Sequence(building_blocks...)
diff --git a/src/inserted_building_blocks.jl b/src/inserted_building_blocks.jl
deleted file mode 100644
index 4a4b54d..0000000
--- a/src/inserted_building_blocks.jl
+++ /dev/null
@@ -1,64 +0,0 @@
-module InsertedBuildingBlocks
-import Printf: @sprintf
-import JuMP: owner_model, has_values, Model
-import ..GlobalModel: @global_model_constructor
-import ..Variables: Variables, duration, start_time, variables, end_time, get_free_variable
-import ..BuildingBlocks: BuildingBlock, internal_print
-
-"""
-    InsertedBuildingBlock(building_block; start_time=nothing)
-    InsertedBuildingBlock(building_block, index)
-
-Represents a specific insertion of the [`BuildingBlock`](@ref) object within a larger sequence.
-
-If `index` is set an existing [`InsertedBuildingBlock`](@ref) is returned. Otherwise, a new one is created with the given `start_time` as constraint.
-"""
-struct InsertedBuildingBlock{T<:BuildingBlock}
-    bb :: T
-    index :: Int
-    function InsertedBuildingBlock(bb, index)
-        if index < 1 || index > length(bb)
-            error("$index is out of range for $bb")
-        end
-        return new{typeof(bb)}(bb, index)
-    end
-end
-
-owner_model(inserted::InsertedBuildingBlock) = owner_model(inserted.bb)
-has_values(inserted::InsertedBuildingBlock) = has_values(owner_model(inserted))
-
-@global_model_constructor InsertedBuildingBlock
-
-function InsertedBuildingBlock(model::Model, bb::BuildingBlock; start_time=nothing)
-    index = length(bb.start_time) + 1
-    push!(bb.start_time, get_free_variable(model, start_time))
-    InsertedBuildingBlock(bb, index)
-end
-
-
-function Base.show(io::IO, inserted::InsertedBuildingBlock)
-    print(io, string(typeof(block)), "(")
-    if has_values(inserted)
-        if iszero(value(duration(block)))
-            print(io, "time=", @sprintf("%.3f", value(start_time(block))), ", ")
-        else
-            print(
-                io, "time=", 
-                @sprintf("%.3f", value(start_time(block))), "-",
-                @sprintf("%.3f", value(end_time(block))), ", "
-            )
-        end
-    end
-    internal_print(io, inserted.bb)
-    print(io, ")")
-end
-
-for func in variables()
-    if func in (start_time, end_time)
-        continue
-    end
-    @eval Variables.$(nameof(func))(inserted::InsertedBuildingBlock, args...; kwargs...) = Variables.$(nameof(func))(inserted.bb, args...; kwargs...)
-end
-
-
-end
\ No newline at end of file
-- 
GitLab