Minimizing a system of linear equations with limited variables in Octave - octave

I have scoured Octave resources, pdfs on optimization, and many of the questions here, but I can't seem to find or understand the right solution. I'm trying to find a corrective solution to move a group of data points to match closely another set. The equation used is a quadratic with a cross term, i.e. ax^2 +bx +c + d*y = x', where x is from one data set and x' is from another. There is a similar equation for the y coordinate.
I make the x and y values fixed from the data, and am trying to optimize the coefficients to minimize the square sum error between all the points. For now, I'm just trying to minimize the difference between x and x', via ax^2 +bx +c + d*y - x' = 0. I will try to do a square sum of all the equations later, unless someone here can help me with that as well.
I've tried using fminunc and fminsearch, both having and error after a few iterations due to matrix sizes. I don't think these solutions like having more equations than variables. I do not think qp or glpk are useful solutions.
Here is an example of my system of equations I'm trying to minimize. Future iterations may have as many as 32 equations, but the same number of vairables/coefficients.
function zer = fcn(coeff)
zer = zeros(18,1);
zer(1) = coeff(1)*19.338458^2 + coeff(2)*19.338458 + coeff(3) + coeff(4)*17.806945 - 23.200000;
zer(2) = coeff(1)*-0.146987^2 + coeff(2)*-0.146987 + coeff(3) + coeff(4)*2.273490 - 2.900000;
zer(3) = coeff(1)*-18.333520^2 + coeff(2)*-18.333520 + coeff(3) + coeff(4)*-19.133048 - -15.700000;
zer(4) = coeff(1)*-24.447818^2 + coeff(2)*-24.447818 + coeff(3) + coeff(4)*2.146905 - -21.700000;
zer(5) = coeff(1)*0.363997^2 + coeff(2)*0.363997 + coeff(3) + coeff(4)*27.305928 - 3.500000;
zer(6) = coeff(1)*15.042656^2 + coeff(2)*15.042656 + coeff(3) + coeff(4)*-15.456741 - 18.800000;
zer(7) = coeff(1)*18.529375^2 + coeff(2)*18.529375 + coeff(3) + coeff(4)*1.046316 - 22.100000;
zer(8) = coeff(1)*0.045810^2 + coeff(2)*0.045810 + coeff(3) + coeff(4)*-21.082700 - 3.300000;
zer(9) = coeff(1)*-18.499911^2 + coeff(2)*-18.499911 + coeff(3) + coeff(4)*22.048530 - -15.700000;
zer(10) = coeff(5)*17.806945^2 + coeff(6)*17.806945 + coeff(7) + coeff(8)*19.338458 - 16.000000;
zer(11) = coeff(5)*2.273490^2 + coeff(6)*2.273490 + coeff(7) + coeff(8)*-0.146987 - 0.300000;
zer(12) = coeff(5)*-19.133048^2 + coeff(6)*-19.133048 + coeff(7) + coeff(8)*-18.333520 - -21.400000;
zer(13) = coeff(5)*2.146905^2 + coeff(6)*2.146905 + coeff(7) + coeff(8)*-24.447818 - 0.400000;
zer(14) = coeff(5)*27.305928^2 + coeff(6)*27.305928 + coeff(7) + coeff(8)*0.363997 - 25.700000;
zer(15) = coeff(5)*-15.456741^2 + coeff(6)*-15.456741 + coeff(7) + coeff(8)*15.042656 - -18.300000;
zer(16) = coeff(5)*1.046316^2 + coeff(6)*1.046316 + coeff(7) + coeff(8)*18.529375 - -1.100000;
zer(17) = coeff(5)*-21.082700^2 + coeff(6)*-21.082700 + coeff(7) + coeff(8)*0.045810 - -23.200000;
zer(18) = coeff(5)*22.048530^2 + coeff(6)*22.048530 + coeff(7) + coeff(8)*-18.499911 - 20.200000;
endfunction

