Unmatched variable not free or fixed

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Unmatched variable not free or fixed

Post by Archiver »



Hi,

I faced the error of "Unmatched variables not free or fixed". How can
I fix it?

Thanks,

Sonny
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Unmatched variable not free or fixed

Post by Archiver »

Sonny,

You should match the variable(s) referenced in the error message
explicitly to equations in the model statement. This is a good idea
even if you don't have bounds on a variable, since you'll be prepared
for the case where you add them.

The PATH solver manual contains a good discussion of what an MCP model
is and how matching comes into the picture.

-Steve

On Tue, Feb 17, 2009 at 1:45 AM, sonny wrote:
> >
> > Hi,
> >
> > I faced the error of "Unmatched variables not free or fixed". How can
> > I fix it?
> >
> > Thanks,
> >
> > Sonny
> > --~--~---------~--~----~------------~-------~--~----~
> > 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)342-0180 Fax: (202)342-0181 sdirkse@gams.com http://www.gams.com

Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Unmatched variable not free or fixed

Post by Archiver »



Thank you very much Steve.

On Feb 17, 5:45 pm, sonny wrote:
> > Hi,
> >
> > I faced the error of "Unmatched variables not free or fixed". How can
> > I fix it?
> >
> > Thanks,
> >
> > Sonny
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Unmatched variable not free or fixed

Post by Archiver »



Hi Steve,

Very helpful, but I have an equation that contains two variables I
want to solve under different closures. In a baseline, I want (e.g.) x
endogenous and y exogenous, and in the counterfactual I want to
reverse them. If I state eq.x or eq.y, one solution returns an
unmatched error. Can you advise?

Cheers,
David

On Feb 17, 8:43 pm, Steven Dirkse wrote:
> > Sonny,
> >
> > You should match the variable(s) referenced in the error message
> > explicitly to equations in the model statement. This is a good idea
> > even if you don't have bounds on a variable, since you'll be prepared
> > for the case where you add them.
> >
> > The PATH solver manual contains a good discussion of what an MCP model
> > is and how matching comes into the picture.
> >
> > -Steve
> >
> > On Tue, Feb 17, 2009 at 1:45 AM, sonny wrote:
> >
>> > > Hi,
> >
>> > > I faced the error of "Unmatchedvariables not free or fixed". How can
>> > > I fix it?
> >
>> > > Thanks,
> >
>> > > Sonny
> >
> > --
> > Steven Dirkse, Ph.D.
> > GAMS Development Corp., Washington DC
> > Voice:(202)342-0180 Fax: (202)342-0181
> > sdir...@gams.comhttp://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
-~----------~----~----~----~------~----~------~--~---


Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Unmatched variable not free or fixed

Post by Archiver »

David,

GAMS will treat all fixed (i.e. x.lo == x.up) variables that are not
explicitly matched as exogenous, to facilitate just this kind of
model. If the variable is free you can leave the equation as =e=. If
you want to match the equation and variable explicitly, you can do
that too.

variables x, y;
equation f;
f.. sqr(x) + sqr(y) =e= 5;

model hack / f /;

model base / f.x /;
model counter / f.y /;

y.fx = 1;
solve hack using mcp;
solve base using mcp;

y.lo = -inf;
y.up = inf;
x.fx = 2;

solve hack using mcp;
solve counter using mcp;


Probably your model contains lots of equations, so you can do

model core 'all the common stuff' / g1.z1, g2.z2, g3.z3 /;
model base / core, f.x /;
model counter / core, f.y /;

With the setup you describe, though, the benchmark check is not
complete, if you do one at all. You can check the benchmark for model
base but that doesn't necessary get you benchmark replication in model
counter. It looks suspect to me.

-Steve



On Mon, Mar 9, 2009 at 2:43 PM, dwrh wrote:
> >
> > Hi Steve,
> >
> > Very helpful, but I have an equation that contains two variables I
> > want to solve under different closures. In a baseline, I want (e.g.) x
> > endogenous and y exogenous, and in the counterfactual I want to
> > reverse them. If I state eq.x or eq.y, one solution returns an
> > unmatched error. Can you advise?
> >
> > Cheers,
> > David
> >
> > On Feb 17, 8:43 pm, Steven Dirkse wrote:
>> >> Sonny,
>> >>
>> >> You should match the variable(s) referenced in the error message
>> >> explicitly to equations in the model statement. This is a good idea
>> >> even if you don't have bounds on a variable, since you'll be prepared
>> >> for the case where you add them.
>> >>
>> >> The PATH solver manual contains a good discussion of what an MCP model
>> >> is and how matching comes into the picture.
>> >>
>> >> -Steve
>> >>
>> >> On Tue, Feb 17, 2009 at 1:45 AM, sonny wrote:
>> >>
>>> >> > Hi,
>> >>
>>> >> > I faced the error of "Unmatchedvariables not free or fixed". How can
>>> >> > I fix it?
>> >>
>>> >> > Thanks,
>> >>
>>> >> > Sonny
>> >>
>> >> --
>> >> Steven Dirkse, Ph.D.
>> >> GAMS Development Corp., Washington DC
>> >> Voice:(202)342-0180 Fax: (202)342-0181
>> >> sdir...@gams.comhttp://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
> > -~----------~----~----~----~------~----~------~--~---
> >
> >



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

Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Unmatched variable not free or fixed

