Jacobian at optimal condition
Jacobian at optimal condition
Dear all
I guess I am repeating a common question, though I could not find an answer to.
Is that possible to get the Jacobian of the model at the optimal conditions? Is there any attribute for the constraints that can help reporting the derivatives with respect to various variables?
I hope GAMS can help on that. I appreciate your responses.
Regards

Ù…ØÙ…Ø¯ ØµØ§Ø¯Ù‚ ØªÙˆÙ„Ù‘Ù„ÛŒ
Mohammad Sadegh Tavallali
National University of Singapore

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
Re: Jacobian at optimal condition
Mohammad,
GAMS does not have the gradient information readily available inside the GAMS language. To access the gradient info you need access to the Jacobi MATRIX. This does only exist when GAMS communicates with the solver. There is a trick to get this Jacobi "matrix". This goes via the scalar model Convert (or ConvertD) looks at. Basically you can easily get the Jacobian via the solver ConvertD using option "jacobian". This gives you a two dimensional parameter A(i,j) with i = e1,e2,e3,... and j=x1,x2,x3,... in a GDX file jacobian.gdx. With the help of some name mapping you can map you original variables and equations into the e1,e2,... and x1,x2,... space. For that you declare for each variable and equation symbol in your model a set varname_vm(j,original index space) and equname_em(i,original index space). The content for these symbols is created by a ConvertD option called dictmap. Having the maps and the Jacobian A you can map the relevant part of the Jacobian into your name space. I have attached an example (weapons from the GAMS model library that demonstrates this).
This is not very elegant, but if you really need it this would do the trick.
Hope this helps,
Michael Bussieck  GAMS World Administrator
On Sun, Nov 18, 2012 at 9:45 PM, Tavallali
Dear all
I guess I am repeating a common question, though I could not find an answer to.
Is that possible to get the Jacobian of the model at the optimal conditions? Is there any attribute for the constraints that can help reporting the derivatives with respect to various variables?
I hope GAMS can help on that. I appreciate your responses.
Regards

Ù…ØÙ…Ø¯ ØµØ§Ø¯Ù‚ ØªÙˆÙ„Ù‘Ù„ÛŒ
Mohammad Sadegh Tavallali
National University of Singapore

 Attachments

 weapons.gms
 (3.23 KiB) Downloaded 8 times
Re: Jacobian at optimal condition
Replyto: gamsworld@googlegroups.com
Dear Frank and and Micheal
Thanks both for your responses. I am also exactly looking for what Frank discussed in the previous post. Micheal's description shows a green light for that. I will check the file, and at the same time really welcome any related description / example on that. With the increasing need to access the Jacobian for various implementations / interpretations, it would be great if GAMS can add a clear and userfriendly description to its splendid user/solvers manuals.
Regards
Mohammad Sadegh Tavallali
National University of Singapore
On Tue, Nov 20, 2012 at 1:03 AM, Frank Ward wrote:
Michael,
Thanks for your note to Mohammad. Your method seems like a way to discover something very valuable indeed. Does that method produce numerical results for the partial derivative of each (dependent) variable with respect to changes in each parameter? That is quite a matrix indeed. It could be a very powerful and fast way conduct a sensitivity analysis. It tells the modeler the sensitivity of each variable with respect to changes in each assumption (parameter).
Many people have asked me about that information in recent years. Of course, theyâ€™re asking for much more than simple shadow prices (marginal). It would sure be nice to give them a â€˜yesâ€™ answer in the future.
Thanks for checking.
Frank Ward
From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Michael Bussieck
Sent: Monday, November 19, 2012 7:45 AM
To: gamsworld@googlegroups.com
Subject: Re: Jacobian at optimal condition
Mohammad,
GAMS does not have the gradient information readily available inside the GAMS language. To access the gradient info you need access to the Jacobi MATRIX. This does only exist when GAMS communicates with the solver. There is a trick to get this Jacobi "matrix". This goes via the scalar model Convert (or ConvertD) looks at. Basically you can easily get the Jacobian via the solver ConvertD using option "jacobian". This gives you a two dimensional parameter A(i,j) with i = e1,e2,e3,... and j=x1,x2,x3,... in a GDX file jacobian.gdx. With the help of some name mapping you can map you original variables and equations into the e1,e2,... and x1,x2,... space. For that you declare for each variable and equation symbol in your model a set varname_vm(j,original index space) and equname_em(i,original index space). The content for these symbols is created by a ConvertD option called dictmap. Having the maps and the Jacobian A you can map the relevant part of the Jacobian into your name space. I have attached an example (weapons from the GAMS model library that demonstrates this).
This is not very elegant, but if you really need it this would do the trick.
Hope this helps,
Michael Bussieck  GAMS World Administrator
On Sun, Nov 18, 2012 at 9:45 PM, Tavallali wrote:
Dear all
I guess I am repeating a common question, though I could not find an answer to.
Is that possible to get the Jacobian of the model at the optimal conditions? Is there any attribute for the constraints that can help reporting the derivatives with respect to various variables?
I hope GAMS can help on that. I appreciate your responses.
Regards

