set value of variable to value from excel-data-import -> only if value exists otherwise don´t define

Dear Gams-Users,

i´m looking for a solution to the mentioned issue. I tried several versions of if-statements, the latest is written below.
Atm i´m getting the Error message: “Uncontrolled set entered as constant”. I have no idea why though… .can someone solve the knot in my mind?
And if someone has a solution or different idea for the problem i would really appreciate your hints!
Thanks a lot!

Parameters

binBHKW_1fx(t) “exceltab. binaervar.”;

binary variables

bin_BHKW_1(t) “BHKW an (1) aus (0)”;


$onecho > BHKW1bin_data.txt
par=binBHKW_1fx rng=BHKW_1!D1:E11 Cdim=1
$offecho

$call GDXXRW.EXE “\fs-2.uni-due.de\sfsoscha\Eigene Dateien\gamsdir\projdir\Gams_IN.xlsx” @BHKW1bin_data.txt
$GDXIN Gams_IN.gdx
$load binBHKW_1fx
$GDXIN

*=== Fix variables to values from Excel file

if( (binBHKW_1fx(t) = 0) or (binBHKW_1fx(t) = 1), bin_BHKW_1.FX(t) = binBHKW_1fx(t); else bin_BHKW_1.FX(t) = na; );


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/daRVP7bjq_gJ.
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.

Hi



You can’t do the if statement over the whole set in one line like:

if( (binBHKW_1fx(t) = 0) …)



use loop(t,

if statement

);



Cheers

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of filoufi
Sent: Saturday, November 24, 2012 5:51 PM
To: gamsworld@googlegroups.com
Subject: set value of variable to value from excel-data-import → only if value exists otherwise don´t define



Dear Gams-Users,



i´m looking for a solution to the mentioned issue. I tried several versions of if-statements, the latest is written below.

Atm i´m getting the Error message: “Uncontrolled set entered as constant”. I have no idea why though… .can someone solve the knot in my mind?

And if someone has a solution or different idea for the problem i would really appreciate your hints!

Thanks a lot!



Parameters



binBHKW_1fx(t) “exceltab. binaervar.”;



binary variables



bin_BHKW_1(t) “BHKW an (1) aus (0)”;





$onecho > BHKW1bin_data.txt

par=binBHKW_1fx rng=BHKW_1!D1:E11 Cdim=1

$offecho



$call GDXXRW.EXE “\fs-2.uni-due.de\sfsoscha\Eigene Dateien\gamsdir\projdir\Gams_IN.xlsx” @BHKW1bin_data.txt

$GDXIN Gams_IN.gdx

$load binBHKW_1fx

$GDXIN



*=== Fix variables to values from Excel file



if( (binBHKW_1fx(t) = 0) or (binBHKW_1fx(t) = 1), bin_BHKW_1.FX(t) = binBHKW_1fx(t); else bin_BHKW_1.FX(t) = na; );


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/daRVP7bjq_gJ.
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.

Thank you very much Renger!
This was definitely helpful and good to know!!

The solution to the problem I described did I get from the Gams-Support-Team-member Stefan:

You can write
bin_BHKW_1.FX(t)$(inBHKW_1fx(t) NA) = inBHKW_1fx(t);
to fix only variables where inBHKW_1fx(t) is not NA.


Thanks to both of you again :slight_smile:


Am Samstag, 24. November 2012 20:22:47 UTC+1 schrieb Renger van Nieuwkoop:

Hi



You can’t do the if statement over the whole set in one line like:

if( (binBHKW_1fx(t) = 0) …)



use loop(t,

if statement

);



Cheers

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of filoufi
Sent: Saturday, November 24, 2012 5:51 PM
To: gams...@googlegroups.com
Subject: set value of variable to value from excel-data-import → only if value exists otherwise don´t define



Dear Gams-Users,



i´m looking for a solution to the mentioned issue. I tried several versions of if-statements, the latest is written below.

Atm i´m getting the Error message: “Uncontrolled set entered as constant”. I have no idea why though… .can someone solve the knot in my mind?

And if someone has a solution or different idea for the problem i would really appreciate your hints!

Thanks a lot!



Parameters



binBHKW_1fx(t) “exceltab. binaervar.”;



binary variables



bin_BHKW_1(t) “BHKW an (1) aus (0)”;





$onecho > BHKW1bin_data.txt

par=binBHKW_1fx rng=BHKW_1!D1:E11 Cdim=1

$offecho



$call GDXXRW.EXE “\fs-2.uni-due.de\sfsoscha\Eigene Dateien\gamsdir\projdir\Gams_IN.xlsx” @BHKW1bin_data.txt

$GDXIN Gams_IN.gdx

$load binBHKW_1fx

$GDXIN



*=== Fix variables to values from Excel file



if( (binBHKW_1fx(t) = 0) or (binBHKW_1fx(t) = 1), bin_BHKW_1.FX(t) = binBHKW_1fx(t); else bin_BHKW_1.FX(t) = na; );


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/daRVP7bjq_gJ.
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 view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/dRq1UKzIkDgJ.
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.