## Question

Hi,
I have been trying to use class

SolverGeneral to handle a practical problem. For short, I have to solve an equation system like:

y1=x1+x2

y2=2*x1+3*x2

For solve this, I wrote raw codes below:

//declare the variable x1 and x2

Variable x1(

TypeID::byname("x1"),&defaultModel,true,false,10.0 );

Variable x2(

TypeID::byname("x2"),&defaultModel,true,false,10.0 );

//In my problem, the GNSS data structure does not

//keep the coefficient, so I have to set coefficient to x1 and x2

x1.setDefaultForced(true);

x2.setDefaultForced(true);

Variable y1(

TypeID::byname("y1"));

Variable y2(

TypeID::byname("y2"));

//Declare equation 1

Equation equ1(y1);

equ1.addVariable(x1);

equ1.addVariable(x2);

//Declare equation 2

Equation equ2(y2);

// I have to change the x1's coefficient

x1.setDefaultCoefficient (2.0);

equ2.addVariable(x1);

//So as to x2

x2.setDefaultCoefficient (3.0);

equ2.addVariable(x2);

// Declare the

EquationSystem
EquationSystem system;

system.addEquation(equ1);

system.addEquation(equ2);

SolverGeneral solverGen(system);

However, these code does not work well, because the change of coefficient, the x1 in equation1 and equation2 are treated as two different variable, so as to x2, the solverGen hold a 2*4 design matrix, not as supposed 2*2. The solverGen have to estimate 4 different variables in total not 2.

How can I fix this problem? Does the class

SolverGeneral has the capability to solve this?

Thank you!

Frank Wong

--

WongM - 25 Mar 2012

## Answer

**If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.**
Dear Frank Wong,

For the moment I must recommend that you explore the code documentation in the

SolverGeneral header and implementation files, including the files that the author suggests to look at also, since the author of the procframe library code has changed employment and is no longer active in GPSTk development/support. We will look into this and get back to you.

Best Regards,

-- Susan Cummins

--

SusanCummins - 27 Mar 2012

Dear Frank Wong,

It appears to me that you have four unknowns (x1, x2, y1, y2) and two equations. Is that a correct statement of your problem?

-- Susan Cummins

--

SusanCummins - 27 Mar 2012

Dear Susan Cummins,
To make the problem more easy to understand, I refer to the simple equation system as example.In fact, there are two unknowns(x1,x2), and you can see the y1 and y2 as observables,you know the value of them before solve your question.

Frank Wong

--

WongM - 31 Mar 2012

Hello Frank!

I'm glad to know that some body are using the framework. I commit 'example 18' some months ago, you should take a look before started.

To solve your problem, try to use the 'x1.setTypeIndexed(true)' and 'x2.setTypeIndexed(true)', let me know if it does not work.

Regards,

Wei Yan

--

YanWei - 31 Mar 2012

Dear Yanwei,

If you remembered, I wrote to your before in chinese. Before I ask this
question I have exhausted myself to solve this problem and read all
the codes that I think will help, included your example 18 and constrainsystem. Unfortunately, it didn't work. Even using

TypeID's setTypeIndexed method the number of variable is more than I expected. I
ask the problem here to ask for other developers' attention. I am looking forward to a smart solution. This is a really practical problem.

Thanks again!

Frank Wong

--

WongM - 01 Apr 2012

Dear Yanwei,
In my opinion, the source of this problem is the mechanics of c++ to identify object.For c++, same object means two objects have same member. However, for class variable, once you change the coefficient of a variable object, there are two variables by c++ grammar. Moreover, the setTypeIndexed method seems could not handle the problem properly.

Thanks again!
Frank Wong

--

WongM - 01 Apr 2012

Hi again!

The 'SolverGeneral' class was initially designed by Dago, and he have left the gpstk team for job changing. In the past years, I have been working with the framework and try to polish some rough edges and extent it with a constraint framework to handle more complex gnss data processing.

I'll take a deep a look and solve the problem after I get my

PhD degree and start my new job, may be several months later. Please bear with us.

Regards,

Wei Yan

--

YanWei - 02 Apr 2012

Dear Wei Yan,

Sorry for delay of response. You've done marvelous work. GPSTk is now the most successful opensource project for GNSS data processing. From it, I've learned a lot which could not learned from books. And I think the 'SolverGeneral' class will provide us with a more general way to 'cook' GNSS data though there is still some work to be done.

If there is something I could help to improve the code, please be free to let me know, after benefiting so much from GPSTk, I want to make my own contribution.

Best regards,

Frank Wong

--

WongM - 04 Apr 2012

Dear Frank Wang!

I promised take a deep look and solve the problem months ago. I just test the 'setTypeIndexed()', and it indeed can solve your problem perfectly. Thank you.

Regards and Cheers,

Wei Yan

--

YanWei - 02 Aug 2012

No such template def TMPL:DEF{PROMPT:supportquery}
- Edit1: txt file describe the problem