0
A - B
0   1  - new connection
0   0  - unchanged 
1   1  - unchanged
1   0  - disruption

I'm working on an industrial engineering modelling/coding project. I facing with data processing problem about the sample data above in an GAMS code.

I need a mathematical way of finding 1-0 patterns(which means disruptions in my model). I cannot use logical statements, like if, as they will affect my model and make it non-linear.

I tried

sum(i,a(i)-b(i))

it returned 0 as all the values cancelled each other. I need a pure mathematical expression to detect disruptions. Any ideas?

EDIT:Absolute value is also not acceptable.

ANSWER: After few hours of playing with numbers I came up with the following:

{ (a(i) + b(i)) - (a(i) * b(i)) - b(i) }

Thanks everyone for their contributions

Andrey Tyukin
  • 43,673
  • 4
  • 57
  • 93
Halox
  • 103
  • 1
  • 10
  • What language are you working with? Can we express the answer in terms of sets? – unutbu May 19 '13 at 13:47
  • I am pretty sure that you mean "arithmetic form", since "pure mathematical form" is either meaningless, or else validly include all expressions in mathematics, including logic, set theory and computer science, all of which have IF-type functions. – RBarryYoung May 19 '13 at 13:48
  • Question is fixed, please re-open. – Halox Jan 22 '14 at 18:06

2 Answers2

0

This should work:

sum(i,ABS(x(i)-y(i)))
RBarryYoung
  • 55,398
  • 14
  • 96
  • 137
-1

ak - old values,
bk - new values

Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64