Erwin and Cris in the comments are 100% correct.
All that needs to be done here is convert this into a matrix with a answer vector.
best_solution = Matrix\answer_vector;
It's embarrassing how much I overcomplicated the problem.

Related

Disable camel-debezium-mysql endpoint URI in Camel metrics

The full Debezium MySQL URI string shows up in metrics. It shows the MySQL user and password in plaintext, which is unsafe. How can one disable this? I followed this setup here.
More information:
Using quarkus 1.11.1.Final which uses camel 3.7.0 with debezium-connector-mysql 1.3.1.Final
This is the Camel route:
from("debezium-mysql:" + config.getConnectorName()
+ "?databaseHostname=" + config.getHost()
+ "&databasePort=" + config.getPort()
+ "&databaseUser=" + config.getUser()
+ "&databasePassword=" + config.getPassword()
+ "&databaseServerName=" + config.getDatabaseServerName()
+ "&databaseServerId=" + config.getDatabaseServerId()
+ "&databaseIncludeList=" + config.getDatabases()
+ "&tableIncludeList=" + config.getTables()
+ "&columnIncludeList=" + config.getColumns()
+ "&databaseHistoryFileFilename=" + config.getHistoryFile()
+ "&offsetStorageFileName=" + config.getStorageFile()
+ "&exchangePattern=InOnly")
.routeId("debezium")
.process(outgoingProcessor)
.marshal().json(JsonLibrary.Jackson)
.to(ExchangePattern.InOnly, outgoingUri)
.to("micrometer:counter:outgoing.counter")
.end();
And when accessing the metrics at /q/metrics, I find this entry:
# HELP CamelExchangeEventNotifier_seconds_max
# TYPE CamelExchangeEventNotifier_seconds_max gauge
CamelExchangeEventNotifier_seconds_max{camelContext="camel-1", endpointName="debezium-mysql://entire connection string here with user and password", eventType="ExchangeCompletedEvent", failed="false", serviceName="MicrometerEventNotifierService",} 0.0
Thank you for bring this up. I have created a Jira ticket to fix this in the upcoming Camel release to mask those sensitive data in those events in the metrics.

invalid value encountered in true_divide in rk45