Ù…ØÙ…Ø¯ ØµØ§Ø¯Ù‚ ØªÙˆÙ„Ù‘Ù„ÛŒ
Mohammad Sadegh Tavallali
National University of Singapore

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Michael R. Bussieck, Ph.D.
Fon/Fax: +1 202 3420180/1 (USA) +49 221 9499170/1 (Germany)
www.gams.com

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
Dear Frank and and Micheal
Thanks both for your responses. I am also exactly looking for what Frank discussed in the previous post. Micheal's description shows a green light for that. I will check the file, and at the same time really welcome any related description / example on that. With the increasing need to access the Jacobian for various implementations / interpretations, it would be great if GAMS can add a clear and userfriendly description to its splendid user/solvers manuals.
Regards
Mohammad Sadegh Tavallali
National University of Singapore
On Tue, Nov 20, 2012 at 1:03 AM, Frank Ward
Michael,
Thanks for your note to Mohammad. Your method seems like a way to discover something very valuable indeed. Does that method produce numerical results for the partial derivative of each (dependent) variable with respect to changes in each parameter? That is quite a matrix indeed. It could be a very powerful and fast way conduct a sensitivity analysis. It tells the modeler the sensitivity of each variable with respect to changes in each assumption (parameter).
Many people have asked me about that information in recent years. Of course, theyâ€™re asking for much more than simple shadow prices (marginal). It would sure be nice to give them a â€˜yesâ€™ answer in the future.
Thanks for checking.
Frank Ward
From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Michael Bussieck
Sent: Monday, November 19, 2012 7:45 AM
To: gamsworld@googlegroups.com
Subject: Re: Jacobian at optimal condition
Mohammad,
GAMS does not have the gradient information readily available inside the GAMS language. To access the gradient info you need access to the Jacobi MATRIX. This does only exist when GAMS communicates with the solver. There is a trick to get this Jacobi "matrix". This goes via the scalar model Convert (or ConvertD) looks at. Basically you can easily get the Jacobian via the solver ConvertD using option "jacobian". This gives you a two dimensional parameter A(i,j) with i = e1,e2,e3,... and j=x1,x2,x3,... in a GDX file jacobian.gdx. With the help of some name mapping you can map you original variables and equations into the e1,e2,... and x1,x2,... space. For that you declare for each variable and equation symbol in your model a set varname_vm(j,original index space) and equname_em(i,original index space). The content for these symbols is created by a ConvertD option called dictmap. Having the maps and the Jacobian A you can map the relevant part of the Jacobian into your name space. I have attached an example (weapons from the GAMS model library that demonstrates this).
This is not very elegant, but if you really need it this would do the trick.
Hope this helps,
Michael Bussieck  GAMS World Administrator
On Sun, Nov 18, 2012 at 9:45 PM, Tavallali
Dear all
I guess I am repeating a common question, though I could not find an answer to.
Is that possible to get the Jacobian of the model at the optimal conditions? Is there any attribute for the constraints that can help reporting the derivatives with respect to various variables?
I hope GAMS can help on that. I appreciate your responses.
Regards

