@@ -306,13 +306,11 @@ function rcsAllocationSimplex(u, My; maxIter=30)
306306 # Determine the candidate base thrusters to leave the basis
307307 # This corresponds to the basis thruster that first reaches 0 or its upper bound when
308308 # we vary the candidate non-base thruster. (smallest shut-off and smallest upper bnd index)
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
312309 r = Inf # Smallest base variable variation ratio before reaching bounds
313310 jOut = 0 # Local (i.e., within basis) index of the first base variable to reach bounds
314311
315312 @inbounds for j in 1 : m
313+ e[j] = E[j, iIn] # Local vector indicating the rate of change of the base thrusters due to the value of the invited thruster
316314 rj = r
317315 if e[j] < 0 # A change in the non-base thrust will cause the base thrust to reduce its thrust level
318316 # CASE 2a: The thruster in the basis will reduce its value and go to zero,
@@ -340,12 +338,15 @@ function rcsAllocationSimplex(u, My; maxIter=30)
340338 # non-base variable does. The non-base variable stays out of the basis but it
341339 # goes either to 0 or to its upper bound. The basis is not modified.
342340 Yn[iIn] = Ymax[iIn] - Yn[iIn] # Update the non-basis vector list. With this operation, if Yn is 0 then it goes to Ymax, if Yn = Ymax then it goes to 0
343- yb .+ = Ymax[iIn]* e # Update the on times for the jets in the basis (substract the effects of having an out of basis thruster at its upper bound)
344341
345- # Switching polarity to indicate that now thruster ratio y must be decreased (or
346- # increased) rather than increased (or decreased) when trying to decrease cost
347- # in next iterations
348- E[:, iIn] = - E[:, iIn]
342+ @inbounds for k in 1 : m
343+ yb[k] += Ymax[iIn]* e[k] # Update the on times for the jets in the basis (substract the effects of having an out of basis thruster at its upper bound)
344+
345+ # Switching polarity to indicate that now thruster ratio y must be decreased (or
346+ # increased) rather than increased (or decreased) when trying to decrease cost
347+ # in next iterations
348+ E[k, iIn] = - E[k, iIn]
349+ end
349350 ∇z[iIn] = - ∇z[iIn]
350351
351352 else
@@ -363,7 +364,9 @@ function rcsAllocationSimplex(u, My; maxIter=30)
363364 # from its upper bound rather than increased from zero (only done for real
364365 # thrusters, and not slack variables)
365366 if iOut ≤ n
366- E[:, iOut] = - E[:, iOut]
367+ @inbounds for k in 1 : m
368+ E[k, iOut] = - E[k, iOut]
369+ end
367370 ∇z[iOut] = - ∇z[iOut]
368371 end
369372 else
@@ -373,7 +376,9 @@ function rcsAllocationSimplex(u, My; maxIter=30)
373376
374377 # Update basis
375378 iBase[jOut] = iIn # Update list of thrusters in basis (replace basis variables with candidate non-basis one)
376- yb .+ = r* e # Update the solution (substract the effects of having removed one thruster from basis)
379+ @inbounds for k in 1 : m
380+ yb[k] += r* e[k] # Update the solution (substract the effects of having removed one thruster from basis)
381+ end
377382
378383 # Check to see if incoming var is decreasing from upper bnd
379384 if Yn[iIn] > 0.0 # If the candidate non-base thruster was open before entering the base
@@ -383,9 +388,12 @@ function rcsAllocationSimplex(u, My; maxIter=30)
383388 # Switching polarity back to 'nominal' to indicate that now
384389 # thruster ratio y must be increased rather than decreased from
385390 # its upper bound
386- E[:, iIn] = - E[:, iIn]
391+ # E[:, iIn] = -E[:, iIn]
392+ @inbounds for k in 1 : m
393+ E[k, iIn] = - E[k, iIn]
394+ end
387395 ∇z[iIn] = - ∇z[iIn]
388- e = - e
396+ e .* = - 1
389397 ∇zMin = - ∇zMin
390398 else
391399 yb[jOut] = r
0 commit comments