Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Sep 1, 2017
1 parent 17e4164 commit 839c57c
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 37 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ os:
- linux
- osx
julia:
- 0.5
- nightly
- 0.6
notifications:
email: false
# CSDP needs lapack and blas
Expand All @@ -21,9 +20,9 @@ before_script:
# uncomment the following lines to override the default test script
#script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.clone(pwd()); Pkg.build("SwitchedSystems"); Pkg.test("SwitchedSystems"; coverage=true)'
# - julia -e 'Pkg.clone(pwd()); Pkg.build("SwitchOnSafety"); Pkg.test("SwitchOnSafety"; coverage=true)'
after_success:
# push coverage results to Coveralls
- julia -e 'cd(Pkg.dir("SwitchedSystems")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
- julia -e 'cd(Pkg.dir("SwitchOnSafety")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("SwitchedSystems")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia -e 'cd(Pkg.dir("SwitchOnSafety")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The SwitchedSystems.jl package is licensed under the MIT "Expat" License:
The SwitchOnSafety.jl package is licensed under the MIT "Expat" License:

> Copyright (c) 2016: Benoît Legat.
>
Expand Down
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
# Stability analysis and control synthesis for Switched Systems
# Switch On Safety (SOS) : Computing invariant sets and controlled invariant sets of hybrid systems

[![Build Status](https://travis-ci.org/blegat/SwitchedSystems.jl.svg?branch=master)](https://travis-ci.org/blegat/SwitchedSystems.jl)
[![Build status](https://ci.appveyor.com/api/projects/status/afm00qxhh89f8drm/branch/master?svg=true)](https://ci.appveyor.com/project/blegat/switchedsystems-jl/branch/master)
[![Coverage Status](https://coveralls.io/repos/blegat/SwitchedSystems.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/blegat/SwitchedSystems.jl?branch=master)
[![codecov.io](http://codecov.io/github/blegat/SwitchedSystems.jl/coverage.svg?branch=master)](http://codecov.io/github/blegat/SwitchedSystems.jl?branch=master)
| **Documentation** | **PackageEvaluator** | **Build Status** |
|:-----------------:|:--------------------:|:----------------:|
| [![][docs-stable-img]][docs-stable-url] | [![][pkg-0.5-img]][pkg-0.5-url] | [![Build Status][build-img]][build-url] [![Build Status][winbuild-img]][winbuild-url] |
| [![][docs-latest-img]][docs-latest-url] | [![][pkg-0.6-img]][pkg-0.6-url] | [![Coveralls branch][coveralls-img]][coveralls-url] [![Codecov branch][codecov-img]][codecov-url] |

This packages is in early stage of development but it aims at including tools to analyse the stability and synthesize control of discrete or continuous switched system.
This packages implements methods for computing invariant sets and controlled invariant sets of [hybrid systems](https://github.com/blegat/HybridSystems.jl) using [Sum Of Squares Programming](https://github.com/JuliaOpt/SumOfSquares.jl).
It also includes utilities for approximation the [Joint Spectral Radius](https://link.springer.com/book/10.1007%2F978-3-540-95980-9) / Lyapunov exponent of a system using invariant set computation.

[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg
[docs-latest-img]: https://img.shields.io/badge/docs-latest-blue.svg
[docs-stable-url]: https://blegat.github.io/SwitchOnSafety.jl/stable
[docs-latest-url]: https://blegat.github.io/SwitchOnSafety.jl/latest

[build-img]: https://travis-ci.org/blegat/SwitchOnSafety.jl.svg?branch=master
[build-url]: https://travis-ci.org/blegat/SwitchOnSafety.jl
[winbuild-img]: https://ci.appveyor.com/api/projects/status/afm00qxhh89f8drm/branch/master?svg=true
[winbuild-url]: https://ci.appveyor.com/project/blegat/switchedsystems-jl/branch/master
[coveralls-img]: https://coveralls.io/repos/blegat/SwitchOnSafety.jl/badge.svg?branch=master&service=github
[coveralls-url]: https://coveralls.io/github/blegat/SwitchOnSafety.jl?branch=master
[codecov-img]: http://codecov.io/github/blegat/SwitchOnSafety.jl/coverage.svg?branch=master
[codecov-url]: http://codecov.io/github/blegat/SwitchOnSafety.jl?branch=master
13 changes: 6 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
environment:
matrix:
- JULIAVERSION: "julialang/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe"
- JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"

branches:
only:
Expand All @@ -17,9 +15,10 @@ notifications:
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$("http://s3.amazonaws.com/"+$env:JULIAVERSION),
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
Expand All @@ -28,7 +27,7 @@ build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(\"https://github.com/blegat/MultivariatePolynomials.jl\"); Pkg.clone(\"https://github.com/JuliaOpt/PolyJuMP.jl\"); Pkg.clone(\"https://github.com/JuliaOpt/SumOfSquares.jl\"); Pkg.clone(pwd(), \"SwitchedSystems\"); Pkg.build(\"SwitchedSystems\")"
Pkg.clone(\"https://github.com/blegat/MultivariatePolynomials.jl\"); Pkg.clone(\"https://github.com/JuliaOpt/PolyJuMP.jl\"); Pkg.clone(\"https://github.com/JuliaOpt/SumOfSquares.jl\"); Pkg.clone(pwd(), \"SwitchOnSafety\"); Pkg.build(\"SwitchOnSafety\")"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"SwitchedSystems\")"
- C:\projects\julia\bin\julia -e "Pkg.test(\"SwitchOnSafety\")"
2 changes: 1 addition & 1 deletion src/constrained.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export ConstrainedDiscretePeriodicSwitching, ConstrainedDiscreteSwitchedSystem

mutable struct ConstrainedDiscretePeriodicSwitching <: AbstractPeriodicSwitching
struct ConstrainedDiscretePeriodicSwitching <: AbstractPeriodicSwitching
s::AbstractDiscreteSwitchedSystem # Cannot say DiscreteSwitchedSystem as it would be a circular type declaration https://github.com/JuliaLang/julia/issues/269
period::Vector{Edge}
growthrate::Float64
Expand Down
2 changes: 1 addition & 1 deletion src/continuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export ContinuousSwitchedSystem, ContinuousPeriodicSwitching, getsmp

abstract type AbstractContinuousSwitchedSystem <: AbstractSwitchedSystem end

mutable struct ContinuousPeriodicSwitching <: AbstractPeriodicSwitching
struct ContinuousPeriodicSwitching <: AbstractPeriodicSwitching
s::AbstractContinuousSwitchedSystem
period::Vector{Tuple{Int, Float64}}
growthrate::Float64
Expand Down
2 changes: 1 addition & 1 deletion src/discrete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export DiscreteSwitchedSystem, DiscretePeriodicSwitching, getsmp

abstract type AbstractDiscreteSwitchedSystem <: AbstractSwitchedSystem end

mutable struct DiscretePeriodicSwitching <: AbstractPeriodicSwitching
struct DiscretePeriodicSwitching <: AbstractPeriodicSwitching
s::AbstractDiscreteSwitchedSystem # Cannot say DiscreteSwitchedSystem as it would be a circular type declaration https://github.com/JuliaLang/julia/issues/269
period::Vector{Int}
growthrate::Float64
Expand Down
2 changes: 1 addition & 1 deletion src/switchings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function dynamicfor(s::AbstractDiscreteSwitchedSystem, sw::AbstractDiscreteSwitc
sw.A
end

mutable struct SwitchingIterator
struct SwitchingIterator
s::AbstractDiscreteSwitchedSystem
k::Int
v0::Int
Expand Down
26 changes: 13 additions & 13 deletions test/AJPR14e54.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
@testset "[AJPR14] Example 5.4" begin
s = DiscreteSwitchedSystem([[-1 -1; -4 0],[3 3; -2 1]])
qub = 4.31959610746
@test_approx_eq(quicklb(s), 3)
@test_approx_eq(quickub(s), qub)
@test quicklb(s) 3
@test quickub(s) qub
qb = quickb(s)
@test typeof(qb) == NTuple{2,Float64}
@test_approx_eq(qb[1], 3)
@test_approx_eq(qb[2], qub)
@test qb[1] 3
@test qb[2] qub
# pnorm=Inf: [17.2409,7.42377,5.65853,4.92192,4.52597,4.28099,4.11275,3.99139,3.8991,3.827,3.76891,3.72121,3.6813,3.64744,3.61834,3.59307,3.57092,3.55135,3.53393,3.51832,3.50426,3.49152,3.47994]
# pnorm=1: [15.1245,7.35044,5.47402,4.84722,4.45847,4.23242,4.0709,3.95644,3.8687,3.80015,3.74485,3.69944,3.66141,3.62914,3.6014,3.5773,3.55616,3.53748,3.52085,3.50595,3.49253,3.48037,3.4693,3.45919]
# pnorm=2: [14.1535,6.81871,5.32651,4.7096,4.37067,4.15723,4.01117,3.90488,3.82407,3.7606,3.70945,3.66735,3.6321,3.60215,3.57639,3.554,3.53437,3.517,3.50154,3.48768,3.47519]
@test_throws ArgumentError pradius(s, 1)
@test_throws MethodError pradius(s, 2, :MagicAlgo)
@test_approx_eq_eps(pradius(s, 2), 3.234535151244, 1e-9)
@test_approx_eq(pradius(s, 2, :BruteForce, pnorm=2), 3.632097274822649)
@test pradius(s, 2) 3.234535151244 rtol=1e-9
@test pradius(s, 2, :BruteForce, pnorm=2) 3.632097274822649

pρlb = [3.23453515151244, 3.4275601560595668, 3.543749287036915]
pρub = [4.574323478862314, 4.0760789246858735, 3.977724083422336]
Expand All @@ -37,11 +37,11 @@
tol = ismosek(solver) ? 1e-5 : 5e-4
println(" > With solver $(typeof(solver))")
lb, ub = soslyapb(s, 1, solver=solver, tol=tol)
@test isapprox(log(lb), log(2.814640557), rtol=tol)
@test isapprox(log(ub), log(3.980502849), rtol=tol)
@test log(lb) log(2.814640557) rtol=tol
@test log(ub) log(3.980502849) rtol=tol
lb, ub = soslyapb(s, 2, solver=solver, tol=tol)
@test isapprox(log(lb), log(3.299750624), rtol=tol)
@test isapprox(log(ub), log(3.924086919), rtol=tol)
@test log(lb) log(3.299750624) rtol=tol
@test log(ub) log(3.924086919) rtol=tol
seq = sosbuildsequence(s, 1, p_0=:Primal)
psw = findsmp(seq)
@test !isnull(psw)
Expand All @@ -52,10 +52,10 @@
@test get(psw) == smp
end
if isempty(sdp_solvers)
@test isapprox(s.ub, 4.0760789246858735)
@test s.ub 4.0760789246858735
else
@test isapprox(log(s.ub), log(3.924086919), rtol=5e-4)
@test log(s.ub) log(3.924086919) rtol=5e-4
@test getsmp(s) == smp
@test isapprox(s.lb, 3.917384715148, rtol=1e-12)
@test s.lb 3.917384715148 rtol=1e-12
end
end
2 changes: 1 addition & 1 deletion test/PJ08e54.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
iscsdp(solver) && continue
println(" > With solver $(typeof(solver))")
for d in 1:3
tol = ismosek(solver) ? (d <= 2 ? 4e-4 : 3e-2) : 1e-3
tol = ismosek(solver) ? (d <= 2 ? 4e-4 : 4e-2) : 1e-3
lb, ub = soslyapb(s, d, solver=solver, tol=tol)
@test abs(log(expected_lb[d]) - log(lb)) <= tol
@test abs(log(expected_ub[d]) - log(ub)) <= tol
Expand Down

0 comments on commit 839c57c

Please sign in to comment.