Ù…ØÙ…Ø¯ ØµØ§Ø¯Ù‚ ØªÙˆÙ„Ù‘Ù„ÛŒ
Mohammad Sadegh Tavallali
National University of Singapore

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Michael R. Bussieck, Ph.D.
Fon/Fax: +1 202 3420180/1 (USA) +49 221 9499170/1 (Germany)
www.gams.com

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
Re: Jacobian at optimal condition
Frank,
Michael pointed out a way to get the Jacobian matrix for the model at
the solution point. The entries of the Jacobian measure the
sensitivity of the equation levels wrt the variables, i.e. df/dx.
It sounds like you want to get the sensitivities of the optimal
variables wrt the model parameters, e.g. dx/dc for some variable x
and GAMS scalar c. This is a very different thing. For simplicity,
consider the case of an LP. We can divide this task into two parts
using the chain rule:
dx/dc = sum{(i,j), dx/dA(i,j) * dA(i,j)/dc}, where (i,j) sums over
the LP constraint matrix.
The sensitivities dx/dA(i,j) are available and there are examples for
how to get them, e.g. check
http://support.gams.com/doku.php?id=solver:sensitivity_analysis_with_gams_cplex
But there is no way to get the sensitivites of the LP constraint
matrix to the model parameters. To take an extreme example, you could
have a loop in GAMS that computes parameter D depending on scalar c.
It would take lots of time and memory to maintain the required
dependency information in this and other cases.
I think the best that one can do is use parameters directly in the
model, or in a simple enough way so that you know what dA(i,j)/dc is,
since you are responsible for providing that information.
HTH,
Steve
On Mon, Nov 19, 2012 at 12:03 PM, Frank Ward wrote:
> > Michael,
> >
> >
> >
> > Thanks for your note to Mohammad. Your method seems like a way to discover
> > something very valuable indeed. Does that method produce numerical results
> > for the partial derivative of each (dependent) variable with respect to
> > changes in each parameter? That is quite a matrix indeed. It could be a
> > very powerful and fast way conduct a sensitivity analysis. It tells the
> > modeler the sensitivity of each variable with respect to changes in each
> > assumption (parameter).
> >
> >
> >
> > Many people have asked me about that information in recent years. Of
> > course, theyâ€™re asking for much more than simple shadow prices (marginal).
> > It would sure be nice to give them a â€˜yesâ€™ answer in the future.
> >
> >
> >
> > Thanks for checking.
> >
> >
> >
> > Frank Ward
> >
> >
> >
> >
> >
> > From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On
> > Behalf Of Michael Bussieck
> > Sent: Monday, November 19, 2012 7:45 AM
> > To: gamsworld@googlegroups.com
> > Subject: Re: Jacobian at optimal condition
> >
> >
> >
> > Mohammad,
> >
> > GAMS does not have the gradient information readily available inside the
> > GAMS language. To access the gradient info you need access to the Jacobi
> > MATRIX. This does only exist when GAMS communicates with the solver. There
> > is a trick to get this Jacobi "matrix". This goes via the scalar model
> > Convert (or ConvertD) looks at. Basically you can easily get the Jacobian
> > via the solver ConvertD using option "jacobian". This gives you a two
> > dimensional parameter A(i,j) with i = e1,e2,e3,... and j=x1,x2,x3,... in a
> > GDX file jacobian.gdx. With the help of some name mapping you can map you
> > original variables and equations into the e1,e2,... and x1,x2,... space. For
> > that you declare for each variable and equation symbol in your model a set
> > varname_vm(j,original index space) and equname_em(i,original index space).
> > The content for these symbols is created by a ConvertD option called
> > dictmap. Having the maps and the Jacobian A you can map the relevant part of
> > the Jacobian into your name space. I have attached an example (weapons from
> > the GAMS model library that demonstrates this).
> >
> > This is not very elegant, but if you really need it this would do the trick.
> >
> > Hope this helps,
> > Michael Bussieck  GAMS World Administrator
> >
> > On Sun, Nov 18, 2012 at 9:45 PM, Tavallali
> > wrote:
> >
> > Dear all
> > I guess I am repeating a common question, though I could not find an answer
> > to.
> >
> > Is that possible to get the Jacobian of the model at the optimal conditions?
> > Is there any attribute for the constraints that can help reporting the
> > derivatives with respect to various variables?
> >
> > I hope GAMS can help on that. I appreciate your responses.
> > Regards
> >
> > 
> > Ù…ØÙ…Ø¯ ØµØ§Ø¯Ù‚ ØªÙˆÙ„Ù‘Ù„ÛŒ
> > Mohammad Sadegh Tavallali
> >
> > National University of Singapore
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
> >
> >
> >
> >
> > 
> > Michael R. Bussieck, Ph.D.
> > Fon/Fax: +1 202 3420180/1 (USA) +49 221 9499170/1 (Germany)
> > www.gams.com
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
 Steven Dirkse, Ph.D. GAMS Development Corp., Washington DC Voice: (202)3420180 Fax: (202)3420181 sdirkse@gams.com http://www.gams.com