I'm trying to implement to RK45 for a two body problem with the earth and sun but keep getting a division by zero that I don't understand. It seems to be in the norme from the accelerations function that the division occurs but I don't see how that can be or how to fix it. Here is code:
from scipy import optimize
from numpy import linalg as LA
import matplotlib.pyplot as plt
from scipy.optimize import fsolve
import numpy as np
AU=1.5e11
a=AU
e=0.5
mss=2E30
ms = 2E30
me = 5.98E24
mv=4.867E24
yr=3.15e7
h=100
mu1=ms*me/(ms+me)
mu2=ms*me/(ms+me)
G=6.67E11
step=24
vi=np.sqrt(G*ms*(2/(a*(1-e))-1/a))
#sun=sphere(pos=vec(0,0,0),radius=0.1*AU,color=color.yellow)
#earth=sphere(pos=vec(1*AU,0,0),radius=0.1*AU)
sunpos=np.array([-903482.12391302, -6896293.6960525, 0. ])
earthpos=np.array([a*(1-e),0,0])
earthv=np.array([0,vi,0])
sunv=np.array([0,0,0])
def accelerations(t,earthposs, sunposs):
norme=sum( (earthposs-sunposs)**2 )**0.5
gravit = G*(earthposs-sunposs)/norme**3
sunaa = me*gravit
earthaa = -ms*gravit
return earthaa, sunaa
def ode45(f,t,y,h):
"""Calculate next step of an initial value problem (IVP) of an ODE with a RHS described
by the RHS function with an order 4 approx. and an order 5 approx.
Parameters:
t: float. Current time.
y: float. Current step (position).
h: float. Step-length.
Returns:
q: float. Order 2 approx.
w: float. Order 3 approx.
"""
s1 = f(t, y[0],y[1])
s2 = f(t + h/4.0, y[0] + h*s1[0]/4.0,y[1] + h*s1[1]/4.0)
s3 = f(t + 3.0*h/8.0, y[0] + 3.0*h*s1[0]/32.0 + 9.0*h*s2[0]/32.0,y[1] + 3.0*h*s1[1]/32.0 + 9.0*h*s2[1]/32.0)
s4 = f(t + 12.0*h/13.0, y[0] + 1932.0*h*s1[0]/2197.0 - 7200.0*h*s2[0]/2197.0 + 7296.0*h*s3[0]/2197.0,y[1] + 1932.0*h*s1[1]/2197.0 - 7200.0*h*s2[1]/2197.0 + 7296.0*h*s3[1]/2197.0)
s5 = f(t + h, y[0] + 439.0*h*s1[0]/216.0 - 8.0*h*s2[0] + 3680.0*h*s3[0]/513.0 - 845.0*h*s4[0]/4104.0,y[1] + 439.0*h*s1[1]/216.0 - 8.0*h*s2[1] + 3680.0*h*s3[1]/513.0 - 845.0*h*s4[1]/4104.0)
s6 = f(t + h/2.0, y[0] - 8.0*h*s1[0]/27.0 + 2*h*s2[0] - 3544.0*h*s3[0]/2565 + 1859.0*h*s4[0]/4104.0 - 11.0*h*s5[0]/40.0,y[1] - 8.0*h*s1[1]/27.0 + 2*h*s2[1] - 3544.0*h*s3[1]/2565 + 1859.0*h*s4[1]/4104.0 - 11.0*h*s5[1]/40.0)
w1 = y[0] + h*(25.0*s1[0]/216.0 + 1408.0*s3[0]/2565.0 + 2197.0*s4[0]/4104.0 - s5[0]/5.0)
w2 = y[1] + h*(25.0*s1[1]/216.0 + 1408.0*s3[1]/2565.0 + 2197.0*s4[1]/4104.0 - s5[1]/5.0)
q1 = y[0] + h*(16.0*s1[0]/135.0 + 6656.0*s3[0]/12825.0 + 28561.0*s4[0]/56430.0 - 9.0*s5[0]/50.0 + 2.0*s6[0]/55.0)
q2 = y[1] + h*(16.0*s1[1]/135.0 + 6656.0*s3[1]/12825.0 + 28561.0*s4[1]/56430.0 - 9.0*s5[1]/50.0 + 2.0*s6[1]/55.0)
return w1,w2, q1,q2
t=0
T=10**5
xarray=[]
yarray=[]
while t<T:
ode45(accelerations,t,[earthpos,sunpos],h)
earthpos=ode45(accelerations,t,[earthpos,sunpos],h)[1]
sunpos=ode45(accelerations,t,[earthpos,sunpos],h)[3]
xarray.append(ode45(accelerations,t,[earthpos,sunpos],h)[0][0])
yarray.append(ode45(accelerations,t,[earthpos,sunpos],h)[0][1])
print(ode45(accelerations,t,[earthpos,sunpos],h)[0][0],ode45(accelerations,t,[earthpos,sunpos],h)[0][1])
t=t+h
plt.plot(xarray,yarray)
plt.savefig('orbit.png')
plt.show()
After the second iteration the code comes back with only nan values for the earthpos.
Numerical integration methods usually integrate first order systems, y'=f(t,y). You want to integrate a second order ODE system y''=f(t,y) which you first need to turn into a first order system.
Why do you not use the vector class of numpy?
Why do you perform the same computation with the same arguments multiple times instead of catching all return values once and then distributing them to the lists?
You could also use scipy.integrate.solve_ivp with the "RK45" method instead of programming it yourself.

Promise.all to update the data in mysql by using GET request, but it doesn't update all of the data

