Giter VIP home page Giter VIP logo

Comments (9)

schillic avatar schillic commented on June 14, 2024 1

If you do not need to rely on the concrete type, you can keep the eltype of A parametric.

struct IntervalParametricArray{T, MT<:AbstractVecOrMat}
    A::MT
    params::Vector{Interval{T}}
end

But I agree to go for Option 1 because it can always be changed later. A short note in the documentation that this is work in progress and the interface may change would be good, though.

from intervallinearalgebra.jl.

lucaferranti avatar lucaferranti commented on June 14, 2024

even when going with alternative 1, there could still be a constructor to construct the matrix from the symbolic expression

from intervallinearalgebra.jl.

lucaferranti avatar lucaferranti commented on June 14, 2024

Looking at skalna2006 paper, an alternative structure could be

Alternative 3

struct IntervalParametricArray where {T}
  ฮฉ::Matrix{Vector{T}}
  params::Vector{Interval{T}}
end

so that A(i, j) = ฮฉ(i, j)แต€p (p being the vector of symbolic parameters).

that's basically the same of alternative 1, except that instead of having a vector of matrices you have a matrix of vectors.

Maybe not the most optimal solution, but would be at least straightforward to implement with DynamicPolynomials

julia> @polyvar x y z
(x, y, z)

julia> A = [x+2y+z+1 2x+z+2;y/2 z+x+y+1]
2ร—2 Matrix{Polynomial{true, Float64}}:
 x + 2.0y + z + 1.0  2.0x + z + 2.0
 0.5y                x + y + z + 1.0

julia> map(a -> coefficients(a, [x, y, z, 1]), A)
2ร—2 Matrix{Vector{Float64}}:
 [1.0, 2.0, 1.0, 1.0]  [2.0, 0.0, 1.0, 2.0]
 [0.0, 0.5, 0.0, 0.0]  [1.0, 1.0, 1.0, 1.0]

from intervallinearalgebra.jl.

lucaferranti avatar lucaferranti commented on June 14, 2024

With a quick googling, it seems Symbolics.jl doesn't have (yet) the needed functionalities (extract coefficients wrt given variable, check if expression is linear etc). Alternatives could be

  1. use DynamicPolynomials (maybe an overkill)
  2. if for the moment we restrict to linear expressions, could just create a simple type LinearExpression with addition and subtraction overloaded.

good to notice that the interfaces are just for human-readable output/-writable input, at least for the algorithm in Skalna06 symbolic manipulation is not needed

from intervallinearalgebra.jl.

mforets avatar mforets commented on June 14, 2024

If possible let's use the AbstractIntervalMatrix interface (conceptually, a parametric interval matrix resp system is a special case of a general interval matrix, resp system). Moreover, I would rather leave the params vector type generic (algebraic ops and using eg. using statically sized arrays is a reasonable thing to do).

These observations lead to:

import IntervalMatrices: AbstractIntervalMatrix

struct ParametricIntervalMatrix{N, MN<: AbstractMatrix{N}, VMN<:AbstractVector{MN}, T, IT, VI<: AbstractVector{IT}} <: AbstractIntervalMatrix{IT}
  coeffs::VMN
  params::VI
end

We may decide that the "A0" matrix is another field, or that the length of coeffs is 1 plus the length of params and checked in a constructor.

from intervallinearalgebra.jl.

mforets avatar mforets commented on June 14, 2024

good to notice that the interfaces are just for human-readable output/-writable input, at least for the algorithm in Skalna06 symbolic manipulation is not needed

Indeed, the discussion of using symbolic expressions to initialize such objects is nice but also somehow orthogonal, so we may split it to another issue.

it seems Symbolics.jl doesn't have (yet) the needed functionalities (extract coefficients wrt given variable, check if expression is linear etc)

But it shouldn't be hard to do, at least naively (now that I think about it, there is some code in LazySets to parse hyperplanes and half-spaces, both linear expressions).

The long-term benefits of using an established and active project such as Symbolics.jl (or MultivariatePolynomials, or both) exceed the short-term benefits of cooking custom symbolic structs as in #104 -- which I find it is a fantastic demo!

from intervallinearalgebra.jl.

lucaferranti avatar lucaferranti commented on June 14, 2024

Yes parametrizing on the constructor type would indeed be good, I was just lazy when writing the comment ๐Ÿ˜„

Now that I think a little better about it, maybe it makes sense to keep the list of parameters separated from the matrix and make ParametricMatrix callable, that is

struct ParametricMatrix{T, VT<:AbstractVector{T}, MT<:AbstractMatrix{VT}} <: AbstractMatrix{VT}
  coeffs::MT
end

# define array interface here, getindex, setindex, size etc

function (A::ParametricIntervalMatrix)(p::AbstractVector)
   return [dot(a[1:end-1], p) + a[end] for a in A]
end

or something like that, so that one could simply do

A = ParametricMatrix([1+p1 p2;p2 p1-1])
p1 = [1..2, 3..4]
p2 = [1, 2]
Ap = A(p)
Amid = A(p1)

This would make it easier to use the matrix over different parameters domains or getting an instance of the system at a specific parameter value.

from intervallinearalgebra.jl.

mforets avatar mforets commented on June 14, 2024

ok ๐Ÿ‘ something like that but also allowing to store the coeffs in a struct seems like a nice approach.

i mean, after it's been created, it has non-zero cost to "extract" the coeffs from Ap, even though it'll possibly be required to use the params p separately from the coeffs matrix in downstream computations.

from intervallinearalgebra.jl.

mforets avatar mforets commented on June 14, 2024

i mean the "callable" approach also works with the definition in #100 (comment). and provided that the container type VI is mutable, one can always update such coeffs after creation:

@variables p1 p2

A = ParametricIntervalMatrix([1+p1 p2;p2 p1-1]) # params field is initialized with interval(1)
p = [1..2, 3..4]

Ap = A(p) # instance with old A and new p

setparams!(A, p) # in-place update of A's params field 

In this way, ParametricIntervalMatrix works like a "template".

from intervallinearalgebra.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.