Michael pointed out a way to get the Jacobian matrix for the model at
the solution point. The entries of the Jacobian measure the
sensitivity of the equation levels wrt the variables, i.e. df/dx.
It sounds like you want to get the sensitivities of the optimal
variables wrt the model parameters, e.g. dx/dc for some variable x
and GAMS scalar c. This is a very different thing. For simplicity,
consider the case of an LP. We can divide this task into two parts
using the chain rule:
dx/dc = sum{(i,j), dx/dA(i,j) * dA(i,j)/dc}, where (i,j) sums over
the LP constraint matrix.
The sensitivities dx/dA(i,j) are available and there are examples for
how to get them, e.g. check
http://support.gams.com/doku.php?id=solver:sensitivity_analysis_with_gams_cplex
But there is no way to get the sensitivites of the LP constraint
matrix to the model parameters. To take an extreme example, you could
have a loop in GAMS that computes parameter D depending on scalar c.
It would take lots of time and memory to maintain the required
dependency information in this and other cases.
I think the best that one can do is use parameters directly in the
model, or in a simple enough way so that you know what dA(i,j)/dc is,
since you are responsible for providing that information.
HTH,
Steve
On Mon, Nov 19, 2012 at 12:03 PM, Frank Ward
> > Michael,
> >
> >
> >
> > Thanks for your note to Mohammad. Your method seems like a way to discover
> > something very valuable indeed. Does that method produce numerical results
> > for the partial derivative of each (dependent) variable with respect to
> > changes in each parameter? That is quite a matrix indeed. It could be a
> > very powerful and fast way conduct a sensitivity analysis. It tells the
> > modeler the sensitivity of each variable with respect to changes in each
> > assumption (parameter).
> >
> >
> >
> > Many people have asked me about that information in recent years. Of
> > course, theyâ€™re asking for much more than simple shadow prices (marginal).
> > It would sure be nice to give them a â€˜yesâ€™ answer in the future.
> >
> >
> >
> > Thanks for checking.
> >
> >
> >
> > Frank Ward
> >
> >
> >
> >
> >
> > From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On
> > Behalf Of Michael Bussieck
> > Sent: Monday, November 19, 2012 7:45 AM
> > To: gamsworld@googlegroups.com
> > Subject: Re: Jacobian at optimal condition
> >
> >
> >
> > Mohammad,
> >
> > GAMS does not have the gradient information readily available inside the
> > GAMS language. To access the gradient info you need access to the Jacobi
> > MATRIX. This does only exist when GAMS communicates with the solver. There
> > is a trick to get this Jacobi "matrix". This goes via the scalar model
> > Convert (or ConvertD) looks at. Basically you can easily get the Jacobian
> > via the solver ConvertD using option "jacobian". This gives you a two
> > dimensional parameter A(i,j) with i = e1,e2,e3,... and j=x1,x2,x3,... in a
> > GDX file jacobian.gdx. With the help of some name mapping you can map you
> > original variables and equations into the e1,e2,... and x1,x2,... space. For
> > that you declare for each variable and equation symbol in your model a set
> > varname_vm(j,original index space) and equname_em(i,original index space).
> > The content for these symbols is created by a ConvertD option called
> > dictmap. Having the maps and the Jacobian A you can map the relevant part of
> > the Jacobian into your name space. I have attached an example (weapons from
> > the GAMS model library that demonstrates this).
> >
> > This is not very elegant, but if you really need it this would do the trick.
> >
> > Hope this helps,
> > Michael Bussieck  GAMS World Administrator
> >
> > On Sun, Nov 18, 2012 at 9:45 PM, Tavallali
> > wrote:
> >
> > Dear all
> > I guess I am repeating a common question, though I could not find an answer
> > to.
> >
> > Is that possible to get the Jacobian of the model at the optimal conditions?
> > Is there any attribute for the constraints that can help reporting the
> > derivatives with respect to various variables?
> >
> > I hope GAMS can help on that. I appreciate your responses.
> > Regards
> >
> > 
> > Ù…ØÙ…Ø¯ ØµØ§Ø¯Ù‚ ØªÙˆÙ„Ù‘Ù„ÛŒ
> > Mohammad Sadegh Tavallali
> >
> > National University of Singapore
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
> >
> >
> >
> >
> > 
> > Michael R. Bussieck, Ph.D.
> > Fon/Fax: +1 202 3420180/1 (USA) +49 221 9499170/1 (Germany)
> > www.gams.com
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
 Steven Dirkse, Ph.D. GAMS Development Corp., Washington DC Voice: (202)3420180 Fax: (202)3420181 sdirkse@gams.com http://www.gams.com
Re: Jacobian at optimal condition
Hi everyone.
I'm not quite sure if this will help you, anyhow it also can be interesting.
If you are trying to get the value of the sensitivities of the optimal value of a problem with respect to some parameters, you can try with the sensitivity analysis from the book of Fiacco "Introduction to Sensitivity and Stability Analysis in Nonlinear Programming "
As a summary of the method, the idea is to derive the KKT conditions of a given problem. The result of this derivation is a set of equations that can be solved for the value of the sensitivities. If you need the value of the local sensitivity dx/dc around a given optimal point, this set of equations becomes linear and it uses the Jacobian matrix evaluated at the solution (that Michael told you how to obtain it). This methodology is based in the assumption of strict complementarity, implying that the set of active constraints remains unchanged around the optimal solution. If this is not the case, the group of Professor L. Biegler proposed several years ago an extension to take into account the possibility of changes in the set of active constraints based in solving a QP, that also has been employed by the group pf Professor W. Marquardt in the context of dynamic optimization.
The references that might be useful are:
 Fiacco, A. V. (1983). Introduction to Sensitivity and Stability Analysis in Nonlinear Programming: Elsevier Science.
 Ganesh, N., & Biegler, L. T. (1987). A reduced hessian strategy for sensitivity analysis of optimal flowsheets. AIChE Journal, 33, 282296.
 Kadam, J. V., & Marquardt, W. (2004). SENSITIVITYBASED SOLUTION UPDATES IN CLOSEDLOOP DYNAMIC OPTIMIZATION. In DYCOPS 7. Cambridge, USA.