Post by Archiver »



Hi Steve,

This is very helpful and quite ingenious, but my problem persists...
I thought PATH would simply count residual degrees of freedom,
regardless of their source, but I still get mismatch diagnostics like
those below. My problem is a little more subtle than I set forth in
the last example. Consider instead a case where I am making endogenous
a subset of a variable:

parameter a(n,m), b(m), c(n,m), d(m) ;
variable x(n,m), y(m) ;

equations
eq1.. a(n,m) =e= sum(m,x(n,m)**c(n,m)) ;
eq2.. z(m) =e= y(m)**2 ;

Two runs:
Baseline: Solve for x and z with y.fx(m)
Counterfactual: Solve for y, z, and the rest of x with x.fx("rowi",m)

The problem is if I run model1 / eq1.x, eq2.z / I can solve the
baseline,
but how do I specify the second model statement?

Cheers,
David


On Mar 9, 12:23 pm, Steven Dirkse wrote:
> > David,
> >
> > GAMS will treat all fixed (i.e. x.lo == x.up) variables that are not
> > explicitly matched as exogenous, to facilitate just this kind of
> > model. If the variable is free you can leave the equation as =e=. If
> > you want to match the equation and variable explicitly, you can do
> > that too.
> >
> > variables x, y;
> > equation f;
> > f.. sqr(x) + sqr(y) =e= 5;
> >
> > model hack / f /;
> >
> > model base / f.x /;
> > model counter / f.y /;
> >
> > y.fx = 1;
> > solve hack using mcp;
> > solve base using mcp;
> >
> > y.lo = -inf;
> > y.up = inf;
> > x.fx = 2;
> >
> > solve hack using mcp;
> > solve counter using mcp;
> >
> > Probably your model contains lots of equations, so you can do
> >
> > model core 'all the common stuff' / g1.z1, g2.z2, g3.z3 /;
> > model base / core, f.x /;
> > model counter / core, f.y /;
> >
> > With the setup you describe, though, the benchmark check is not
> > complete, if you do one at all. You can check the benchmark for model
> > base but that doesn't necessary get you benchmark replication in model
> > counter. It looks suspect to me.
> >
> > -Steve
> >
> >
> >
> > On Mon, Mar 9, 2009 at 2:43 PM, dwrh wrote:
> >
>> > > Hi Steve,
> >
>> > > Very helpful, but I have an equation that contains two variables I
>> > > want to solve under different closures. In a baseline, I want (e.g.) x
>> > > endogenous and y exogenous, and in the counterfactual I want to
>> > > reverse them. If I state eq.x or eq.y, one solution returns an
>> > >unmatchederror. Can you advise?
> >
>> > > Cheers,
>> > > David
> >
>> > > On Feb 17, 8:43 pm, Steven Dirkse wrote:
>>> > >> Sonny,
> >
>>> > >> You should match the variable(s) referenced in the error message
>>> > >> explicitly to equations in the model statement. This is a good idea
>>> > >> even if you don't have bounds on a variable, since you'll be prepared
>>> > >> for the case where you add them.
> >
>>> > >> The PATH solver manual contains a good discussion of what an MCP model
>>> > >> is and how matching comes into the picture.
> >
>>> > >> -Steve
> >
>>> > >> On Tue, Feb 17, 2009 at 1:45 AM, sonny wrote:
> >
>>>> > >> > Hi,
> >
>>>> > >> > I faced the error of "Unmatchedvariables not free or fixed". How can
>>>> > >> > I fix it?
> >
>>>> > >> > Thanks,
> >
>>>> > >> > Sonny
> >
>>> > >> --
>>> > >> Steven Dirkse, Ph.D.
>>> > >> GAMS Development Corp., Washington DC
>>> > >> Voice:(202)342-0180 Fax: (202)342-0181
>>> > >> sdir...@gams.comhttp://www.gams.com
> >
> > --
> > Steven Dirkse, Ph.D.
> > GAMS Development Corp., Washington DC
> > Voice:(202)342-0180 Fax: (202)342-0181
> > sdir...@gams.comhttp://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
-~----------~----~----~----~------~----~------~--~---


Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Unmatched variable not free or fixed

Post by Archiver »



