Skip to content

Commit

Permalink
0.7 Deprecations fix
Browse files Browse the repository at this point in the history
  • Loading branch information
v-i-s-h committed Jul 20, 2018
1 parent a7e5107 commit ee421a7
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 21 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -5,7 +5,6 @@ os:
- osx
julia:
# - release
- 0.7.0-beta2
- nightly
notifications:
email: false
Expand Down
3 changes: 1 addition & 2 deletions src/Agents/AgentBase.jl
Expand Up @@ -30,7 +30,6 @@ Prints information about agent into the specified I/O.
```julia-repl
```
"""
# import Base.show
function Base.show( io::IO, ::MIME"text/plain", agent::AgentBase )
print( io, @sprintf("Agent: %s",info_str(agent)) )
for param in fieldnames(agent)
Expand Down Expand Up @@ -77,7 +76,7 @@ function ==( agent1::AgentBase, agent2::AgentBase )
if typeof(agent1) != typeof(agent2)
return false
else
for param in fieldnames(agent1)
for param in fieldnames(typeof(agent1))
if getfield(agent1,param) != getfield(agent2,param)
# info( "Failed at ", param )
return false
Expand Down
6 changes: 2 additions & 4 deletions src/Agents/EpsilonGreedy.jl
Expand Up @@ -3,8 +3,7 @@
Implements constant exploration ϵ-greedy agent. `noOfArms` is the number
of arms to pick from and `ϵ` is the exploration factor.
"""

type epsGreedy <: StationaryAgentBase
mutable struct epsGreedy <: StationaryAgentBase
noOfArms::Int64
noOfSteps::Int64
lastPlayedArm::Int64
Expand Down Expand Up @@ -73,8 +72,7 @@ of options, `c` and `d` are algorithm dependent parameters.
Reference: Auer, P., Bianchi, N. C., & Fischer, P. (2002). Finite time analysis of the multiarmed bandit problem. Machine Learning, 47, 235–256.
"""

type epsNGreedy <: StationaryAgentBase
mutable struct epsNGreedy <: StationaryAgentBase
noOfArms::Int64
noOfSteps::Int64
lastPlayedArm::Int64
Expand Down
1 change: 0 additions & 1 deletion src/Agents/StationaryAgentBase.jl
Expand Up @@ -6,7 +6,6 @@
arms. Even though it is not enforced, the assumption is the reward updated to
stationary agents are from a stationary arm model.
"""

abstract type StationaryAgentBase <: AgentBase end

"""
Expand Down
10 changes: 5 additions & 5 deletions src/Arms/NonStationaryArms.jl
Expand Up @@ -16,7 +16,7 @@ should switch from 0 to 1 from the start of period. `holdDuration` (Int) is the
for which the pulse should stay 1. `isRestless` (bool) sets whether the arm is
restless or not.
"""
type Pulse <: NonstationaryArmBase
mutable struct Pulse <: NonstationaryArmBase
step::Int # For tracking internally
period::Int # Period of the pulse
changePoint::Int # The point at which the signal goes high
Expand All @@ -40,7 +40,7 @@ function pull!( arm::Pulse )
arm.step = 1
end

return ((arm.step>=arm.changePoint)&&(arm.step<=arm.changePoint+arm.highDuration))?1:0;
return ((arm.step>=arm.changePoint)&&(arm.step<=arm.changePoint+arm.highDuration)) ? 1 : 0;
end

function tick!( arm::Pulse )
Expand All @@ -65,7 +65,7 @@ end
`period`. `isRestless` (bool) sets whether the arm is restless or not. `offset`
sets the offset for the arm (set to a random offset by default).
"""
type Sinusoidal <: NonstationaryArmBase
mutable struct Sinusoidal <: NonstationaryArmBase
step::Int # Time step
period::Int # Period of the sinusoidal wave
isRestless::Bool # Is this arm restless - True by default
Expand Down Expand Up @@ -108,7 +108,7 @@ a default value of `0` and changes to values as per the dictionary of changePoin
arm1 = Arms.Square( 50, Dict(10=>0.5,25=>0.20,40=>1.0) )
```
"""
type Square <: NonstationaryArmBase
mutable struct Square <: NonstationaryArmBase
step::Int # For internal tracking
period::Int # Period at which wave repeats
changePoints::Dict{Int,Float64} # Dictionary of change points
Expand Down Expand Up @@ -163,7 +163,7 @@ end
`Variational` creates a nonstationary arm as mentioned in
Besbes, O., Gur, Y., & Zeevi, A. (2014). Optimal Exploration-Exploitation in a Multi-Armed-Bandit Problem with Non-stationary Rewards, 1–20.
"""
type Variational <: NonstationaryArmBase
mutable struct Variational <: NonstationaryArmBase
step::Int64 # Time step
variation::Float64 # Variation of the arms
period::Float64 # Period of the sinusoidal wave
Expand Down
10 changes: 4 additions & 6 deletions src/Arms/StationaryArms.jl
Expand Up @@ -18,7 +18,7 @@ mean( arm::StationaryArmBase ) = Distributions.mean( arm.armDist )
Bernoulli( p )
`Bernoulli` creates a Bernoulli arm with success probability `p`.
"""
type Bernoulli <: StationaryArmBase
mutable struct Bernoulli <: StationaryArmBase
armDist::Distributions.Bernoulli

function Bernoulli( p::Real )
Expand All @@ -36,8 +36,7 @@ end
`Beta` creates a Beta arm with parameters `α` and `β`.
"""

type Beta <: StationaryArmBase
mutable struct Beta <: StationaryArmBase
armDist::Distributions.Beta

function Beta( α::Real, β::Real )
Expand All @@ -55,8 +54,7 @@ end
`Expoenential` creates a Expoenentially distributed arm with mean reward `θ`
"""

type Exponential <: StationaryArmBase
mutable struct Exponential <: StationaryArmBase
armDist::Distributions.Exponential

function Exponential( λ::Real ) # λ is the mean parameter
Expand All @@ -75,7 +73,7 @@ end
Creates an arm with reward distributed as Normal random varaible with mean `μ`
and standard deviation `σ`.
"""
type Normal <: StationaryArmBase
mutable struct Normal <: StationaryArmBase
armDist::Distributions.Normal

function Normal( μ::Real, σ::Real )
Expand Down
1 change: 1 addition & 0 deletions src/BanditOpt.jl
Expand Up @@ -14,6 +14,7 @@ of agents and the common interface.
module Agents
using Distributions
using LaTeXStrings
using Printf
include( "Agents/AgentBase.jl" )
include( "Agents/StationaryAgentBase.jl" )

Expand Down
1 change: 1 addition & 0 deletions test/Arms/StationaryArms.jl
@@ -1,4 +1,5 @@
# Tests for Stationary Arm Model
using InteractiveUtils

@testset "Stationary Arm Models" begin

Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
@@ -1,5 +1,5 @@
using BanditOpt
using Base.Test
using Test

macro test_nothrow(ex)
quote
Expand Down Expand Up @@ -38,7 +38,7 @@ if length(ARGS) > 0
tests = ARGS
end

@testset "Bandit Tests" begin
@testset "BanditOpt Tests" begin
for test_script in tests
fp = joinpath( dirname(@__FILE__), "$(test_script).jl" )
# println( "Testing : ", test_script )
Expand Down

0 comments on commit ee421a7

Please sign in to comment.