I really hope this helps,
Best Regards.
2012/11/21 Steven Dirkse
Frank,
Michael pointed out a way to get the Jacobian matrix for the model at
the solution point. The entries of the Jacobian measure the
sensitivity of the equation levels wrt the variables, i.e. df/dx.
It sounds like you want to get the sensitivities of the optimal
variables wrt the model parameters, e.g. dx/dc for some variable x
and GAMS scalar c. This is a very different thing. For simplicity,
consider the case of an LP. We can divide this task into two parts
using the chain rule:
dx/dc = sum{(i,j), dx/dA(i,j) * dA(i,j)/dc}, where (i,j) sums over
the LP constraint matrix.
The sensitivities dx/dA(i,j) are available and there are examples for
how to get them, e.g. check
http://support.gams.com/doku.php?id=solver:sensitivity_analysis_with_gams_cplex
But there is no way to get the sensitivites of the LP constraint
matrix to the model parameters. To take an extreme example, you could
have a loop in GAMS that computes parameter D depending on scalar c.
It would take lots of time and memory to maintain the required
dependency information in this and other cases.
I think the best that one can do is use parameters directly in the
model, or in a simple enough way so that you know what dA(i,j)/dc is,
since you are responsible for providing that information.
HTH,
Steve
On Mon, Nov 19, 2012 at 12:03 PM, Frank Ward
> Michael,
>
>
>
> Thanks for your note to Mohammad. Your method seems like a way to discover
> something very valuable indeed. Does that method produce numerical results
> for the partial derivative of each (dependent) variable with respect to
> changes in each parameter? That is quite a matrix indeed. It could be a
> very powerful and fast way conduct a sensitivity analysis. It tells the
> modeler the sensitivity of each variable with respect to changes in each
> assumption (parameter).
>
>
>
> Many people have asked me about that information in recent years. Of
> course, theyâ€™re asking for much more than simple shadow prices (marginal).
> It would sure be nice to give them a â€˜yesâ€™ answer in the future.
>
>
>
> Thanks for checking.
>
>
>
> Frank Ward
>
>
>
>
>
> From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On
> Behalf Of Michael Bussieck
> Sent: Monday, November 19, 2012 7:45 AM
> To: gamsworld@googlegroups.com
> Subject: Re: Jacobian at optimal condition
>
>
>
> Mohammad,
>
> GAMS does not have the gradient information readily available inside the
> GAMS language. To access the gradient info you need access to the Jacobi
> MATRIX. This does only exist when GAMS communicates with the solver. There
> is a trick to get this Jacobi "matrix". This goes via the scalar model
> Convert (or ConvertD) looks at. Basically you can easily get the Jacobian
> via the solver ConvertD using option "jacobian". This gives you a two
> dimensional parameter A(i,j) with i = e1,e2,e3,... and j=x1,x2,x3,... in a
> GDX file jacobian.gdx. With the help of some name mapping you can map you
> original variables and equations into the e1,e2,... and x1,x2,... space. For
> that you declare for each variable and equation symbol in your model a set
> varname_vm(j,original index space) and equname_em(i,original index space).
> The content for these symbols is created by a ConvertD option called
> dictmap. Having the maps and the Jacobian A you can map the relevant part of
> the Jacobian into your name space. I have attached an example (weapons from
> the GAMS model library that demonstrates this).
>
> This is not very elegant, but if you really need it this would do the trick.
>
> Hope this helps,
> Michael Bussieck  GAMS World Administrator
>
> On Sun, Nov 18, 2012 at 9:45 PM, Tavallali
> wrote:
>
> Dear all
> I guess I am repeating a common question, though I could not find an answer
> to.
>
> Is that possible to get the Jacobian of the model at the optimal conditions?
> Is there any attribute for the constraints that can help reporting the
> derivatives with respect to various variables?
>
> I hope GAMS can help on that. I appreciate your responses.
> Regards
>
> 
> Ù…ØÙ…Ø¯ ØµØ§Ø¯Ù‚ ØªÙˆÙ„Ù‘Ù„ÛŒ
> Mohammad Sadegh Tavallali
>
> National University of Singapore
>
> 
> "gamsworld" group.
> To post to this group, send email to gamsworld@googlegroups.com.
> To unsubscribe from this group, send email to
> gamsworld+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/gamsworld?hl=en.
>
>
>
>
> 
> Michael R. Bussieck, Ph.D.
> Fon/Fax: +1 202 3420180/1 (USA) +49 221 9499170/1 (Germany)
> www.gams.com
>
> 
> "gamsworld" group.
> To post to this group, send email to gamsworld@googlegroups.com.
> To unsubscribe from this group, send email to
> gamsworld+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/gamsworld?hl=en.
>
> 
> "gamsworld" group.
> To post to this group, send email to gamsworld@googlegroups.com.
> To unsubscribe from this group, send email to
> gamsworld+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/gamsworld?hl=en.

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)3420180 Fax: (202)3420181
sdirkse@gams.com
http://www.gams.com

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Daniel AndrÃ©s Navia LÃ³pez
Ingeniero Civil QuÃmico
Mg.Sc.Ciencias de la IngenierÃa, MenciÃ³n IngenierÃa QuÃmica
MÃ¡ster en InvestigaciÃ³n en IngenierÃa de Procesos y Sistemas
https://sites.google.com/site/dnavialopez/

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
Re: Jacobian at optimal condition
Replyto: gamsworld@googlegroups.com
Dear Daniel, Steven, and Michael
It seems that the Jacobian matrix defined as the table of impacts of changes in each endogenous variable with respect to each parameter is too ambitious to seek. What I sometimes do is to add a set element for each parameter I want to vary. Then we simply run the model for each of those set elements. This produces an ordinary sensitivity analysis of the sort that can provide most of what we need.
Thanks to you all for your insights
Frank
Sent from my iPhone
On Nov 22, 2012, at 12:35 AM, "Daniel Navia LÃ³pez" wrote:
> Hi everyone.
> I'm not quite sure if this will help you, anyhow it also can be interesting.
>
> If you are trying to get the value of the sensitivities of the optimal value of a problem with respect to some parameters, you can try with the sensitivity analysis from the book of Fiacco "Introduction to Sensitivity and Stability Analysis in Nonlinear Programming "
>
> As a summary of the method, the idea is to derive the KKT conditions of a given problem. The result of this derivation is a set of equations that can be solved for the value of the sensitivities. If you need the value of the local sensitivity dx/dc around a given optimal point, this set of equations becomes linear and it uses the Jacobian matrix evaluated at the solution (that Michael told you how to obtain it). This methodology is based in the assumption of strict complementarity, implying that the set of active constraints remains unchanged around the optimal solution. If this is not the case, the group of Professor L. Biegler proposed several years ago an extension to take into account the possibility of changes in the set of active constraints based in solving a QP, that also has been employed by the group pf Professor W. Marquardt in the context of dynamic optimization.
>
> The references that might be useful are:
>
>  Fiacco, A. V. (1983). Introduction to Sensitivity and Stability Analysis in Nonlinear Programming: Elsevier Science.
>
>  Ganesh, N., & Biegler, L. T. (1987). A reduced hessian strategy for sensitivity analysis of optimal flowsheets. AIChE Journal, 33, 282296.
>
>  Kadam, J. V., & Marquardt, W. (2004). SENSITIVITYBASED SOLUTION UPDATES IN CLOSEDLOOP DYNAMIC OPTIMIZATION. In DYCOPS 7. Cambridge, USA.
>
> I really hope this helps,
>
> Best Regards.
>
>
>
>
>
>
> 2012/11/21 Steven Dirkse
>
> Frank,
>
> Michael pointed out a way to get the Jacobian matrix for the model at
> the solution point. The entries of the Jacobian measure the
> sensitivity of the equation levels wrt the variables, i.e. df/dx.
>
> It sounds like you want to get the sensitivities of the optimal
> variables wrt the model parameters, e.g. dx/dc for some variable x
> and GAMS scalar c. This is a very different thing. For simplicity,
> consider the case of an LP. We can divide this task into two parts
> using the chain rule:
>
> dx/dc = sum{(i,j), dx/dA(i,j) * dA(i,j)/dc}, where (i,j) sums over
> the LP constraint matrix.
>
> The sensitivities dx/dA(i,j) are available and there are examples for
> how to get them, e.g. check
> http://support.gams.com/doku.php?id=solver:sensitivity_analysis_with_gams_cplex
>
> But there is no way to get the sensitivites of the LP constraint
> matrix to the model parameters. To take an extreme example, you could
> have a loop in GAMS that computes parameter D depending on scalar c.
> It would take lots of time and memory to maintain the required
> dependency information in this and other cases.
>
> I think the best that one can do is use parameters directly in the
> model, or in a simple enough way so that you know what dA(i,j)/dc is,
> since you are responsible for providing that information.
>
> HTH,
>
> Steve
>
>
>
> On Mon, Nov 19, 2012 at 12:03 PM, Frank Ward wrote:
> > Michael,
> >
> >
> >
> > Thanks for your note to Mohammad. Your method seems like a way to discover
> > something very valuable indeed. Does that method produce numerical results
> > for the partial derivative of each (dependent) variable with respect to
> > changes in each parameter? That is quite a matrix indeed. It could be a
> > very powerful and fast way conduct a sensitivity analysis. It tells the
> > modeler the sensitivity of each variable with respect to changes in each
> > assumption (parameter).
> >
> >
> >
> > Many people have asked me about that information in recent years. Of
> > course, theyâ€™re asking for much more than simple shadow prices (marginal).
> > It would sure be nice to give them a â€˜yesâ€™ answer in the future.
> >
> >
> >
> > Thanks for checking.
> >
> >
> >
> > Frank Ward
> >
> >
> >
> >
> >
> > From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On
> > Behalf Of Michael Bussieck
> > Sent: Monday, November 19, 2012 7:45 AM
> > To: gamsworld@googlegroups.com
> > Subject: Re: Jacobian at optimal condition
> >
> >
> >
> > Mohammad,
> >
> > GAMS does not have the gradient information readily available inside the
> > GAMS language. To access the gradient info you need access to the Jacobi
> > MATRIX. This does only exist when GAMS communicates with the solver. There
> > is a trick to get this Jacobi "matrix". This goes via the scalar model
> > Convert (or ConvertD) looks at. Basically you can easily get the Jacobian
> > via the solver ConvertD using option "jacobian". This gives you a two
> > dimensional parameter A(i,j) with i = e1,e2,e3,... and j=x1,x2,x3,... in a
> > GDX file jacobian.gdx. With the help of some name mapping you can map you
> > original variables and equations into the e1,e2,... and x1,x2,... space. For
> > that you declare for each variable and equation symbol in your model a set
> > varname_vm(j,original index space) and equname_em(i,original index space).
> > The content for these symbols is created by a ConvertD option called
> > dictmap. Having the maps and the Jacobian A you can map the relevant part of
> > the Jacobian into your name space. I have attached an example (weapons from
> > the GAMS model library that demonstrates this).
> >
> > This is not very elegant, but if you really need it this would do the trick.
> >
> > Hope this helps,
> > Michael Bussieck  GAMS World Administrator
> >
> > On Sun, Nov 18, 2012 at 9:45 PM, Tavallali
> > wrote:
> >
> > Dear all
> > I guess I am repeating a common question, though I could not find an answer
> > to.
> >
> > Is that possible to get the Jacobian of the model at the optimal conditions?
> > Is there any attribute for the constraints that can help reporting the
> > derivatives with respect to various variables?
> >
> > I hope GAMS can help on that. I appreciate your responses.
> > Regards
> >
> > 
> > Ù…ØÙ…Ø¯ ØµØ§Ø¯Ù‚ ØªÙˆÙ„Ù‘Ù„ÛŒ
> > Mohammad Sadegh Tavallali
> >
> > National University of Singapore
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
> >
> >
> >
> >
> > 
> > Michael R. Bussieck, Ph.D.
> > Fon/Fax: +1 202 3420180/1 (USA) +49 221 9499170/1 (Germany)
> > www.gams.com
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
>
>
>
> 
> Steven Dirkse, Ph.D.
> GAMS Development Corp., Washington DC
> Voice: (202)3420180 Fax: (202)3420181
> sdirkse@gams.com
> http://www.gams.com
>
> 
> To post to this group, send email to gamsworld@googlegroups.com.
> To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
>
>
>
>
> 
> Daniel AndrÃ©s Navia LÃ³pez
> Ingeniero Civil QuÃmico
> Mg.Sc.Ciencias de la IngenierÃa, MenciÃ³n IngenierÃa QuÃmica
> MÃ¡ster en InvestigaciÃ³n en IngenierÃa de Procesos y Sistemas
> https://sites.google.com/site/dnavialopez/
>
>
> 
> To post to this group, send email to gamsworld@googlegroups.com.
> To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
Dear Daniel, Steven, and Michael
It seems that the Jacobian matrix defined as the table of impacts of changes in each endogenous variable with respect to each parameter is too ambitious to seek. What I sometimes do is to add a set element for each parameter I want to vary. Then we simply run the model for each of those set elements. This produces an ordinary sensitivity analysis of the sort that can provide most of what we need.
Thanks to you all for your insights
Frank
Sent from my iPhone
On Nov 22, 2012, at 12:35 AM, "Daniel Navia LÃ³pez"
> Hi everyone.
> I'm not quite sure if this will help you, anyhow it also can be interesting.
>
> If you are trying to get the value of the sensitivities of the optimal value of a problem with respect to some parameters, you can try with the sensitivity analysis from the book of Fiacco "Introduction to Sensitivity and Stability Analysis in Nonlinear Programming "
>
> As a summary of the method, the idea is to derive the KKT conditions of a given problem. The result of this derivation is a set of equations that can be solved for the value of the sensitivities. If you need the value of the local sensitivity dx/dc around a given optimal point, this set of equations becomes linear and it uses the Jacobian matrix evaluated at the solution (that Michael told you how to obtain it). This methodology is based in the assumption of strict complementarity, implying that the set of active constraints remains unchanged around the optimal solution. If this is not the case, the group of Professor L. Biegler proposed several years ago an extension to take into account the possibility of changes in the set of active constraints based in solving a QP, that also has been employed by the group pf Professor W. Marquardt in the context of dynamic optimization.
>
> The references that might be useful are:
>
>  Fiacco, A. V. (1983). Introduction to Sensitivity and Stability Analysis in Nonlinear Programming: Elsevier Science.
>
>  Ganesh, N., & Biegler, L. T. (1987). A reduced hessian strategy for sensitivity analysis of optimal flowsheets. AIChE Journal, 33, 282296.
>
>  Kadam, J. V., & Marquardt, W. (2004). SENSITIVITYBASED SOLUTION UPDATES IN CLOSEDLOOP DYNAMIC OPTIMIZATION. In DYCOPS 7. Cambridge, USA.
>
> I really hope this helps,
>
> Best Regards.
>
>
>
>
>
>
> 2012/11/21 Steven Dirkse
>
> Frank,
>
> Michael pointed out a way to get the Jacobian matrix for the model at
> the solution point. The entries of the Jacobian measure the
> sensitivity of the equation levels wrt the variables, i.e. df/dx.
>
> It sounds like you want to get the sensitivities of the optimal
> variables wrt the model parameters, e.g. dx/dc for some variable x
> and GAMS scalar c. This is a very different thing. For simplicity,
> consider the case of an LP. We can divide this task into two parts
> using the chain rule:
>
> dx/dc = sum{(i,j), dx/dA(i,j) * dA(i,j)/dc}, where (i,j) sums over
> the LP constraint matrix.
>
> The sensitivities dx/dA(i,j) are available and there are examples for
> how to get them, e.g. check
> http://support.gams.com/doku.php?id=solver:sensitivity_analysis_with_gams_cplex
>
> But there is no way to get the sensitivites of the LP constraint
> matrix to the model parameters. To take an extreme example, you could
> have a loop in GAMS that computes parameter D depending on scalar c.
> It would take lots of time and memory to maintain the required
> dependency information in this and other cases.
>
> I think the best that one can do is use parameters directly in the
> model, or in a simple enough way so that you know what dA(i,j)/dc is,
> since you are responsible for providing that information.
>
> HTH,
>
> Steve
>
>
>
> On Mon, Nov 19, 2012 at 12:03 PM, Frank Ward
> > Michael,
> >
> >
> >
> > Thanks for your note to Mohammad. Your method seems like a way to discover
> > something very valuable indeed. Does that method produce numerical results
> > for the partial derivative of each (dependent) variable with respect to
> > changes in each parameter? That is quite a matrix indeed. It could be a
> > very powerful and fast way conduct a sensitivity analysis. It tells the
> > modeler the sensitivity of each variable with respect to changes in each
> > assumption (parameter).
> >
> >
> >
> > Many people have asked me about that information in recent years. Of
> > course, theyâ€™re asking for much more than simple shadow prices (marginal).
> > It would sure be nice to give them a â€˜yesâ€™ answer in the future.
> >
> >
> >
> > Thanks for checking.
> >
> >
> >
> > Frank Ward
> >
> >
> >
> >
> >
> > From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On
> > Behalf Of Michael Bussieck
> > Sent: Monday, November 19, 2012 7:45 AM
> > To: gamsworld@googlegroups.com
> > Subject: Re: Jacobian at optimal condition
> >
> >
> >
> > Mohammad,
> >
> > GAMS does not have the gradient information readily available inside the
> > GAMS language. To access the gradient info you need access to the Jacobi
> > MATRIX. This does only exist when GAMS communicates with the solver. There
> > is a trick to get this Jacobi "matrix". This goes via the scalar model
> > Convert (or ConvertD) looks at. Basically you can easily get the Jacobian
> > via the solver ConvertD using option "jacobian". This gives you a two
> > dimensional parameter A(i,j) with i = e1,e2,e3,... and j=x1,x2,x3,... in a
> > GDX file jacobian.gdx. With the help of some name mapping you can map you
> > original variables and equations into the e1,e2,... and x1,x2,... space. For
> > that you declare for each variable and equation symbol in your model a set
> > varname_vm(j,original index space) and equname_em(i,original index space).
> > The content for these symbols is created by a ConvertD option called
> > dictmap. Having the maps and the Jacobian A you can map the relevant part of
> > the Jacobian into your name space. I have attached an example (weapons from
> > the GAMS model library that demonstrates this).
> >
> > This is not very elegant, but if you really need it this would do the trick.
> >
> > Hope this helps,
> > Michael Bussieck  GAMS World Administrator
> >
> > On Sun, Nov 18, 2012 at 9:45 PM, Tavallali
> > wrote:
> >
> > Dear all
> > I guess I am repeating a common question, though I could not find an answer
> > to.
> >
> > Is that possible to get the Jacobian of the model at the optimal conditions?
> > Is there any attribute for the constraints that can help reporting the
> > derivatives with respect to various variables?
> >
> > I hope GAMS can help on that. I appreciate your responses.
> > Regards
> >
> > 
> > Ù…ØÙ…Ø¯ ØµØ§Ø¯Ù‚ ØªÙˆÙ„Ù‘Ù„ÛŒ
> > Mohammad Sadegh Tavallali
> >
> > National University of Singapore
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
> >
> >
> >
> >
> > 
> > Michael R. Bussieck, Ph.D.
> > Fon/Fax: +1 202 3420180/1 (USA) +49 221 9499170/1 (Germany)
> > www.gams.com
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
> >
> > 
> > "gamsworld" group.
> > To post to this group, send email to gamsworld@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gamsworld+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/gamsworld?hl=en.
>
>
>
> 
> Steven Dirkse, Ph.D.
> GAMS Development Corp., Washington DC
> Voice: (202)3420180 Fax: (202)3420181
> sdirkse@gams.com
> http://www.gams.com
>
> 
> To post to this group, send email to gamsworld@googlegroups.com.
> To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
>
>
>
>
> 
> Daniel AndrÃ©s Navia LÃ³pez
> Ingeniero Civil QuÃmico
> Mg.Sc.Ciencias de la IngenierÃa, MenciÃ³n IngenierÃa QuÃmica
> MÃ¡ster en InvestigaciÃ³n en IngenierÃa de Procesos y Sistemas
> https://sites.google.com/site/dnavialopez/
>
>
> 
> To post to this group, send email to gamsworld@googlegroups.com.
> To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
Return to “Archive Google Group”
Who is online
Users browsing this forum: Bing [Bot] and 2 guests