001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.math.genetics;
018
019 /**
020 * A pair of {@link Chromosome} objects.
021 * @since 2.0
022 *
023 * @version $Revision: 811685 $ $Date: 2009-09-05 19:36:48 +0200 (sam. 05 sept. 2009) $
024 */
025 public class ChromosomePair {
026 /** the first chromosome in the pair. */
027 private final Chromosome first;
028
029 /** the second chromosome in the pair. */
030 private final Chromosome second;
031
032 /**
033 * Create a chromosome pair.
034 *
035 * @param c1 the first chromosome.
036 * @param c2 the second chromosome.
037 */
038 public ChromosomePair(final Chromosome c1, final Chromosome c2) {
039 super();
040 first = c1;
041 second = c2;
042 }
043
044 /**
045 * Access the first chromosome.
046 *
047 * @return the first chromosome.
048 */
049 public Chromosome getFirst() {
050 return first;
051 }
052
053 /**
054 * Access the second chromosome.
055 *
056 * @return the second chromosome.
057 */
058 public Chromosome getSecond() {
059 return second;
060 }
061
062 /**
063 * {@inheritDoc}
064 */
065 @Override
066 public String toString() {
067 return String.format("(%s,%s)", getFirst(), getSecond());
068 }
069 }