I need to input the vector into a function in the form of x1, x2, .. , xn so that I can run an lpsolve but I can't figure out how to do this. I can't put it in as a vector, It needs to be in that form with the commas separating the terms. I don't know how to make it this way though. I was thinking make it a string of characters but I don't know how to do that either.
I built the vector using the push_back from separate Duration values. I was thinking their may be a way to create a string/char in the same way where I push the value then the comma then another value so on and so forth.
I need to have it with the commas separating the values...
ehrm I doubt you do.... but I'll dig. Why do you need comma separated values? Are you saying the function has comma separated arguments? What does the function do? Is there a better alternative?
In your example you're attempting to convert to an array, which is unnecessary! Just do this!:
add_constraint(lp,&DurationVector[0], LE, P[P.size()-1][1]);
From what I have gathered (through trial and error using working programs) I do need comma separated values but I never thought to try to just put it in the add_constraint like that so here goes...
That's just initializing the array, if you want a new array with the elements of a vector here's a quick (and dirty) and easy way to do it. (you can also just use a pointer...which is exactly what I'm recommending with the &DurationVector[0] thing)
1 2 3 4 5 6 7 8 9
double* row = newdouble[DurationVector.size()];
for (int a = 0; a < DurationVector.size(); a++){
row[a]=DurationVector[a];
}
//do your stuff with row here
delete [] row;