I am currently trying to update some data using fetch in mysql, whenever i click a button, the Promise.all triggers, and fetches all the data from my function, then, i fetch all the data from the jsons that I get from my promise.all and i make a GET request to update all the data, but it doesnt seem to update all the data in my database, only a few.
const previousMonthcompanyInfos = this.state.addDataOnce == 'true' && this.state.airlinesPreviousMonth && this.state.airlinesPreviousMonth.filter(t=> t.airlineName != 'Generic').map((airline, idx) => {
Promise.all([
fetch(`http://ca-fpscfb2:4000/totalOpenBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/totalOpenEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/totalOpenQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/P1OpenedPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/P2OpenedPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/ticketsThisCyclePreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/ticketsOneToThreeMonthsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/ticketsThreeToSixMonthsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/ticketsSixToTwelveMonthsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/ticketsMoreThanOneYearPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/1stMonthOpenedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/2ndMonthOpenedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/3rdMonthOpenedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/4thMonthOpenedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/1stMonthOpenedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/2ndMonthOpenedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/3rdMonthOpenedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/4thMonthOpenedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/1stMonthOpenedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/2ndMonthOpenedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/3rdMonthOpenedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/4thMonthOpenedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/1stMonthClosedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/2ndMonthClosedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/3rdMonthClosedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/4thMonthClosedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/1stMonthClosedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/2ndMonthClosedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/3rdMonthClosedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/4thMonthClosedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/1stMonthClosedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/2ndMonthClosedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/3rdMonthClosedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/4thMonthClosedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/LineValuePreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
fetch(`http://ca-fpscfb2:4000/CRsDataPerAirlinePreviousMonth?airline=${airline.airlineName}&product=${airline.product}`),
fetch(`http://ca-fpscfb2:4000/HLEsDataPerAirlinePreviousMonth?airline=${airline.airlineName}&product=${airline.product}`)
])
.then(([totalBugs, totalEnhancements, totalQuestions, P1, P2, ticketCreationThisCycle, ticketCreationOneToThree,
ticketsCreationThreeToSix, ticketsCreationSixToTwelve, ticketsCreationOneYear,
monthOneOpenEnhancements, monthTwoOpenEnhancements, monthThreeOpenEnhancements, monthFourOpenEnhancements,
monthOneOpenBugs, monthTwoOpenBugs, monthThreeOpenBugs, monthFourOpenBugs,
monthOneOpenQuestions, monthTwoOpenQuestions, monthThreeOpenQuestions, monthFourOpenQuestions,
monthOneClosedEnhancements, monthTwoClosedEnhancements, monthThreeClosedEnhancements, monthFourClosedEnhancements,
monthOneClosedBugs, monthTwoClosedBugs, monthThreeClosedBugs, monthFourClosedBugs,
monthOneClosedQuestions, monthTwoCloseQuestions, monthThreeClosedQuestions, monthFourClosedQuestions, lineValue, JSONCR, JSONHLE]) => Promise.all([totalBugs.json(), totalEnhancements.json(), totalQuestions.json(), P1.json(), P2.json(),
ticketCreationThisCycle.json(), ticketCreationOneToThree.json(),ticketsCreationThreeToSix.json(), ticketsCreationSixToTwelve.json(), ticketsCreationOneYear.json(),
monthOneOpenEnhancements.json(), monthTwoOpenEnhancements.json(), monthThreeOpenEnhancements.json(), monthFourOpenEnhancements.json(),
monthOneOpenBugs.json(), monthTwoOpenBugs.json(), monthThreeOpenBugs.json(), monthFourOpenBugs.json(),
monthOneOpenQuestions.json(), monthTwoOpenQuestions.json(), monthThreeOpenQuestions.json(), monthFourOpenQuestions.json(),
monthOneClosedEnhancements.json(), monthTwoClosedEnhancements.json(), monthThreeClosedEnhancements.json(), monthFourClosedEnhancements.json(),
monthOneClosedBugs.json(), monthTwoClosedBugs.json(), monthThreeClosedBugs.json(), monthFourClosedBugs.json(),
monthOneClosedQuestions.json(), monthTwoCloseQuestions.json(), monthThreeClosedQuestions.json(), monthFourClosedQuestions.json(), lineValue.json(),
JSONCR.json(), JSONHLE.json()
]))
.then(([totalBugs, totalEnhancements, totalQuestions, P1, P2, ticketCreationThisCycle, ticketCreationOneToThree,
ticketsCreationThreeToSix, ticketsCreationSixToTwelve, ticketsCreationOneYear,
monthOneOpenEnhancements, monthTwoOpenEnhancements, monthThreeOpenEnhancements, monthFourOpenEnhancements,
monthOneOpenBugs, monthTwoOpenBugs, monthThreeOpenBugs, monthFourOpenBugs,
monthOneOpenQuestions, monthTwoOpenQuestions, monthThreeOpenQuestions, monthFourOpenQuestions,
monthOneClosedEnhancements, monthTwoClosedEnhancements, monthThreeClosedEnhancements, monthFourClosedEnhancements,
monthOneClosedBugs, monthTwoClosedBugs, monthThreeClosedBugs, monthFourClosedBugs,
monthOneClosedQuestions, monthTwoCloseQuestions, monthThreeClosedQuestions, monthFourClosedQuestions, lineValue, JSONCR, JSONHLE
]) => {
this.setState({ addDataOnce: 'true' }, () => {
fetch(`http://ca-fpscfb2:4000/SavePreviousMonthlyValuesForPreviousMonth?previous_dashboardID=${this.state.lastInsertedDashboardID-1}
&airlineID=${airline.airlineID}&totalBugs=${totalBugs.data.total}&totalQuestions=${totalQuestions.data.total}&totalEnhancements=${totalEnhancements.data.total}
&totalOpen=${totalBugs.data.total+totalQuestions.data.total+totalEnhancements.data.total}&P1=${P1.data.total}&P2=${P2.data.total}&ticketCreationThisCycle=${ticketCreationThisCycle.data.total}&
&ticketCreationOneToThree=${ticketCreationOneToThree.data.total}&ticketsCreationThreeToSix=${ticketsCreationThreeToSix.data.total}&ticketsCreationSixToTwelve=${ticketsCreationSixToTwelve.data.total}
&ticketsCreationOneYear=${ticketsCreationOneYear.data.total}&monthOneOpenEnhancements=${monthOneOpenEnhancements.data.total}&monthTwoOpenEnhancements=${monthTwoOpenEnhancements.data.total}
&monthThreeOpenEnhancements=${monthThreeOpenEnhancements.data.total}&monthFourOpenEnhancements=${monthFourOpenEnhancements.data.total}&monthOneOpenBugs=${monthOneOpenBugs.data.total}&monthTwoOpenBugs=${monthTwoOpenBugs.data.total}
&monthThreeOpenBugs=${monthThreeOpenBugs.data.total}&monthFourOpenBugs=${monthFourOpenBugs.data.total}&monthOneOpenQuestions=${monthOneOpenQuestions.data.total}&monthTwoOpenQuestions=${monthTwoOpenQuestions.data.total}
&monthThreeOpenQuestions=${monthThreeOpenQuestions.data.total}&monthFourOpenQuestions=${monthFourOpenQuestions.data.total}&monthOneClosedEnhancements=${monthOneClosedEnhancements.data.total}&monthTwoClosedEnhancements=${monthTwoClosedEnhancements.data.total}
&monthThreeClosedEnhancements=${monthThreeClosedEnhancements.data.total}&monthFourClosedEnhancements=${monthFourClosedEnhancements.data.total}&monthOneClosedBugs=${monthOneClosedBugs.data.total}&monthTwoClosedBugs=${monthTwoClosedBugs.data.total}
&monthThreeClosedBugs=${monthThreeClosedBugs.data.total}&monthFourClosedBugs=${monthFourClosedBugs.data.total}&monthOneClosedQuestions=${monthOneClosedQuestions.data.total}&monthTwoCloseQuestions=${monthTwoCloseQuestions.data.total}
&monthThreeClosedQuestions=${monthThreeClosedQuestions.data.total}&monthFourClosedQuestions=${monthFourClosedQuestions.data.total}&monthOneLine=${lineValue.data.total + (monthOneOpenEnhancements.data.total + monthOneOpenBugs.data.total + monthOneOpenQuestions.data.total) - (monthOneClosedBugs.data.total + monthOneClosedEnhancements.data.total + monthOneClosedQuestions.data.total)}
&monthTwoLine=${lineValue.data.total + (monthOneOpenEnhancements.data.total + monthOneOpenBugs.data.total + monthOneOpenQuestions.data.total) - (monthOneClosedBugs.data.total + monthOneClosedEnhancements.data.total + monthOneClosedQuestions.data.total)
+ (monthTwoOpenBugs.data.total + monthTwoOpenEnhancements.data.total + monthTwoOpenQuestions.data.total) - (monthTwoCloseQuestions.data.total + monthTwoClosedBugs.data.total + monthTwoClosedEnhancements.data.total)}
&monthThreeLine=${lineValue.data.total + (monthOneOpenEnhancements.data.total + monthOneOpenBugs.data.total + monthOneOpenQuestions.data.total) - (monthOneClosedBugs.data.total + monthOneClosedEnhancements.data.total + monthOneClosedQuestions.data.total)
+ (monthTwoOpenBugs.data.total + monthTwoOpenEnhancements.data.total + monthTwoOpenQuestions.data.total) - (monthTwoCloseQuestions.data.total + monthTwoClosedBugs.data.total + monthTwoClosedEnhancements.data.total)
+ (monthThreeOpenBugs.data.total + monthThreeOpenEnhancements.data.total + monthThreeOpenQuestions.data.total) - (monthThreeClosedBugs.data.total + monthThreeClosedEnhancements.data.total + monthThreeClosedQuestions.data.total)}
&monthFourLine=${lineValue.data.total + (monthOneOpenEnhancements.data.total + monthOneOpenBugs.data.total + monthOneOpenQuestions.data.total) - (monthOneClosedBugs.data.total + monthOneClosedEnhancements.data.total + monthOneClosedQuestions.data.total)
+ (monthTwoOpenBugs.data.total + monthTwoOpenEnhancements.data.total + monthTwoOpenQuestions.data.total) - (monthTwoCloseQuestions.data.total + monthTwoClosedBugs.data.total + monthTwoClosedEnhancements.data.total)
+ (monthThreeOpenBugs.data.total + monthThreeOpenEnhancements.data.total + monthThreeOpenQuestions.data.total) - (monthThreeClosedBugs.data.total + monthThreeClosedEnhancements.data.total + monthThreeClosedQuestions.data.total)
+ (monthFourOpenBugs.data.total+ monthFourOpenEnhancements.data.total + monthFourOpenQuestions.data.total) - (monthFourClosedBugs.data.total + monthFourClosedEnhancements.data.total + monthFourClosedQuestions.data.total)}
&openedLastCycle=${monthFourOpenBugs.data.total + monthFourOpenEnhancements.data.total+ monthFourOpenQuestions.data.total}
&resolvedLastCycle=${monthFourClosedBugs.data.total + monthFourClosedEnhancements.data.total + monthFourClosedQuestions.data.total}&JSONCR=${Base64.encode(JSON.stringify(JSONCR.data))}&JSONHLE=${Base64.encode(JSON.stringify(JSONHLE.data))}
`)
}
)
})
}
)
{previousMonthcompanyInfos}

Why is setting SQL variable is creating an error?

Following SQL statement is creating an error with message :
"Message: Fatal error encountered during command execution."
"Inner exception: Parameter '#LastUserID' must be defined."
If I directly use LAST_INSERT_ID() instead of LastUserID, it always returns zero (hence fails at second insert) when executed like this.
I don't see my syntax is different than in mySQL document.
Could some one help me ?
string Query = #"INSERT INTO login (" +
"LOGIN_EMAIL," +
"LOGIN_PASSWORD," +
"LOGIN_SALT," +
"LOGIN_LAST_LOGIN_DATE," +
// "LOGIN_LAST_LOGIN_LOCATION," +
"LOGIN_ACCOUNT_STATUS," +
"LOGIN_LOGIN_ATTEMPTS," +
"LOGIN_CREATED_DATE) " +
"VALUES (" +
"#Parameter2," +
"#Parameter3," +
"#Parameter4," +
"#Parameter5," +
// "#Parameter6," +
"#Parameter6," +
"#Parameter7," +
"#Parameter8); " +
"SET #LastUserID = LAST_INSERT_ID(); " +
"INSERT INTO user_role (" +
"USER_ROLE_USER_ID," +
"USER_ROLE_ROLE," +
"USER_ROLE_STATUS," +
"USER_ROLE_CREATED_DATE) " +
"SELECT " +
"#LastUserID," +
"#Parameter9," +
"#Parameter10," +
"#Parameter11 " +
"FROM dual WHERE NOT EXISTS (SELECT USER_ROLE_USER_ID FROM user_role " +
"WHERE USER_ROLE_USER_ID = #LastUserID AND USER_ROLE_ROLE = #Parameter9)";
MySqlCommand oCommand = new MySqlCommand(Query, oMySQLConnecion);
oCommand.Transaction = tr;
Create a procedure in which you first do your insert, cache the last inserted id, do the other insert and let it print out your parameters with a bool if your last insert worked or not. That way you can debug it properly.
In general you should avoid concatinating strings to generate sql-commands or you might get troubles with parameters containing unexpected characters or be hit by a injection.
Simple fix : Replace "$LastUserID" with "$'LastUserID'". The ephostophy makes the difference.

Why CurrentApp::AppId take so long in Windows Phone 10?

I have a windows 8 universal project and have a function to get APP ID,
The following function works well in Windows Phone 8.1
Platform::Guid appId = Windows::ApplicationModel::Store::CurrentApp::AppId;
however, it spent around 40s in Windows Phone 10.
From MSDN, only the Metadata is different,
May I know is it caused by the metadata? And how to solve it?
To instead of using AppID, you might use the following code,
Windows::ApplicationModel::Package^ package = Windows::ApplicationModel::Package::Current;
Windows::ApplicationModel::PackageId^ packageId = package->Id;
Windows::ApplicationModel::PackageVersion version = packageId->Version;
Platform::String^ output =
"Name: \"" + packageId->Name + "\"\n" +
"Version: " + version.Major.ToString() + "."
+ version.Minor.ToString() + "."
+ version.Revision.ToString() + "."
+ version.Build.ToString() + "\n" +
"Architecture: " + packageId->Architecture.ToString() + "\n" +
"ResourceId: \"" + packageId->ResourceId + "\"\n" +
"Publisher: \"" + packageId->Publisher + "\"\n" +
"PublisherId: \"" + packageId->PublisherId + "\"\n" +
"FullName: \"" + packageId->FullName + "\"\n" +
"FamilyName: \"" + packageId->FamilyName + "\"\n" +
"IsFramework: " + package->IsFramework.ToString();
Sample output from device
Output:
Name: "f3e02737-ddfa-47a0-a837-37ee53459898"
Version: 1.0.0.0
Architecture: Arm
ResourceId: ""
Publisher: "CN=heefan"
PublisherId: "gsbawe9kfjm1p"
FullName: "f3e02737-ddfa-47a0-a837-37ee53459898_1.0.0.0_arm__gsbawe9kfjm1p"
FamilyName: "f3e02737-ddfa-47a0-a837-37ee53459898_gsbawe9kfjm1p"
IsFramework: false
I also have no idea why AppID take long time to compute.