Hi, this is my first question on Gams Forum.
I'm now modelling with gams, and having a trouble.
I have a variable name as A.
A(machine, time) only has value of -1, 0, 1 as its value.
Actually, 1 means 'turning on a machine', -1 means 'turning off machine' in my model.
I would like to extract only '1' and '-1' value from A.
I tried introducing new variables such as A_positive and A_negative.
Adding two more equations in my model.
A_positive(machine, time) = max(A(machine, time), 0);
A_negative(machine, time) = min(A(machine, time), 0);
But, it does not work with error message below.
"Endogenous function argument(s) not allowed in linear models"
Is there any other way that I can do this?
Thanks in advance.
Extract 1 from variables {-1, 0, 1}
Re: Extract 1 from variables {-1, 0, 1}
You could do some thing like this:
binary variables
switchOn 'turning machine on'
switchOff 'turning machine off'
;
equation switchCon;
switchCon .. switchOn + switchOff =L= 1;
With this, you have the option to do nothing or to switch on or switch off, but not switch on and off.
-Steve
binary variables
switchOn 'turning machine on'
switchOff 'turning machine off'
;
equation switchCon;
switchCon .. switchOn + switchOff =L= 1;
With this, you have the option to do nothing or to switch on or switch off, but not switch on and off.
-Steve
-
- User
- Posts: 15
- Joined: 4 years ago
Re: Extract 1 from variables {-1, 0, 1}
Thanks for your reply.
For me, I solve this trouble with this.
Binary variable switch_on
Binary variable switch_off
with two constraints
A = switch_on - switch_off;
switch_on + switch_off =L= 1;
then when A = 1, switch on always have value of 1 and value of 0 for switch_off.
Also, when A = 0, both value are 0.
When A=-1, switch_on 0, switch off 1.
For me, I solve this trouble with this.
Binary variable switch_on
Binary variable switch_off
with two constraints
A = switch_on - switch_off;
switch_on + switch_off =L= 1;
then when A = 1, switch on always have value of 1 and value of 0 for switch_off.
Also, when A = 0, both value are 0.
When A=-1, switch_on 0, switch off 1.