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

Add AbstractScalarFunction and AbstractVectorFunction #44

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ Abstract supertype for function objects.
"""
abstract type AbstractFunction end

"""
AbstractScalarFunction

Abstract supertype for scalar function objects.
"""
abstract type AbstractScalarFunction end

"""
AbstractVectorFunction

Abstract supertype for vector function objects.
"""
abstract type AbstractVectorFunction end

"""
ScalarVariablewiseFunction(variable)

The function that extracts the scalar variable referenced by `variable`, a `VariableReference`.
This function would naturally be used for single variable bounds or integrality constraints.
"""
struct ScalarVariablewiseFunction <: AbstractFunction
struct ScalarVariablewiseFunction <: AbstractScalarFunction
variable::VariableReference
end

Expand All @@ -23,7 +37,7 @@ end
The function that extracts the vector of variables referenced by `variables`, a `Vector{VariableReference}`.
This function would naturally be used for constraints that apply to groups of variables, such as an "all different" constraint, an indicator constraint, or a complementarity constraint.
"""
struct VectorVariablewiseFunction <: AbstractFunction
struct VectorVariablewiseFunction <: AbstractVectorFunction
variables::Vector{VariableReference}
end

Expand All @@ -36,7 +50,7 @@ The scalar-valued affine function ``a^T x + b``, where:

Duplicate variable references in `variables` are accepted, and the corresponding coefficients are summed together.
"""
struct ScalarAffineFunction{T} <: AbstractFunction
struct ScalarAffineFunction{T} <: AbstractScalarFunction
variables::Vector{VariableReference}
coefficients::Vector{T}
constant::T
Expand All @@ -51,7 +65,7 @@ The vector-valued affine function ``A x + b``, where:

Duplicate indices in the ``A`` are accepted, and the corresponding coefficients are summed together.
"""
struct VectorAffineFunction{T} <: AbstractFunction
struct VectorAffineFunction{T} <: AbstractVectorFunction
outputindex::Vector{Int}
variables::Vector{VariableReference}
coefficients::Vector{T}
Expand All @@ -69,7 +83,7 @@ The scalar-valued quadratic function ``\\frac{1}{2}x^TQx + a^T x + b``, where:
Duplicate indices in ``a`` or ``Q`` are accepted, and the corresponding coefficients are summed together.
"Mirrored" indices `(q,r)` and `(r,q)` (where `r` and `q` are `VariableReferences`) are considered duplicates; only one need be specified.
"""
struct ScalarQuadraticFunction{T} <: AbstractFunction
struct ScalarQuadraticFunction{T} <: AbstractScalarFunction
affine_variables::Vector{VariableReference}
affine_coefficients::Vector{T}
quadratic_rowvariables::Vector{VariableReference}
Expand All @@ -90,7 +104,7 @@ The vector-valued quadratic function with i`th` component ("output index") defin
Duplicate indices in ``a_i`` or ``Q_i`` are accepted, and the corresponding coefficients are summed together.
"Mirrored" indices `(q,r)` and `(r,q)` (where `r` and `q` are `VariableReferences`) are considered duplicates; only one need be specified.
"""
struct VectorQuadraticFunction{T} <: AbstractFunction
struct VectorQuadraticFunction{T} <: AbstractVectorFunction
affine_outputindex::Vector{Int}
affine_variables::Vector{VariableReference}
affine_coefficients::Vector{T}
Expand Down