?
Solved

stable marriage problem

Posted on 2003-02-19
13
Medium Priority
?
1,619 Views
Last Modified: 2012-05-04
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
Comment
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
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +1
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 7984597
Please post your code so far
0
 

Author Comment

by:n0152974
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

by:n0152974
ID: 7984640
AvailableIndex is a class containing a boolean representing available, int (index) and float (distance)
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Expert Comment

by:danBosh
ID: 7984800
all you need to do is bosh
0
 

Author Comment

by:n0152974
ID: 7986705
any other constuctive comments please?
0
 

Author Comment

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

Author Comment

by:n0152974
ID: 8003966
can any1 help me please?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8004039
0
 

Expert Comment

by:SpideyMod
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

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

Expert Comment

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

Expert Comment

by:SpideyMod
ID: 8105550
danBosh,
Thanks for responding.

SpideyMod
Community Support Moderator @Experts Exchange
0
 

Accepted Solution

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

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question