LightJason - AgentSpeak(L++)
IConstraint.java
Go to the documentation of this file.
1 /*
2  * @cond LICENSE
3  * ######################################################################################
4  * # LGPL License #
5  * # #
6  * # This file is part of the LightJason AgentSpeak(L++) #
7  * # Copyright (c) 2015-19, LightJason (info@lightjason.org) #
8  * # This program is free software: you can redistribute it and/or modify #
9  * # it under the terms of the GNU Lesser General Public License as #
10  * # published by the Free Software Foundation, either version 3 of the #
11  * # License, or (at your option) any later version. #
12  * # #
13  * # This program is distributed in the hope that it will be useful, #
14  * # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15  * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16  * # GNU Lesser General Public License for more details. #
17  * # #
18  * # You should have received a copy of the GNU Lesser General Public License #
19  * # along with this program. If not, see http://www.gnu.org/licenses/ #
20  * ######################################################################################
21  * @endcond
22  */
23 
24 package org.lightjason.agentspeak.action.builtin.math.linearprogram;
25 
26 import org.apache.commons.math3.optim.linear.Relationship;
30 
31 import javax.annotation.Nonnull;
32 import java.util.Locale;
33 
34 
38 public abstract class IConstraint extends IBuiltinAction
39 {
43  private static final long serialVersionUID = 1078912058401537801L;
44 
48  public IConstraint()
49  {
50  super( 3 );
51  }
52 
59  @Nonnull
60  protected final Relationship getRelation( @Nonnull final String p_symbol )
61  {
62  switch ( p_symbol.trim().toLowerCase( Locale.ROOT ) )
63  {
64  case "less":
65  case "less-equal":
66  case "leq":
67  case "<":
68  case "<=":
69  return Relationship.LEQ;
70 
71  case "greater":
72  case "greater-equal":
73  case "geq":
74  case ">":
75  case ">=":
76  return Relationship.GEQ;
77 
78  case "equal":
79  case "eq":
80  case "=":
81  case "==":
82  return Relationship.EQ;
83 
84  default:
85  throw new CIllegalArgumentException( CCommon.languagestring( IConstraint.class, "relation", p_symbol ) );
86  }
87  }
88 
89 }
base class of build-in actions for setting name by package/classname (without prefix character) ...
final Relationship getRelation( @Nonnull final String p_symbol)
returns the enum of a relationship by a string value
static< T > String languagestring(final T p_source, final String p_label, final Object... p_parameter)
returns the language depend string on any object