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 */
017package org.apache.commons.math4.legacy.optim.linear;
018
019import java.util.Arrays;
020import java.util.LinkedHashSet;
021import java.util.Set;
022import java.util.Collection;
023import java.util.Collections;
024
025import org.apache.commons.math4.legacy.optim.OptimizationData;
026
027/**
028 * Class that represents a set of {@link LinearConstraint linear constraints}.
029 *
030 * @since 3.1
031 */
032public class LinearConstraintSet implements OptimizationData {
033    /** Set of constraints. */
034    private final Set<LinearConstraint> linearConstraints = new LinkedHashSet<>();
035
036    /**
037     * Creates a set containing the given constraints.
038     *
039     * @param constraints Constraints.
040     */
041    public LinearConstraintSet(LinearConstraint... constraints) {
042        linearConstraints.addAll(Arrays.asList(constraints));
043    }
044
045    /**
046     * Creates a set containing the given constraints.
047     *
048     * @param constraints Constraints.
049     */
050    public LinearConstraintSet(Collection<LinearConstraint> constraints) {
051        linearConstraints.addAll(constraints);
052    }
053
054    /**
055     * Gets the set of linear constraints.
056     *
057     * @return the constraints.
058     */
059    public Collection<LinearConstraint> getConstraints() {
060        return Collections.unmodifiableSet(linearConstraints);
061    }
062}