Skip to content

Commit a7d43b4

Browse files
committed
[UPD] Change name of function argsup_proba_risk to risk_proba
1 parent c9bae21 commit a7d43b4

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

examples/risk-example.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ end
6262
s_bounds = [(0, 1)] # bounds on the state
6363
u_bounds = [(CONTROL_MIN, CONTROL_MAX)] # bounds on controls
6464

65-
println("Initialzing functions to compare execution time")
65+
println("Initializing functions to compare execution time")
6666
spmodel = LinearSPModel(N_STAGES,u_bounds,[S0],cost_t,dynamic,xi_laws, riskMeasure = Expectation())
6767
set_state_bounds(spmodel, s_bounds) # adding the bounds to the model
6868
# 10 forward pass, stop at MAX_ITER

src/StochDynamicProgramming.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export solve_SDDP,
2525
StochDynProgModel, SDPparameters, solve_dp,
2626
sampling, get_control, get_bellman_value,
2727
benchmark_parameters, SDDPInterface,
28-
argsup_proba_risk,
28+
risk_proba,
2929
RiskMeasure, AVaR, Expectation, WorstCase, ConvexCombi, PolyhedralRisk
3030

3131
include("noises.jl")

src/forwardBackwardIterations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ function compute_cuts_hd!(model::SPModel, param::SDDPparameters,
345345
proba /= sum(proba)
346346

347347
#Modify the probability vector to compute the value of the risk measure
348-
proba = argsup_proba_risk(proba,model.riskMeasure,costs)
348+
proba = risk_proba(proba,model.riskMeasure,costs)
349349

350350
# Compute expectation of subgradient λ:
351351
subgradient = vec(sum(proba' .* subgradient_array, 2))

src/risk.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ allowing to compute the risk
3333
a new probability distribution taking risk into account.
3434
3535
"""
36-
function argsup_proba_risk(prob, riskMeasure::RiskMeasure,costs)
37-
error("'argsup_proba_risk' not defined for $(typedof(s))")
36+
function risk_proba(prob, riskMeasure::RiskMeasure,costs)
37+
error("'risk_proba' not defined for $(typedof(s))")
3838
end
3939

4040
"""
4141
$(TYPEDEF)
4242
4343
Return the probability distribution to compute a Average Value at Risk of level beta.
4444
"""
45-
function argsup_proba_risk(prob,riskMeasure::AVaR,costs)
45+
function risk_proba(prob,riskMeasure::AVaR,costs)
4646
perm = sortperm(costs,rev = true)
4747
beta = riskMeasure.beta
4848
proba = zeros(length(prob))
@@ -69,7 +69,7 @@ $(TYPEDEF)
6969
7070
Leave the probability distribution unchanged to compute the expectation.
7171
"""
72-
function argsup_proba_risk(prob,riskMeasure::Expectation,costs)
72+
function risk_proba(prob,riskMeasure::Expectation,costs)
7373
return prob
7474
end
7575

@@ -78,7 +78,7 @@ $(TYPEDEF)
7878
perm
7979
Return a dirac on the worst cost as a probability distribution.
8080
"""
81-
function argsup_proba_risk(prob,riskMeasure::WorstCase,costs)
81+
function risk_proba(prob,riskMeasure::WorstCase,costs)
8282
proba = zeros(length(prob))
8383
proba[indmax(costs)] = 1
8484
return proba
@@ -90,7 +90,7 @@ $(TYPEDEF)
9090
Return the probability distribution to compute a convex combination
9191
between expactation and an Average Value at Risk of level beta.
9292
"""
93-
function argsup_proba_risk(prob,riskMeasure::ConvexCombi,costs)
93+
function risk_proba(prob,riskMeasure::ConvexCombi,costs)
9494
perm = sortperm(costs,rev = true)
9595
beta = riskMeasure.beta
9696
lambda = riskMeasure.lambda
@@ -119,7 +119,7 @@ $(TYPEDEF)
119119
Return the worst extreme probability distribution
120120
defining the convex set P
121121
"""
122-
function argsup_proba_risk(prob,riskMeasure::PolyhedralRisk,costs)
122+
function risk_proba(prob,riskMeasure::PolyhedralRisk,costs)
123123
P = riskMeasure.polyset
124124
valuesup = P*costs
125125
return P[indmax(valuesup),:]

test/changeprob.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@ end
2727
@testset "Equality WorstCase AVaR(0)" begin
2828
n = 100
2929
prob = 1/n*ones(n)
30-
@test sum(abs.(argsup_proba_risk(prob,AVaR(0),1:n)-argsup_proba_risk(prob,WorstCase(),1:n)) .<= EPSILON*ones(n)) == n
30+
@test sum(abs.(risk_proba(prob,AVaR(0),1:n)-risk_proba(prob,WorstCase(),1:n)) .<= EPSILON*ones(n)) == n
3131
end
3232

3333
@testset "Equality Expectation AVaR(1)" begin
3434
n = 100
3535
prob = 1/n*ones(n)
36-
@test sum(abs.(argsup_proba_risk(prob,AVaR(1),1:n)-argsup_proba_risk(prob,Expectation(),1:n)) .<= EPSILON*ones(n)) == n
36+
@test sum(abs.(risk_proba(prob,AVaR(1),1:n)-risk_proba(prob,Expectation(),1:n)) .<= EPSILON*ones(n)) == n
3737
end
3838

3939
@testset "Equality Expectation ConvexCombi(beta,1)" begin
4040
n = 100
4141
prob = 1/n*ones(n)
42-
@test sum(abs.(argsup_proba_risk(prob,Expectation(),1:n)-argsup_proba_risk(prob,ConvexCombi(rand(),1),1:n)) .<= EPSILON*ones(n)) == n
42+
@test sum(abs.(risk_proba(prob,Expectation(),1:n)-risk_proba(prob,ConvexCombi(rand(),1),1:n)) .<= EPSILON*ones(n)) == n
4343
end
4444

4545
@testset "Equality AVaR(beta) ConvexCombi(beta,0)" begin
4646
n = 100
4747
beta = rand()
4848
prob = 1/n*ones(n)
49-
@test sum(abs.(argsup_proba_risk(prob,AVaR(beta),1:n)-argsup_proba_risk(prob,ConvexCombi(beta,0),1:n)) .<= EPSILON*ones(n)) == n
49+
@test sum(abs.(risk_proba(prob,AVaR(beta),1:n)-risk_proba(prob,ConvexCombi(beta,0),1:n)) .<= EPSILON*ones(n)) == n
5050
end
5151

5252
# Check that in the case of minimization, AVaR find the worst costs
@@ -55,7 +55,7 @@ end
5555
betamin = rand()/2+0.5
5656
n = 100
5757
prob = 1/n*ones(n)
58-
@test argsup_proba_risk(prob, AVaR(betamin), 1:n)'*(n:-1:1) - argsup_proba_risk(prob, AVaR(betamax), 1:n)'*(n:-1:1) >= 0
58+
@test risk_proba(prob, AVaR(betamin), 1:n)'*(n:-1:1) - risk_proba(prob, AVaR(betamax), 1:n)'*(n:-1:1) >= 0
5959
end
6060
end
6161

@@ -78,7 +78,7 @@ end
7878

7979
status = solve(m)
8080

81-
probaAVaR = argsup_proba_risk(prob, AVaR(beta), X)
81+
probaAVaR = risk_proba(prob, AVaR(beta), X)
8282

8383
@test abs(probaAVaR'*X - getobjectivevalue(m)) <= EPSILON
8484
end
@@ -97,8 +97,8 @@ end
9797
polyset[i,i] = (beta*n-n+1)/(n*beta)
9898
end
9999

100-
probaAVaR = argsup_proba_risk(prob, AVaR(beta), X)
101-
probaPolyhedral = argsup_proba_risk(prob, PolyhedralRisk(polyset), X)
100+
probaAVaR = risk_proba(prob, AVaR(beta), X)
101+
probaPolyhedral = risk_proba(prob, PolyhedralRisk(polyset), X)
102102

103103
@test sum(abs.(probaAVaR-probaPolyhedral) .<= EPSILON*ones(n)) == n
104104
end

0 commit comments

Comments
 (0)