Skip to content

Commit c1cdd65

Browse files
committed
up?
1 parent 689f00a commit c1cdd65

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/functions/rcsTools.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ xsign(u) = u < 0.0 ? -1.0 : 1.0
268268
# function rcsAllocationSimplex(u, My, c=ones(size(My, 2)); maxIter=30)
269269
function rcsAllocationSimplex(u, My; maxIter=30)
270270
m, n = size(My) # m = number of dof, n = number of thrusters
271-
if all(u .== 0.0); return zeros(n); end
271+
if iszero(u); return zeros(n); end
272272

273273
# # Variable change to have ylb = 0
274274
# off = false;
@@ -286,6 +286,7 @@ function rcsAllocationSimplex(u, My; maxIter=30)
286286
E = -diagm(xsign.(u))*My # [m x n]
287287
# ∇z = c + E'*cs # [OLD with c] [n x 1] Cost change when bringing in the base a thruster which is out of the basis (i.e., increasing Yn[i])
288288
∇z = 1.0 .+ E'*cs # [n x 1] Cost change when bringing in the base a thruster which is out of the basis (i.e., increasing Yn[i])
289+
e = zeros(m)
289290

290291
iBase = Integer.(n+1:n+m) # [m x 1] Global indices (i.e., within the vector Y) of thrusters in the basis. Initial solution is y = s
291292
Yn = zeros(n + m) # [n+m x 1] Thrusters out of the basis, either at zero (Yn[i] = 0) or at max (Yn[i] = Ymax[i])
@@ -305,9 +306,11 @@ function rcsAllocationSimplex(u, My; maxIter=30)
305306
# Determine the candidate base thrusters to leave the basis
306307
# This corresponds to the basis thruster that first reaches 0 or its upper bound when
307308
# we vary the candidate non-base thruster. (smallest shut-off and smallest upper bnd index)
308-
e = E[:, iIn] # Local vector indicating the rate of change of the base thrusters due to the value of the invited thruster
309-
r = Inf # Smallest base variable variation ratio before reaching bounds
310-
jOut = 0 # Local (i.e., within basis) index of the first base variable to reach bounds
309+
@inbounds for j in eachindex(e)
310+
e[j] = E[j, iIn] # Local vector indicating the rate of change of the base thrusters due to the value of the invited thruster
311+
end
312+
r = Inf # Smallest base variable variation ratio before reaching bounds
313+
jOut = 0 # Local (i.e., within basis) index of the first base variable to reach bounds
311314

312315
@inbounds for j in 1:m
313316
rj = r

0 commit comments

Comments
 (0)