Solved

# stable marriage problem

Posted on 2003-02-19
Medium Priority
1,619 Views
I'm struggling to get the stable marriage problem solved in java. I have two arrays of point3d's and have a list of all the possible distances in rank order, but i can't get the algorithm to work. Can any1 help please
Cheers
0
Question by:n0152974
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 5
• 3
• 3
• +1

LVL 86

Expert Comment

ID: 7984597
0

Author Comment

ID: 7984628
public void stableMarriage()
{
AvailableIndex [] startAvailableIndex = new AvailableIndex[start.length];
for(int b = 0; b < startAvailableIndex.length; b++)
{
startAvailableIndex[b] = new AvailableIndex();
}
while(!allPaired(startAvailableIndex))
{
System.out.println("in while loop");
//pick 1st unpaired
int i = 0;
for(i=0;i<start.length;i++)
{
if(startAvailableIndex[i].index() == -1)
{
break;
}

}
PointDist temp;
if(startAvailableIndex[i].index == -1)
{
temp = lists[i][0]; //get first choice
}
else
{
temp = lists[i][startAvailableIndex[i].index()];
}
startAvailableIndex[i].increment();
//remove lists[i][0] and shift then all down
System.out.println("temp "+temp.toString());
if(temp.available()==true)
{
System.out.println(temp.toString());
if(temp.dist() <= start [i].distance( end[startAvailableIndex[i].index()] )  )
{
//makePair(start[i],temp);
startAvailableIndex[i].available = false;
}
else
{
//remain unpaired
//startAvailableIndex[i] = -1;
}
}
}
for(int b = 0; b < startAvailableIndex.length; b++)
{
System.out.println(startAvailableIndex[b].index());
}
}

public boolean allPaired(AvailableIndex [] temp)
{
System.out.println("All paired");
for(int b = 0; b < temp.length; b++)
{
if(temp[b].available() == true)
{
return false;
}
}
return true;
}
0

Author Comment

ID: 7984640
AvailableIndex is a class containing a boolean representing available, int (index) and float (distance)
0

Expert Comment

ID: 7984800
all you need to do is bosh
0

Author Comment

ID: 7986705
0

Author Comment

ID: 7993422
is it possible for me to do this problem or is another way needed?
0

Author Comment

ID: 8003966
0

LVL 86

Expert Comment

ID: 8004039
0

Expert Comment

ID: 8104364
A request for refund has been made.  Experts you have 72 hours to respond.

danBosh,
I have seen many of your responses that say "all you need to do is bosh".  If you have nothing professional or constructive to add to a question, do not post.  This will be your only warning.

SpideyMod
Community Support Moderator @Experts Exchange
0

Expert Comment

ID: 8105494
Sorry SideyMod, n0152974 is my flatmate, and the comment was only a joke
0

Expert Comment

ID: 8105495
Sorry SideyMod, n0152974 is my flatmate, and the comment was only a joke
0

Expert Comment

ID: 8105550
danBosh,
Thanks for responding.

SpideyMod
Community Support Moderator @Experts Exchange
0

Accepted Solution

SpideyMod earned 0 total points
ID: 8132680
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET â€¦
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be uâ€¦
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and â€¦
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompaâ€¦
###### Suggested Courses
Course of the Month9 days, 17 hours left to enroll