Skip to content

Commit ab566c5

Browse files
authored
Format .jl files
1 parent 83c5e35 commit ab566c5

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

docs/src/guide.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,17 @@ constraint(
6060
c,
6161
3x[i+1]^3 + 2 * x[i+2] - 5 + sin(x[i+1] - x[i+2])sin(x[i+1] + x[i+2]) + 4x[i+1] -
6262
x[i]exp(x[i] - x[i+1]) - 3 for i = 1:(N-2);
63-
lcon = -1.0, ucon = 1.0
63+
lcon = -1.0,
64+
ucon = 1.0,
6465
)
6566

6667
# If you want to create a single-bounded constraint, you can set `lcon` to `-Inf` or `ucon` to `Inf`. For example, if we wanted to set the lower bound of the constraint to -1 and the upper bound to infinity, we could do it as follows:
6768
constraint(
6869
c,
6970
3x[i+1]^3 + 2 * x[i+2] - 5 + sin(x[i+1] - x[i+2])sin(x[i+1] + x[i+2]) + 4x[i+1] -
7071
x[i]exp(x[i] - x[i+1]) - 3 for i = 1:(N-2);
71-
lcon = -1.0, ucon = Inf
72+
lcon = -1.0,
73+
ucon = Inf,
7274
)
7375

7476
# ## ExaModel

ext/ExaModelsMOI.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,7 @@ function exafy_con(
314314
func = MOI.get(moim, MOI.ConstraintFunction(), ci)
315315
set = MOI.get(moim, MOI.ConstraintSet(), ci)
316316
con_to_idx[ci] = offset + i
317-
start = if MOI.supports(
318-
moim, MOI.ConstraintPrimalStart(), typeof(ci)
319-
)
317+
start = if MOI.supports(moim, MOI.ConstraintPrimalStart(), typeof(ci))
320318
MOI.get(moim, MOI.ConstraintPrimalStart(), ci)
321319
else
322320
nothing
@@ -457,10 +455,12 @@ function _exafy(i::R, var_to_idx, p) where {R<:Real}
457455
end
458456

459457
function _exafy(e::MOI.ScalarNonlinearFunction, var_to_idx, p = ())
460-
return op(e.head)((begin
461-
c, p = _exafy(e, var_to_idx, p)
462-
c
463-
end for e in e.args)...), p
458+
return op(e.head)((
459+
begin
460+
c, p = _exafy(e, var_to_idx, p)
461+
c
462+
end for e in e.args
463+
)...), p
464464
end
465465

466466
function _exafy(e::MOI.ScalarAffineFunction{T}, var_to_idx, p = ()) where {T}

src/graph.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,13 @@ end
115115

116116
@inline Base.getproperty(n::ParSource, s::Symbol) = ParIndexed(n, s)
117117
@inline Base.getindex(n::ParSource, i) = ParIndexed(n, i)
118-
@inline Base.indexed_iterate(n::P, idx, start = 1) where P <: Union{ParSource, ParIndexed} = (ParIndexed(n, idx), idx + 1)
118+
@inline Base.indexed_iterate(n::P, idx, start = 1) where {P<:Union{ParSource,ParIndexed}} =
119+
(ParIndexed(n, idx), idx + 1)
119120

120-
@inline Base.getproperty(v::ParIndexed{I, n}, s::Symbol) where {I, n} = ParIndexed(v, s)
121-
@inline Base.getindex(v::ParIndexed{I, n}, i) where {I, n} = ParIndexed(v, i)
122-
@inline Base.indexed_iterate(v::ParIndexed{I, n}, idx, start = 1) where {I, n} = (ParIndexed(v, idx), idx + 1)
121+
@inline Base.getproperty(v::ParIndexed{I,n}, s::Symbol) where {I,n} = ParIndexed(v, s)
122+
@inline Base.getindex(v::ParIndexed{I,n}, i) where {I,n} = ParIndexed(v, i)
123+
@inline Base.indexed_iterate(v::ParIndexed{I,n}, idx, start = 1) where {I,n} =
124+
(ParIndexed(v, idx), idx + 1)
123125

124126

125127
@inline Base.getindex(n::VarSource, i) = Var(i)
@@ -144,7 +146,8 @@ struct Identity end
144146
@inline (v::ParameterNode{I})(::Identity, x, ::Nothing) where {I<:AbstractNode} = NaN
145147

146148
@inline (v::ParSource)(i, x, θ) = i
147-
@inline (v::ParIndexed{I,n})(i, x, θ) where {I,n} = @inbounds getfield(getfield(v, :inner)(i, x, θ), n)
149+
@inline (v::ParIndexed{I,n})(i, x, θ) where {I,n} =
150+
@inbounds getfield(getfield(v, :inner)(i, x, θ), n)
148151

149152
(v::ParIndexed)(i::Identity, x, θ) = NaN # despecialized
150153
(v::ParSource)(i::Identity, x, θ) = NaN # despecialized

src/simdfunction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct SIMDFunction{F,C1,C2}
2525
end
2626

2727
@inline (sf::SIMDFunction{F,C1,C2})(i, x, θ) where {F,C1,C2} = sf.f(i, x, θ)
28-
@inline (sf::SIMDFunction{F,C1,C2})(i, x, θ) where {F <: Real,C1,C2} = sf.f
28+
@inline (sf::SIMDFunction{F,C1,C2})(i, x, θ) where {F<:Real,C1,C2} = sf.f
2929

3030
"""
3131
SIMDFunction(gen::Base.Generator, o0 = 0, o1 = 0, o2 = 0)

test/NLPTest/luksan_struct.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
struct I2
2-
i::Tuple{Int, Int}
2+
i::Tuple{Int,Int}
33
end
44

55
struct I1
@@ -9,10 +9,15 @@ end
99
function _exa_luksan_struct_model(backend, N; M = 1)
1010

1111
c = ExaCore(backend = backend)
12-
data = [I1(I2((i,j))) for i = 1:N, j = 1:M]
12+
data = [I1(I2((i, j))) for i = 1:N, j = 1:M]
1313
x = variable(c, N, M; start = [luksan_vlcek_x0(i.i.i[1]) for i in data])
14-
s = constraint(c, luksan_vlcek_con1(x, i.i.i[1], i.i.i[2]) for i in data[1:end-2,:])
15-
constraint!(c, s, (i.i.i[1], i.i.i[2]) => luksan_vlcek_con2(x, i.i.i[1], i.i.i[2]) for i in data[1:end-2,:])
14+
s = constraint(c, luksan_vlcek_con1(x, i.i.i[1], i.i.i[2]) for i in data[1:(end-2), :])
15+
constraint!(
16+
c,
17+
s,
18+
(i.i.i[1], i.i.i[2]) => luksan_vlcek_con2(x, i.i.i[1], i.i.i[2]) for
19+
i in data[1:(end-2), :]
20+
)
1621
objective(c, luksan_vlcek_obj(x, i, j) for i = 2:N, j = 1:M)
1722

1823
return ExaModel(c; prod = true), (x,), (s,)

0 commit comments

Comments
 (0)