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