Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fuzzy sets placing values 2

Status
Not open for further replies.

tig12

Programmer
Feb 27, 2007
20
GB
Hi,

Just wanted to know how to put some values in arrays.

i.e.

One would be car- ford, toyata, audi.

2nd one would be = long, round, large

The 3rd would be ={1.8,0.5,2.0}

Then by typing i.e. some values in like the third array you find out which car you were looking at.

----

How would I go about doing this or is there a website I could go on?

Thanks
 
Based on your example, I think you'd want to use maps.

You'll need to provide more information if you want a better answer.

-----------------------------------------
I cannot be bought. Find leasing information at
 
thank for the reply.

I think this may make it a bit clearer

A fruit example,

A group of fruits ={banana, mango}

Shape={long, round, large}

I think assign numbers i.e. a banana is 1.0 large, 0.0 round and 0.5 large.
--------------------------

Then someone can type in for the three shape choices i.e. I want something 0.9 large, 0.2 round and 0.3 large. Therefore he/she would get the closest thing which would be a banana in this case.

thanks
 
I think what I would do is this:

Calculate the sum of the absolute value of the differences
[1.0-.9] + [0.0-0.2] + [0.5-0.3] = 0.5

Store that value in a TreeMap.

Code:
TreeMap myMap = new TreeMap();
float calculatedSumofAbsoulteDifference;
String fruitName;
String answer;

/* for loop to calculate values*/
...
myMap.put(calculatedSumofAbsoluteDifference,fruitName);
....
/* end for loop*/
answer = myMap.get(myMap.firstKey());

There might be a better way, but I can't think of one at the moment.

-----------------------------------------
I cannot be bought. Find leasing information at
 
This should be asked in the Java forum.

I'd use a HashMap with key=name of fruit, value=array of three numbres.

I'd iterate calculating the differences and getting the min.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top