Steve,

Sorry, the first example equation should read
eq1.. a(n,m) =e= x(n,m)**c(n,m) ;

On Mar 10, 10:43 am, dwrh wrote:
> > Hi Steve,
> >
> > This is very helpful and quite ingenious, but my problem persists...
> > I thought PATH would simply count residual degrees of freedom,
> > regardless of their source, but I still get mismatch diagnostics like
> > those below. My problem is a little more subtle than I set forth in
> > the last example. Consider instead a case where I am making endogenous
> > a subset of a variable:
> >
> > parameter a(n,m), b(m), c(n,m), d(m) ;
> > variable x(n,m), y(m) ;
> >
> > equations
> > eq1.. a(n,m) =e= sum(m,x(n,m)**c(n,m)) ;
> > eq2.. z(m) =e= y(m)**2 ;
> >
> > Two runs:
> > Baseline: Solve for x and z with y.fx(m)
> > Counterfactual: Solve for y, z, and the rest of x with x.fx("rowi",m)
> >
> > The problem is if I run model1 / eq1.x, eq2.z / I can solve the
> > baseline,
> > but how do I specify the second model statement?
> >
> > Cheers,
> > David
> >
> > On Mar 9, 12:23 pm, Steven Dirkse wrote:
> >
>> > > David,
> >
>> > > GAMS will treat all fixed (i.e. x.lo == x.up) variables that are not
>> > > explicitly matched as exogenous, to facilitate just this kind of
>> > > model. If the variable is free you can leave the equation as =e=. If
>> > > you want to match the equation and variable explicitly, you can do
>> > > that too.
> >
>> > > variables x, y;
>> > > equation f;
>> > > f.. sqr(x) + sqr(y) =e= 5;
> >
>> > > model hack / f /;
> >
>> > > model base / f.x /;
>> > > model counter / f.y /;
> >
>> > > y.fx = 1;
>> > > solve hack using mcp;
>> > > solve base using mcp;
> >
>> > > y.lo = -inf;
>> > > y.up = inf;
>> > > x.fx = 2;
> >
>> > > solve hack using mcp;
>> > > solve counter using mcp;
> >
>> > > Probably your model contains lots of equations, so you can do
> >
>> > > model core 'all the common stuff' / g1.z1, g2.z2, g3.z3 /;
>> > > model base / core, f.x /;
>> > > model counter / core, f.y /;
> >
>> > > With the setup you describe, though, the benchmark check is not
>> > > complete, if you do one at all. You can check the benchmark for model
>> > > base but that doesn't necessary get you benchmark replication in model
>> > > counter. It looks suspect to me.
> >
>> > > -Steve
> >
>> > > On Mon, Mar 9, 2009 at 2:43 PM, dwrh wrote:
> >
>>> > > > Hi Steve,
> >
>>> > > > Very helpful, but I have an equation that contains two variables I
>>> > > > want to solve under different closures. In a baseline, I want (e.g.) x
>>> > > > endogenous and y exogenous, and in the counterfactual I want to
>>> > > > reverse them. If I state eq.x or eq.y, one solution returns an
>>> > > >unmatchederror. Can you advise?
> >
>>> > > > Cheers,
>>> > > > David
> >
>>> > > > On Feb 17, 8:43 pm, Steven Dirkse wrote:
>>>> > > >> Sonny,
> >
>>>> > > >> You should match the variable(s) referenced in the error message
>>>> > > >> explicitly to equations in the model statement. This is a good idea
>>>> > > >> even if you don't have bounds on a variable, since you'll be prepared
>>>> > > >> for the case where you add them.
> >
>>>> > > >> The PATH solver manual contains a good discussion of what an MCP model
>>>> > > >> is and how matching comes into the picture.
> >
>>>> > > >> -Steve
> >
>>>> > > >> On Tue, Feb 17, 2009 at 1:45 AM, sonny wrote:
> >
>>>>> > > >> > Hi,
> >
>>>>> > > >> > I faced the error of "Unmatchedvariables not free or fixed". How can
>>>>> > > >> > I fix it?
> >
>>>>> > > >> > Thanks,
> >
>>>>> > > >> > Sonny
> >
>>>> > > >> --
>>>> > > >> Steven Dirkse, Ph.D.
>>>> > > >> GAMS Development Corp., Washington DC
>>>> > > >> Voice:(202)342-0180 Fax: (202)342-0181
>>>> > > >> sdir...@gams.comhttp://www.gams.com
> >
>> > > --
>> > > Steven Dirkse, Ph.D.
>> > > GAMS Development Corp., Washington DC
>> > > Voice:(202)342-0180 Fax: (202)342-0181
>> > > sdir...@gams.comhttp://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
-~----------~----~----~----~------~----~------~--~---


Post Reply