optimization

Least squares in a set of equations with optimize.leastsq() (Python)

陌路散爱 提交于 2021-02-09 15:49:04
问题 I have two functions and a set of data. Both functions have the same x data and the same parameters. I want to obtain the parameters by least squares method that makes the best fit of my data. The parameters are: ex,ey,ez. The X data are: RA,DE (like 3000 points). The Y data are: dRA,dDE. I tried this but I obtained a wrong solution: def residuals(p, dRA, dDE, RA, DEC): ex,ey,ez = p f1 = dRA-(ex*sin(DEC)*cos(RA)+ey*sin(DEC)*sin(RA)-ez*cos(DEC)) f2 = dDE-(-ex*sin(RA)+ey*cos(RA)) err = np

Least squares in a set of equations with optimize.leastsq() (Python)

人盡茶涼 提交于 2021-02-09 15:46:38
问题 I have two functions and a set of data. Both functions have the same x data and the same parameters. I want to obtain the parameters by least squares method that makes the best fit of my data. The parameters are: ex,ey,ez. The X data are: RA,DE (like 3000 points). The Y data are: dRA,dDE. I tried this but I obtained a wrong solution: def residuals(p, dRA, dDE, RA, DEC): ex,ey,ez = p f1 = dRA-(ex*sin(DEC)*cos(RA)+ey*sin(DEC)*sin(RA)-ez*cos(DEC)) f2 = dDE-(-ex*sin(RA)+ey*cos(RA)) err = np

Should we prefer temporary variables over user defined variables in c++

梦想与她 提交于 2021-02-09 08:44:27
问题 Lets say there is a c++ function foo() which returns a boolean. I call this functions to check the status of a property Or to get the result of the function call. So what would be the best way to call this type of functions. Method 1 : bool flag = foo() if (flag) { // some code } else { // else some code } Method 2: if ( foo() ) { // some code } else { // some code } My Question : Does using the temporary variable gives compiler opportunity to better optimize in general. 回答1: First of all,

Trajectory Planner with GEKKO is not able to handle given goal velocities

两盒软妹~` 提交于 2021-02-09 07:30:22
问题 I have set up a Trajectory Planner for a vehicle with GEKKO, so basically i used a kinematic single-track model, which in nonlinear. It all works fine until i get to the part, when i give a goal velocity that is not equal to 0. I can give all other goal states (x-position, y-position, steering angle and yaw angle) without problems, but if i give a goal velocity, the optimizer exits with the following code: Converged to a point of local infeasibility. Problem may be infeasible. I also tried

Trajectory Planner with GEKKO is not able to handle given goal velocities

♀尐吖头ヾ 提交于 2021-02-09 07:26:14
问题 I have set up a Trajectory Planner for a vehicle with GEKKO, so basically i used a kinematic single-track model, which in nonlinear. It all works fine until i get to the part, when i give a goal velocity that is not equal to 0. I can give all other goal states (x-position, y-position, steering angle and yaw angle) without problems, but if i give a goal velocity, the optimizer exits with the following code: Converged to a point of local infeasibility. Problem may be infeasible. I also tried

Trajectory Planner with GEKKO is not able to handle given goal velocities

自作多情 提交于 2021-02-09 07:26:02
问题 I have set up a Trajectory Planner for a vehicle with GEKKO, so basically i used a kinematic single-track model, which in nonlinear. It all works fine until i get to the part, when i give a goal velocity that is not equal to 0. I can give all other goal states (x-position, y-position, steering angle and yaw angle) without problems, but if i give a goal velocity, the optimizer exits with the following code: Converged to a point of local infeasibility. Problem may be infeasible. I also tried

GCC not performing loop invariant code motion

爷,独闯天下 提交于 2021-02-09 07:12:33
问题 I decided to check the result of loop invariant code motion optimization using g++. However, when I compiled the following code with -fmove-loop-invariants and analysed its assembly, I saw that k + 17 calculation is still performed in the loop body. What could prevent the compiler from optimizing it? May be the compiler concludes that it is more efficient to recalculate k + 17 ? int main() { int k = 0; std::cin >> k; for (int i = 0; i < 10000; ++i) { int n = k + 17; // not moved out of the

SIMD optimization of a curve computed from the second derivative

妖精的绣舞 提交于 2021-02-08 19:21:51
问题 This question is really a curiosity. I was converting a routine into SIMD instructions (and I am quite new to SIMD programming), and had trouble with the following bit of code: // args: uint32_t phase_current; uint32_t phase_increment; uint32_t phase_increment_step; for (int i = 0; i < blockSize; ++i) { USEFUL_FUNC(phase_current); phase_increment += phase_increment_step; phase_current += phase_increment; } The Question: Assuming that USEFUL_FUNC has a SIMD implementation and I am simply

SIMD optimization of a curve computed from the second derivative

青春壹個敷衍的年華 提交于 2021-02-08 19:10:14
问题 This question is really a curiosity. I was converting a routine into SIMD instructions (and I am quite new to SIMD programming), and had trouble with the following bit of code: // args: uint32_t phase_current; uint32_t phase_increment; uint32_t phase_increment_step; for (int i = 0; i < blockSize; ++i) { USEFUL_FUNC(phase_current); phase_increment += phase_increment_step; phase_current += phase_increment; } The Question: Assuming that USEFUL_FUNC has a SIMD implementation and I am simply

SIMD optimization of a curve computed from the second derivative

大憨熊 提交于 2021-02-08 19:06:50
问题 This question is really a curiosity. I was converting a routine into SIMD instructions (and I am quite new to SIMD programming), and had trouble with the following bit of code: // args: uint32_t phase_current; uint32_t phase_increment; uint32_t phase_increment_step; for (int i = 0; i < blockSize; ++i) { USEFUL_FUNC(phase_current); phase_increment += phase_increment_step; phase_current += phase_increment; } The Question: Assuming that USEFUL_FUNC has a SIMD implementation and I am simply