Min function implementation

335
6
Jump to solution
06-03-2014 02:13 AM
MarianaDanielová
New Contributor
Hi everybody,

I would like to to use min function in my .cga file which would assign parameter with the lowest value to an attribute.
Is there any way how to do this?

Thank you

Mary
0 Kudos
1 Solution

Accepted Solutions
MatthiasBuehler1
Frequent Contributor II
hi ..

I had one implementation, then one of the devs helped to simplify the code:
 attr minA = 3 attr minB = 50 attr minC = 2 attr minD = 12   findMin(valList, index, min) =  case (index < 0): min  else:   case(float(listItem(valList, index)) < min): findMin(valList, index-1, float(listItem(valList, index)))   else:                                        findMin(valList, index-1, min)     findMin(valList) = findMin(valList, listSize(valList)-1, float(listItem(valList, listSize(valList)-1)))  Shape -->  print (findMin(str(minA) + ";" + str(minB) + ";" +  str(minC) + ";" + str(minD) + ";") )




let me know if this works ..

m.

View solution in original post

0 Kudos
6 Replies
MatthiasBuehler1
Frequent Contributor II
hi..

please give me an example of what you need.


there's ways to do this, but I need a bit preciser description. ok ? :)

matt
0 Kudos
MarianaDanielová
New Contributor
Hey Matt,

and thank you. I will try to describe it in more detail:

I am dealing with the visualization of uncertainty of the archaeological buildings. Simply written, the easiest method is to classify each parameter of the building with some uncertainty value (0,1). I am assuming that each parameter can have more possibilities. And each of these possibilities has different uncertainty value. Then the final value for the entire building would be the lowest (minimum) value from the uncertainty values of each parameters. I am trying to calculate the final value interactively as are the attributes changed in inspector.

@Group("Model options",0) @Order(1) @Range("DoorA","DoorB","DoorC")   
attr type_of_door   = "DoorA"

doorUncertainty    = 
 case "DoorA" : 0.8
 case "DoorB" : 0.9
 else : 0.7

@Group("Model options",0) @Order(2) @Range("WindowA","WindowB","WindowC")   
attr type_of_door   = "WindowA"

windowUncertainty   = 
 case "WindowA" : 1
 case "WindowB" : 0.6
 else : 0.9


@Group("Model options",0) @Order(3) @Range("WallColorA","WallColorB","WallColorC")   
attr type_of_door   = "WallColorA"

wallColorUncertainty  = 
 case "WallColorA" : 0.2
 case "WallColorB" : 0.5
 else : 0.8


Here I would need something like this:
buildingUncertainty = min(doorUncertainty, windowUncertainty, wallColorUncertainty)


I hope that my explanation is understandable :)

Thank you

Mary
0 Kudos
MatthiasBuehler1
Frequent Contributor II
do you need exactly 3 inputs to the min() function or 'n' ?


m.
0 Kudos
MarianaDanielová
New Contributor
I need 'n' inputs.. :)
0 Kudos
MatthiasBuehler1
Frequent Contributor II
hi ..

I had one implementation, then one of the devs helped to simplify the code:
 attr minA = 3 attr minB = 50 attr minC = 2 attr minD = 12   findMin(valList, index, min) =  case (index < 0): min  else:   case(float(listItem(valList, index)) < min): findMin(valList, index-1, float(listItem(valList, index)))   else:                                        findMin(valList, index-1, min)     findMin(valList) = findMin(valList, listSize(valList)-1, float(listItem(valList, listSize(valList)-1)))  Shape -->  print (findMin(str(minA) + ";" + str(minB) + ";" +  str(minC) + ";" + str(minD) + ";") )




let me know if this works ..

m.
0 Kudos
MarianaDanielová
New Contributor
Hi Matt,

It works! :)) Thank you so much for your help! I am so happy. And really, thank you, you are making my thesis a lot easier :)

Mary
0 Kudos