AnyLogic
Expand
Font size

Class Utilities

All Implemented Interfaces:
AgentConstants, EnvironmentConstants, UtilitiesMath, UtilitiesRandom, UtilitiesString, Serializable
Direct Known Subclasses:
Agent, Experiment

public abstract class Utilities
extends Presentable
implements EnvironmentConstants, AgentConstants, UtilitiesRandom, UtilitiesMath, UtilitiesString
This class provides a lot of commonly used functions and constants, including the probability distributions and mathematical functions. The class is a superclass for Agent and Experiment, so that its functions can be called without any prefixing from any code written by the user within those subclasses.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Field Summary

Modifier and TypeFieldDescription
static final intAM
Value of the getAmPm(Date) method indicating the period of the day from midnight to just before noon.
static final intAPRIL
Value of the getMonth(Date) method indicating the fourth month of the year in the Gregorian and Julian calendars.
static final intAUGUST
Value of the getMonth(Date) method indicating the eighth month of the year in the Gregorian and Julian calendars.
static final intDECEMBER
Value of the getMonth(Date) method indicating the twelfth month of the year in the Gregorian and Julian calendars.
static final intFEBRUARY
Value of the getMonth(Date) method indicating the second month of the year in the Gregorian and Julian calendars.
static final intFRIDAY
Value of the getDayOfWeek(Date) method indicating Friday.
static final intJANUARY
Value of the getMonth(Date) method indicating the first month of the year in the Gregorian and Julian calendars.
static final intJULY
Value of the getMonth(Date) method indicating the seventh month of the year in the Gregorian and Julian calendars.
static final intJUNE
Value of the getMonth(Date) method indicating the sixth month of the year in the Gregorian and Julian calendars.
static final LengthUnitsLENGTH_UNIT_CENTIMETER 
static final LengthUnitsLENGTH_UNIT_FOOT 
static final LengthUnitsLENGTH_UNIT_INCH 
static final LengthUnitsLENGTH_UNIT_KILOMETER 
static final LengthUnitsLENGTH_UNIT_METER 
static final LengthUnitsLENGTH_UNIT_MILE 
static final intMARCH
Value of the getMonth(Date) method indicating the third month of the year in the Gregorian and Julian calendars.
static final intMAY
Value of the getMonth(Date) method indicating the fifth month of the year in the Gregorian and Julian calendars.
static final intMONDAY
Value of the getDayOfWeek(Date) method indicating Monday.
static final intNOVEMBER
Value of the getMonth(Date) method indicating the eleventh month of the year in the Gregorian and Julian calendars.
static final intOCTOBER
Value of the getMonth(Date) method indicating the tenth month of the year in the Gregorian and Julian calendars.
static final intPM
Value of the getAmPm(Date) method indicating the period of the day from noon to just before midnight.
static final intSATURDAY
Value of the getDayOfWeek(Date) method indicating Saturday.
static final intSEPTEMBER
Value of the getMonth(Date) method indicating the ninth month of the year in the Gregorian and Julian calendars.
static final intSUNDAY
Value of the getDayOfWeek(Date) method indicating Sunday.
static final intTHURSDAY
Value of the getDayOfWeek(Date) method indicating Thursday.
static final longTIME_UNIT_DAY
One of the possible time units.
static final longTIME_UNIT_HOUR
One of the possible time units.
static final longTIME_UNIT_MILLISECOND
One of the possible time units.
static final longTIME_UNIT_MINUTE
One of the possible time units.
static final longTIME_UNIT_MONTH
One of the possible time units.
static final longTIME_UNIT_SECOND
One of the possible time units.
static final longTIME_UNIT_WEEK
One of the possible time units.
static final longTIME_UNIT_YEAR
One of the possible time units.
static final intTUESDAY
Value of the getDayOfWeek(Date) method indicating Tuesday.
static final intUNDECIMBER
Value of the getMonth(Date) method indicating the thirteenth month of the year.
static final intWEDNESDAY
Value of the getDayOfWeek(Date) method indicating Wednesday.

Fields inherited from interface com.anylogic.engine.AgentConstants

AGENT_ORIENTATION_FRONT, AGENT_ORIENTATION_LEFT, AGENT_ORIENTATION_REAR, AGENT_ORIENTATION_RIGHT, ALL, ALL_CONNECTED, ALL_NEIGHBORS, AREA_ACCESS_RESTRICTION_BY_CAPACITY, AREA_ACCESS_RESTRICTION_BY_CONDITION, AREA_ACCESS_RESTRICTION_BY_SCHEDULE, AREA_ACCESS_RESTRICTION_BY_THROUGHPUT, AREA_ACCESS_RESTRICTION_MANUAL, CENTIMETER, CONVEYOR_BACKWARD, CONVEYOR_CUSTOM_STATION_AGENT_LOCATION_CENTER, CONVEYOR_CUSTOM_STATION_AGENT_LOCATION_NEAR_CONVEYOR, CONVEYOR_CUSTOM_STATION_AGENT_LOCATION_RANDOM, CONVEYOR_FORWARD, CONVEYOR_SIMPLE_STATION_DELAY_TYPE_MANUAL, CONVEYOR_SIMPLE_STATION_DELAY_TYPE_TIMEOUT, CONVEYOR_TYPE_BELT, CONVEYOR_TYPE_CELL, CONVEYOR_TYPE_ROLLER, CUBIC_METER, CUBIC_METER_PER_SECOND, CUSTOM_COLOR_SCHEME, DAY, DEG_PER_SECOND, DEGREE, DENSITY_VALUE_MAX, DENSITY_VALUE_MEAN, EAST, ELEVATOR_DIRECTION_DOWN, ELEVATOR_DIRECTION_NONE, ELEVATOR_DIRECTION_UP, ELEVATOR_DOOR_FRONT, ELEVATOR_DOOR_REAR, ELEVATOR_DOORS_FRONT, ELEVATOR_DOORS_FRONT_REAR, ELEVATOR_DOORS_FRONT_REAR_XJAL, ELEVATOR_DOORS_FRONT_XJAL, ELEVATOR_MOVEMENT_BY_SPEED, ELEVATOR_MOVEMENT_BY_TIME_PER_LEVEL, ELEVATOR_STATE_FAILED, ELEVATOR_STATE_IDLE, ELEVATOR_STATE_LOADING, ELEVATOR_STATE_MOVING, ESCALATOR_STAY_ALL, ESCALATOR_WALK_ALL, ESCALATOR_WALK_ON_LEFT_SIDE, ESCALATOR_WALK_ON_RIGHT_SIDE, EVENT_TIMEOUT_MODE_CYCLIC, EVENT_TIMEOUT_MODE_ONCE, EVENT_TIMEOUT_MODE_USER, EXCEEDED_QUEUE_CROWD_ROUND_AT_THE_END, EXCEEDED_QUEUE_EXTEND_TO_THE_FREE_SPACE, EXT_AGENT_CONTINUOUS, EXT_AGENT_DISCRETE, EXT_AGENT_GIS, EXT_AGENT_INTERACTIVE, EXT_AGENT_NETWORK, EXT_ENTITY, EXT_ENVIRONMENT_CONTINUOUS, EXT_ENVIRONMENT_DISCRETE, EXT_ENVIRONMENT_GIS, EXT_ENVIRONMENT_INTERACTIVE, EXT_SPACE, FLOW_STATISTICS_BOTH, FLOW_STATISTICS_LEFT, FLOW_STATISTICS_RIGHT, FOOT, FPM, FPS, FPS_SQ, HOUR, INCH, JIB_CRANE_CAT_HEAD, JIB_CRANE_FLAT_TOP, JIB_CRANE_INDUSTRIAL, JIB_CRANE_MOVEMENT_CONCURRENT, JIB_CRANE_MOVEMENT_STEP_BY_STEP, KILOGRAM, KILOGRAM_PER_SECOND, KILOMETER, KN, KPH, LIFT_PLATFORM_FLAT, LIFT_PLATFORM_ROLLER, LIFT_SELECTION_MODE_COMPARISON, LIFT_SELECTION_MODE_FIFO, LIFT_SELECTION_MODE_PRIORITY, LINEAR_COLOR_SCHEME, LITER, LITER_PER_SECOND, LOGARITHMIC_COLOR_SCHEME, METER, MILE, MILLIMETER, MILLISECOND, MINUTE, MONTH, MPH, MPS, MPS_SQ, NAUTICAL_MILE, NORTH, NORTHEAST, NORTHWEST, OBJECT_3D_INTERNAL_LIGHTING_GLOBAL, OBJECT_3D_INTERNAL_LIGHTING_INSIDE, OBJECT_3D_INTERNAL_LIGHTING_OFF, OBJECT_3D_XYZ_AXIS_ORDER, OBJECT_3D_YZX_AXIS_ORDER, OBJECT_3D_ZXY_AXIS_ORDER, OIL_BARREL, OIL_BARREL_PER_SECOND, OVERHEAD_CRANE_BRIDGE, OVERHEAD_CRANE_GANTRY, OVERHEAD_CRANE_GIRDER_DOUBLE_TIE, OVERHEAD_CRANE_GIRDER_SINGLE_FLAT, OVERHEAD_CRANE_MOVEMENT_CONCURRENT, OVERHEAD_CRANE_MOVEMENT_INDEPENDENT_HOIST, OVERHEAD_CRANE_MOVEMENT_STEP_BY_STEP, PALLET_RACK_LEFT_TO_RIGHT, PALLET_RACK_NO_DIRECTION, PALLET_RACK_RIGHT_TO_LEFT, PALLET_RACK_SINGLE_AISLE_LEFT, PALLET_RACK_SINGLE_AISLE_RIGHT, PALLET_RACK_TWO_AISLES, PALLET_RACK_TWO_PALLET_RACKS, PARKING_LOT_PARALLEL, PARKING_LOT_PERPENDICULAR, PATH_CONVEYOR, PATH_DASHEDLINE, PATH_LINE, PATH_RAILROAD, PATH_ROAD, PEDESTRIAN_MAP_TYPE, PER_DAY, PER_HOUR, PER_MILLISECOND, PER_MINUTE, PER_MONTH, PER_SECOND, PER_WEEK, PER_YEAR, POSITION_CHOICE_ARRANGED, POSITION_CHOICE_BY_ATTRACTORS, POSITION_CHOICE_RANDOM, RACK_PLACEMENT_BACK_TO_BACK, RACK_PLACEMENT_STAND_ALONE, RACK_TYPE_DRIVE_IN, RACK_TYPE_FIFO_FLOW, RACK_TYPE_LIFO_FLOW, RACK_TYPE_SELECTIVE, RAD_PER_SECOND, RADIAN, RAILWAY_SWITCH_ALL_TO_ALL, RAILWAY_SWITCH_DOUBLE_SLIP, RAILWAY_SWITCH_SINGLE_SLIP, RANDOM, RANDOM_CONNECTED, RANDOM_NEIGHBOR, ROAD_LEFT_HAND, ROAD_LINE_DOUBLE, ROAD_LINE_DOUBLE_DASHED, ROAD_LINE_SINGLE, ROAD_LINE_SINGLE_DASHED, ROAD_RIGHT_HAND, RPM, SECOND, SERVICE_GROUP_BEHAVIOR_DEPENDS_ON_INCOMING_GROUP, SERVICE_GROUP_BEHAVIOR_SAME_FOR_ALL_GROUPS, SERVICE_GROUP_INDIVIDUAL_SERVING, SERVICE_GROUP_ONE_MEMBER_IS_SERVED_OTHERS_WAIT_IN_AREA, SERVICE_GROUP_ONE_MEMBER_IS_SERVED_OTHERS_WAIT_IN_QUEUE, SERVICE_QUEUE_CLOSEST_NON_EMPTY, SERVICE_QUEUE_CLOSEST_STRICT, SERVICE_QUEUE_CUSTOM, SERVICE_QUEUE_LONGEST, SERVICE_QUEUE_NEXT_ROUND_ROBIN, SERVICE_QUEUE_PRIORITY, SERVICE_TYPE_LINEAR, SERVICE_TYPE_POINT, SIGNAL_GREEN, SIGNAL_NONE, SIGNAL_RED, SIGNAL_YELLOW, SIMPLE_STATION_LOADING_MODE_AFTER_UNLOADING, SIMPLE_STATION_LOADING_MODE_SIMULTANEOUS_WITH_UNLOADING, SIMPLE_STATION_PROCESSING_WHEN_AGENT_ENTERS, SIMPLE_STATION_PROCESSING_WHEN_CAPACITY_FULL, SOUTH, SOUTHEAST, SOUTHWEST, SPACE_CONTINUOUS, SPACE_CONTINUOUS_2D, SPACE_DISCRETE, SPACE_DISCRETE_2D, SPACE_GIS, SPACE_UNDEFINED, SQ_CENTIMETER, SQ_FOOT, SQ_INCH, SQ_KILOMETER, SQ_METER, SQ_MILE, SQ_MILLIMETER, SQ_NAUTICAL_MILE, SQ_YARD, TON, TON_PER_SECOND, TRANSFER_MODE_AUTOMATIC, TRANSFER_MODE_MANUAL, TRANSPORTER_MAP_TYPE, TURN, TURN_STATION_MODE_ANGLE, TURN_STATION_MODE_ORIENTATION, WALL_FILL_HATCHING, WALL_FILL_NONE, WALL_FILL_SOLID, WEEK, WEST, WINDOW_3D_NAVIGATION_FULL, WINDOW_3D_NAVIGATION_LIMITED_TO_Z_ABOVE_ZERO, WINDOW_3D_NAVIGATION_NONE, WINDOW_3D_NAVIGATION_ROTATION_ONLY, YARD, YEAR

Fields inherited from interface com.anylogic.engine.UtilitiesMath

infinity

Fields inherited from interface com.anylogic.engine.UtilitiesRandom

RANDOM_BOUNDED_DISTRIBUTIONS_MAX_ITERATIONS

Constructor Summary

ConstructorDescription
Utilities() 

Method Summary

Modifier and TypeMethodDescription
static DateaddToDate(Date date, int timeUnit, double amount)
Returns the date, which will be after the given amount of timeUnits from the given date
e.g.
static DateaddToDate(Date date, TimeUnits timeUnit, double amount)
Returns the date, which will be after the given amount of timeUnits from the given date
e.g.
static doubleatan2fast(double y, double x)
Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).
static intbernoulli(double p, Random r)
Generates a sample of the Bernoulli distribution using the specified random number generator.
static doublebeta(double min, double max, double p, double q, double shift, double stretch, Random r)
Generates a sample of truncated Beta distribution using the specified random number generator.
Distribution beta(p, q, 0, 1) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval.
static doublebeta(double p, double q, double min, double max, Random r)
Generates a sample of the Beta distribution using the specified random number generator.
static doublebinomial(double min, double max, double p, double n, double shift, double stretch, Random r)
Generates a sample of truncated Binomial distribution using the specified random number generator.
Distribution binomial(p, n) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval.
static intbinomial(double p, int n, Random r)
Generates a sample of the Binomial distribution using the specified random number generator.
static StringbriefInfoOn(Object object)
Returns a brief one-line textual information on the given object.
<RT> RTcastNumberTypes(Number number, Class<RT> returnType) 
<RT> RTcastTypes(Object result, Class<RT> returnType)
Makes both implicit and explicit casts returnType might be equal to Object.class, then convertation will be done only based on result type like Timestamp -> Date
ObjectcastTypesBack(Object value) 
static doublecauchy(double lambda, double theta, Random r)
Generates a sample of the Cauchy distribution using the specified random number generator.
static doublechi2(double nu, double min, Random r)
Generates a sample of the Chi Squared distribution using the specified random number generator.
static MarkupSegment[]convertMarkupSegmentDescriptors_xjal(MarkupSegmentDescriptor[] descriptors)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
voidcopyToClipboard(String text)
Copies the given text to the system clipboard
Due to the security policy of the browser, the actual copying may be preceded by a prompt.
static voidcopyToClipboard(List<List<Object>> table)
Deprecated.
static voidcopyToClipboard(List<List<Object>> table, List<Integer> sqlTypes) 
TableElementDatabaseBuildercreateTableElementDatabaseBuilder() 
static float[]createTrajectoryGIS(double lonFrom, double latFrom, double lonTo, double latTo, int numberOfSegments)
Deprecated.
static URLcreateURL_xjal(String url)
Creates an URL object from the String representation
Datedate()
Returns the current model date with respect to the start time/date and the model time unit.
doubledateToTime(Date d)
Converts the given date to model time with respect to the start date, start time and model time unit settings
doubleday()
Returns a time value equal to 24-hour day according to the current time unit setting.
DeleteQuerydeleteFrom(com.querydsl.sql.RelationalPathBase<?> table)
Returns DeleteQuery that allows to build queries by chaining calls
static doubledifference(BasicDataSet ds1, BasicDataSet ds2)
Difference function which is always not-negative and reflects difference between 2 given data sets in their common arguments range
static doubledifference(BasicDataSet ds, TableFunction f)
Difference function which is always not-negative and reflects difference between given data set and table function in their common arguments range
doubledifferenceInCalendarUnits(TimeUnits timeUnit, double time1, double time2)
Returns the difference (time2 - time1) between two model dates (corresponding to the given model times) in the given time units.
Result is the number of date units that should be added to the model time time1 to obtain time2
The result may be negative and may have fractional part depending on the given dates.
static doubledifferenceInCalendarUnits(TimeUnits timeUnit, Date date1, Date date2)
Returns the difference (date2 - date1) between two dates in the given time units.
Result is the number of time units that should be added to date1 to obtain date2
The result may be negative and may have fractional part depending on the given dates.
doubledifferenceInDateUnits(int timeUnit, double time1, double time2)
Deprecated.
static doubledifferenceInDateUnits(int timeUnit, Date date1, Date date2)
Deprecated.
doubledifferenceInDateUnits(TimeUnits timeUnit, double time1, double time2)
static doubledifferenceInDateUnits(TimeUnits timeUnit, Date date1, Date date2)
Deprecated.
static doubledirToAngle(CellDirection dir)
Returns the angle value corresponding to the given direction
static DatedropTime(Date date)
This utility method drops time-of-the-day information and returns the date with the time 00:00:00.000
static doubleerlang(double beta, int m, double min, Random r)
Generates a sample of the Erlang distribution using the specified random number generator.
RuntimeExceptionerror(String errorText)
Signals an error during the model run by throwing a RuntimeException with errorText preceded by the agent full name.
RuntimeExceptionerror(String errorTextFormat, Object... args)
The same as error(String) but allows error format syntax like in String.format(String, Object...) method
abstract RuntimeExceptionerror(Throwable cause, String errorText)
Signals an error during the model run by throwing a RuntimeException with errorText preceded by the agent full name.
RuntimeExceptionerror(Throwable cause, String errorTextFormat, Object... args)
The same as error(String) but allows error format syntax like in String.format(String, Object...) method
RuntimeExceptionerrorInModel(String errorText)
Signals an model logic error during the model run by throwing a ModelException with errorText preceded by the agent full name.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments.
RuntimeExceptionerrorInModel(String errorTextFormat, Object... args)
The same as errorInModel(String) but allows error format syntax like in String.format(String, Object...) method
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments.
abstract RuntimeExceptionerrorInModel(Throwable cause, String errorText)
Signals an model logic error during the model run by throwing a ModelException with errorText preceded by the agent full name.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments.
RuntimeExceptionerrorInModel(Throwable cause, String errorTextFormat, Object... args)
The same as errorInModel(String) but allows error format syntax like in String.format(String, Object...) method
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments.
voidexecuteAction(String code, Object... argDescriptors)
Executes action.
<T> TexecuteExpression(Class<T> returnType, String code, Object... argDescriptors)
Executes/evaluates the given code, e.g.
<T> TexecuteExpression(String code, Object... argDescriptors)
Executes/evaluates the given code, e.g.
intexecuteStatement(String sql, Object... params)
Executes insert, delete and update statements in AnyLogic database with given sql query string and parameters
static doubleexponential(double min, double max, double shift, double stretch, Random r)
Generates a sample of truncated Exponential distribution using the specified random number generator.
Distribution exponential(1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval.
static doubleexponential(double lambda, double min, Random r)
Generates a sample of the Exponential distribution using the specified random number generator.
static StringfindExistingFile(String filePath)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
static Stringformat(boolean value)
Formats a boolean value
static Stringformat(char value)
Formats a character to String
static Stringformat(double value)
Formats a double value using the default AnyLogic formatter
static Stringformat(double value, IUnits<?> units)
Formats a double value with units, using the default AnyLogic formatter
static Stringformat(int value)
Formats an integer value using the default AnyLogic formatter
static Stringformat(long value)
Formats a long value using the default AnyLogic formatter
static Stringformat(Date date)
Formats a date using the default AnyLogic formatter
static StringformatAmountUnits(double value, AmountUnits units)
Converts value to required units and turns it into String
static StringformatDayOfWeek(int dayOfWeek, boolean fullName)
Returns the full or short name of the weekday
static StringformatFlowRateUnits(double value, FlowRateUnits units)
Converts value to required units and turns it into String
static StringformatGeoHeading(double radians)
Formats given heading angle (measured in radians CW, starting from North direction) as human-readable geographical heading (azimuth).
static StringformatLatitude(double degrees)
Formats latitude
static StringformatLengthUnits(double value, LengthUnits units)
Converts value to required units and turns it into String
static StringformatLengthUnits(LengthUnits unit, boolean fullName)
Returns the full or short name of the length units
static StringformatLongitude(double degrees)
Formats longitude
static StringformatMonth(int month, boolean fullName)
Returns the full or short name of the month
static StringformatSpeedUnits(double value, SpeedUnits units)
Converts value to required units and turns it into String
StringformatTimeInterval(double dt)
Returns a string representation of a given time interval, according to the current time unit settings, in the form 123 days 21h 0'56".
static doublegamma(double min, double max, double alpha, double shift, double stretch, Random r)
Generates a sample of truncated Gamma distribution using the specified random number generator.
Distribution gamma(alpha, 1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval.
static doublegamma(double alpha, double beta, double min, Random r)
Generates a sample of the Gamma distribution using the specified random number generator.
static doublegammaLog(double x)
Returns the natural logarithm of the gamma function of x:
ln(Γ(x)).
The gamma function is an extension of the factorial function that works on all positive values of x.
If n is a positive integer, then: Γ(n) = (n - 1)!.

The gammaLog function may be useful in System Dynamics models for computing combinatorial factors.
static intgeometric(double p, Random r)
Generates a sample of the Geometric distribution using the specified random number generator.
intgetAmPm()
Indicates whether the hour of the current model date with respect to the start time/date and the model time unit is before (AM) or after (PM) noon.
This method is used for the 12-hour clock.
E.g., at 10:04:15.250 PM the result is PM.
static intgetAmPm(Date date)
Indicates whether the hour of the given date is before (AM) or after (PM) noon.
This method is used for the 12-hour clock.
E.g., at 10:04:15.250 PM the result is PM.
static StringgetCanonicalPath(File file)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Tries getting canonical path for the given file, on any error return absolute path
ConnectiongetDatabaseConnection()
Returns connection to AnyLogic database
static DategetDateWithTimeNextTo(Date date, int hourOfDay, int minute, int second)
Returns the date which the next date after the given date and has the specified time (in the default time zone)
intgetDayOfMonth()
Returns the day of the month of the current model date with respect to the start time/date and the model time unit.
The first day of the month has value 1.
static intgetDayOfMonth(Date date)
Returns the day of the month of the given date.
The first day of the month has value 1.
intgetDayOfWeek()
Returns the day of the week of the current model date with respect to the start time/date and the model time unit.
Returned value is one of: SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
static intgetDayOfWeek(Date date)
Returns the day of the week of the given date.
Returned value is one of: SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
static intgetDayOfYear(Date date)
Returns the day of the year of the given date.
The first day of the year has value 1.
RandomgetDefaultRandomGenerator()
Retrieves the random number generator used by all probability distributions by default, i.e.
static final doublegetDistance(double x1, double y1, double x2, double y2)
Returns the distance between two given points (x1, y1) and (x2, y2)
static final doublegetDistance(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the distance between two given points (x1, y1, z1) and (x2, y2, z2)
static final doublegetDistanceFromPointToLine(double x1, double y1, double x2, double y2, double px, double py)
Returns the distance from a point to a line.
static final doublegetDistanceFromPointToLineSq(double x1, double y1, double x2, double y2, double px, double py)
Returns the square of the distance from a point to a line.
static final doublegetDistanceFromPointToSegment(double x1, double y1, double x2, double y2, double px, double py)
Returns the distance from a point to a line segment.
static final doublegetDistanceFromPointToSegment(double x1, double y1, double z1, double x2, double y2, double z2, double px, double py, double pz)
Returns the distance from a point to a line segment.
static final doublegetDistanceFromPointToSegmentSq(double x1, double y1, double x2, double y2, double px, double py)
Returns the square of the distance from a point to a line segment.
static final doublegetDistanceFromPointToSegmentSq(double x1, double y1, double z1, double x2, double y2, double z2, double px, double py, double pz)
Returns the square of the distance from a point to a line segment.
static doublegetDistanceGIS(double latitude1, double longitude1, double latitude2, double longitude2)
Returns the distance measured in meters between two given points
static doublegetDistanceGIS(double latitude1, double longitude1, double latitude2, double longitude2, LengthUnits units)
Returns the distance measured in meters between two given points
static final doublegetDistanceSq(double x1, double y1, double x2, double y2)
Returns the square of the distance between two given points (x1, y1) and (x2, y2).
This method is useful for comparing different distances, finding nearest point etc.
static final doublegetDistanceSq(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the square of the distance between two given points (x1, y1, z1) and (x2, y2, z2).
This method is useful for comparing different distances, finding nearest point etc.
static StringgetFullName(Agent agent)
Returns the name of the agent prefixed by the path from the top-level agent to this one.
intgetHour()
Returns the hour of the morning or afternoon of the current model date with respect to the start time/date and the model time unit.
This method is used for the 12-hour clock.
Noon and midnight are represented by 0, not by 12.
E.g., at 10:04:15.250 PM the result is 10.
static intgetHour(Date date)
Returns the hour of the morning or afternoon of the given date.
This method is used for the 12-hour clock.
Noon and midnight are represented by 0, not by 12.
E.g., at 10:04:15.250 PM the result is 10.
intgetHourOfDay()
Returns the hour of day of the current model date with respect to the start time/date and the model time unit.
This method is used for the 24-hour clock.
E.g., at 10:04:15.250 PM the result is 22.
static intgetHourOfDay(Date date)
Returns the hour of day of the given date.
This method is used for the 24-hour clock.
E.g., at 10:04:15.250 PM the result is 22.
static final doublegetLength(double dx, double dy)
Returns the length of the vector (dx, dy)
static final doublegetLength(double dx, double dy, double dz)
Returns the length of the vector (dx, dy, dz)
static final doublegetLengthSq(double dx, double dy)
Returns the square of length of the vector (dx, dy)
static final doublegetLengthSq(double dx, double dy, double dz)
Returns the square of length of the vector (dx, dy, dz)
intgetMillisecond()
Returns the millisecond within the second of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 250.
static intgetMillisecond(Date date)
Returns the millisecond within the second of the given date.
E.g., at 10:04:15.250 PM the result is 250.
intgetMinute()
Returns the minute within the hour of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 4.
static intgetMinute(Date date)
Returns the minute within the hour of the given date.
E.g., at 10:04:15.250 PM the result is 4.
intgetMonth()
Returns the month of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value.
The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.
Possible values: JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER
static intgetMonth(Date date)
Returns the month of the given date.
This is a calendar-specific value.
The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.
Possible values: JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER
static StringgetName(Agent agent)
Returns the name of the agent or null if the given agent is null.
This is a convenient function for formatting name of some agent when it may be null.
static final PointgetNearestPointOnSegment(Point out, double x1, double y1, double x2, double y2, double px, double py)
Finds a point on a segment that is closest to a given point.
static final PointgetNearestPointOnSegment(Point out, double x1, double y1, double z1, double x2, double y2, double z2, double px, double py, double pz)
Finds a point on a segment that is closest to a given point.
static intgetPerformanceParallelWorkersCount_xjal()
Returns number of processors (threads) when running parallel (multi-thread) experiments (with multiple runs) and some other features supporting parallel execution.
To get the number of processors reported by Java virtual machine, please use Runtime.getRuntime().availableProcessors() Please note that both methods shouldn't be generally used in the model logic because their results are inpredictable, not reproducible and depend on the underlying machine and AnyLogic installation
<T> TgetRandom(Collection<T> collection)
Same as #randomFrom(Collection)
static <T> TgetRandom(Collection<T> collection, Random r)
Same as #randomFrom(Collection, Random)
<T> TgetResult(boolean cached, boolean mustBeUnique, Class<T> returnType, String sql, Object... params)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
intgetSecond()
Returns the second within the minute of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 15.
static intgetSecond(Date date)
Returns the second within the minute of the given date.
E.g., at 10:04:15.250 PM the result is 15.
doublegetTime()
Deprecated.
Use time() instead
doublegetTimeoutToNextTime(int hourOfDay, int minute, int second)
Returns timeout, in model time units, to the nearest date which will have the specified in-day time (in the default time zone)
intgetYear()
Returns the year of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value
static intgetYear(Date date)
Returns the year of the given date.
This is a calendar-specific value
static doublegumbel1(double a, double b, Random r)
Generates a sample of the Type I Gumbel distribution using the specified random number generator.
static doublegumbel2(double a, double b, Random r)
Generates a sample of the Type II Gumbel distribution using the specified random number generator.
doublehour()
Returns a time value equal to one hour according to the current time unit setting.
static inthypergeometric(int ss, int dn, int ps, Random r)
Generates a sample of the Hypergeometric distribution using the specified random number generator.
InsertQueryinsertInto(com.querydsl.sql.RelationalPathBase<?> table)
Returns InsertQuery that allows to build queries by chaining calls
static StringinspectOf(Object object)
Returns a textual info on the object that can be displayed in the multi-line Inspect window.
static StringinspectOfLink_xjal(Object object)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
static booleanisFinite(double v)
Returns true if the given value is finite (not +/-infinity or NaN)
static final booleanisLineIntersectingLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
Tests if the line segment from (x1,y1) to (x2,y2) intersects the line segment from (x3,y3) to (x4,y4).
static final booleanisLineIntersectingRectangle(double x1, double y1, double x2, double y2, double rx, double ry, double rw, double rh)
Check if the line intersects the given rectangle
booleanisLoggingClassToDB(LoggingType loggingType)
Returns true if this agent type with all internals may log their data/changes/activity to AnyLogic built-in database (logging options are configurable in the properties of Database / Log in the Projects tree inside AnyLogic)
booleanisLoggingToDB(LoggingType loggingType)
Returns true if this agent and its internals may log their data/changes/activity to AnyLogic built-in database (logging options are configurable in the properties of Database / Log in the Projects tree inside AnyLogic)
static final booleanisPointInsideRay(double x1, double y1, double x2, double y2, double px, double py)
Tests if the specified point is inside the given ray.
static final booleanisPointInsideRectangle(double rx, double ry, double rw, double rh, double px, double py)
Tests if the specified point is inside the given rectangle.
static final booleanisPointInsideSegment(double x1, double y1, double x2, double y2, double px, double py)
Tests if the specified point is inside the given segment.
static final booleanisPointOnTheSameLine(double x1, double y1, double x2, double y2, double x3, double y3)
Tests if the three point lie on the same line
static final booleanisRayIntersectingSegment(double rx1, double ry1, double rx2, double ry2, double sx1, double sy1, double sx2, double sy2)
Tests if the ray from (rx1,ry1) in direction to (rx2,ry2) intersects the line segment from (lx1,ly1) to (lx2,ly2).
static int[]joinArrays_xjal(boolean replaceAlways, boolean replaceWithNotEmpty, int[] a1, int[] a2)
This method is internal and isn't intended to be called by user (may be removed in future releases)
static doublelaplace(double phi, double theta, Random r)
Generates a sample of the Laplace distribution using the specified random number generator.
static StringlayoutTypeToString(LayoutType layoutType)
Deprecated.
please use LayoutType.formatName() instead
static doublelimit(double min, double x, double max)
Returns x if it is within [min,max] interval, otherwise returns the closest bound.
static intlimit(int min, int x, int max)
Returns x if it is within [min,max] interval, otherwise returns the closest bound.
static doublelimitMax(double x, double max)
Returns x if it is less or equal to max, otherwise returns max.
static intlimitMax(int x, int max)
Returns x if it is less or equal to max, otherwise returns max.
static doublelimitMin(double min, double x)
Returns x if it is greater or equal to min, otherwise returns min.
static intlimitMin(int min, int x)
Returns x if it is greater or equal to min, otherwise returns min.
static intlogarithmic(double theta, Random r)
Generates a sample of the Logarithmic distribution using the specified random number generator.
static doublelogistic(double beta, double alpha, Random r)
Generates a sample of the Logistic distribution using the specified random number generator.
static doublelognormal(double mu, double sigma, double min, Random r)
Generates a sample of the Lognormal distribution using the specified random number generator.
voidlogToDB(DataSet dataSet, String name)
Writes the given element to the corresponding log table of model database.
If logging is enabled this method should be called in #onDestroy() method
voidlogToDB(HistogramData histogramData, String name)
Writes the given element to the corresponding log table of model database.
If logging is enabled this method should be called in #onDestroy() method
voidlogToDB(StatisticsContinuous statistics, String name)
Writes the given element to the corresponding log table of model database.
If logging is enabled this method should be called in #onDestroy() method
voidlogToDB(StatisticsDiscrete statistics, String name)
Writes the given element to the corresponding log table of model database.
If logging is enabled this method should be called in #onDestroy() method
doublemillisecond()
Returns a time value equal to one millisecond according to the current time unit setting.
doubleminute()
Returns a time value equal to one minute according to the current time unit setting.
doublemonth()
Returns a time value equal to 30 days according to the current time unit setting.
static doublenegativeBinomial(double min, double max, double p, double n, double shift, double stretch, Random r)
Generates a sample of truncated Negative Binomial distribution using the specified random number generator.
Distribution negativeBinomial(p, n) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval.
static intnegativeBinomial(double p, double n, Random r)
Generates a sample of the Negative Binomial distribution using the specified random number generator.
static doublenormal(double min, double max, double shift, double stretch, Random r)
Generates a sample of truncated Normal distribution using the specified random number generator.
Distribution normal(1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval.
static doublenormal(double sigma, double mean, Random r)
Generates a sample of the Normal distribution using the specified random number generator.
static doublepareto(double alpha, double min, Random r)
Generates a sample of the Pareto distribution using the specified random number generator.
static doublepert(double min, double max, double mode, Random r)
Generates a sample of the PERT distribution using the specified random number generator.
static doublepoisson(double min, double max, double mean, double shift, double stretch, Random r)
Generates a sample of truncated Poisson distribution using the specified random number generator.
Distribution poisson(mean) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval.
static intpoisson(double lambda, Random r)
Generates a sample of the Poisson distribution using the specified random number generator.
static voidprepareBeforeExperimentStart_xjal(Class<?> experimentClass)
This method is internal and isn't intended to be called by user (may be removed in future releases)
PreparedStatementprepareStatement(String sql, Object... params)
Creates a PreparedStatement object (which may be used to executes insert, delete and update statements in AnyLogic database) with the given SQL query string and and fills in the given objects as parameters.
Objects passed as parameters are converted automatically to match database format (e.g.
doublepulse(double startTime, double pulseWidth)
Returns 1, starting at startTime, and lasting for interval pulseWidth; 0 is returned at all other times.
doublepulseTrain(double startTime, double pulseWidth, double timeBetweenPulses, double endTime)
Returns 1, starting at startTime, and lasting for interval pulseWidth and then repeats this pattern every timeBetweenPulses time until endTime; 0 is returned at all other times.
If the value of timeBetweenPulses is smaller than pulseWidth then 1 will be returned between startTime and endTime.
static doublequantum(double value, double quantizer)
Returns the number smaller (by absolute value) than or equal to value that is an integer multiple of quantizer.
If quantizer is less than or equal to zero, then value is returned unchanged.
For example, quantum(PI, 0.01) will return 3.14
doubleramp(double slope, double startTime, double endTime)
Returns 0 until the startTime and then slopes upward until endTime and then holds constant.
ColorrandomColor()
Returns random standard color, one of possible standard colors
static booleanrandomFalse(double p, Random r)
Generates false with the given probability p using the specified random number generator.
For more details see UtilitiesRandom.randomFalse(double)
static <T extends Enum<T>>
T
randomFrom(Class<T> enumeration, Random r)
Returns the randomly chosen enumeration constant.
static <T> TrandomFrom(Iterable<T> collection, Random r)
Returns the randomly chosen element of the given collection.
static <T> TrandomFrom(T[] array, Random r)
Returns the randomly chosen element of the given array.
static <T> TrandomlyCreate(Random r, Class<? extends T>... classes)
Creates a randomly chosen object using one of the given constructors.
static <T> TrandomlyCreate(Random r, Supplier<? extends T>... constructors)
Creates a randomly chosen object using one of the given constructors.
static booleanrandomTrue(double p, Random r)
Generates true with the given probability p using the specified random number generator.
For more details see UtilitiesRandom.randomTrue(double)
static <T> TrandomWhere(Iterable<T> collection, Predicate<T> condition, Random r)
Returns the randomly chosen element of the given collection which meets the given condition.
static <T> TrandomWhere(T[] array, Predicate<T> condition, Random r)
Returns the randomly chosen element of the given array which meets the given condition.
static doublerayleigh(double sigma, double min, Random r)
Generates a sample of the Rayleigh distribution using the specified random number generator.
static doubleroundToDecimal(double v, int nDecimalDigits)
Rounds the value to the given precision.
static introundToInt(double v)
Returns int closest to the given value.
doublesecond()
Returns a time value equal to one second according to the current time unit setting.
intselectAndDoForEach(Consumer<ResultSet> action, String sql, Object... params)
Perform some action with each of results for the given sql and params.
Example:
double[]selectArrayOfDouble(String sql, Object... params)
Returns the array of numbers from the first column returned by the given sql and params.
int[]selectArrayOfInt(String sql, Object... params)
Returns the array of numbers from the first column returned by the given sql and params.
booleanselectExists(boolean cached, String sql, Object... params)
Returns true if the given sql and params returns at least one result This function caches its results, to speed up default behavior Use selectExists(false, sql, params) to get non cached result every time
booleanselectExists(String sql, Object... params)
Returns true if the given sql and params returns at least one result This function caches its results, to speed up default behavior Use selectExists(false, sql, params) to get non cached result every time
<T> TselectFirstValue(boolean cached, Class<T> returnType, String sql, Object... params)
Returns first result for given sql and params or null if no result is found This function caches its results, to speed up default behavior Use selectFirstValue(false, returnType, sql, params) to get non cached result every time
<T> TselectFirstValue(boolean cached, String sql, Object... params)
Returns first result for given sql and params or null if no result is found
<T> TselectFirstValue(Class<T> returnType, String sql, Object... params)
Returns first result for given sql and params or null if no result is found This function caches its results, to speed up default behavior Use selectFirstValue(false, returnType, sql, params) to get non cached result every time
<T> TselectFirstValue(String sql, Object... params)
Returns first result for given sql and params or null if no result is found This function caches its results, to speed up default behavior Use selectFirstValue(false, sql, params) to get non cached result every time
SelectQueryselectFrom(com.querydsl.sql.RelationalPathBase<?> table)
Returns SelectQuery that allows to build queries by chaining calls
ResultSetselectResultSet(String sql, Object... params)
Get the results as a result set object for the given sql and params
TableFunctionselectTableFunction(TableFunction tableFunction, String sql, Object... params)
Executes the given SELECT query which should return data in 2 columns: the first column contains arguments numbers, the second column contains values numbers.
<T> TselectUniqueValue(boolean cached, Class<T> returnType, String sql, Object... params)
Returns an unique result for given sql and params This function caches its results, to speed up default behavior Use selectUniqueValue(false, returnType, sql, params) to get non cached result every time
<T> TselectUniqueValue(boolean cached, String sql, Object... params)
Returns an unique result for given sql and params This function caches its results, to speed up default behavior Use selectUniqueValue(false, sql, params) to get non cached result every time
<T> TselectUniqueValue(Class<T> returnType, String sql, Object... params)
Returns an unique result for given sql and params This function caches its results, to speed up default behavior Use selectUniqueValue(false, returnType, sql, params) to get non cached result every time
<T> TselectUniqueValue(String sql, Object... params)
Returns an unique result for given sql and params This function caches its results, to speed up default behavior Use selectUniqueValue(false, sql, params) to get non cached result every time
<T> List<T>selectValues(Class<T> returnType, String sql, Object... params)
List the results for given sql and params Given sql query must return single column An empty list is returned for no results
<T> List<T>selectValues(String sql, Object... params)
List the results for given sql and params Given sql query must return single column An empty list is returned for no results
voidsetDefaultRandomGenerator(Random r)
Sets the random number generator used by all probability distributions by default, i.e.
<T> TsqlGetObject(ResultSet rs, int index, Class<T> returnType)
Gets values from AnyLogic wrapper for ResultSet in given position
<T> TsqlGetObject(ResultSet rs, String columnLabel, Class<T> returnType)
Gets values from AnyLogic wrapper for ResultSet in given position
<T> TsqlGetObject(ResultSet rs, int index, Class<T> returnType)
Gets values from ResultSet in given position
<T> TsqlGetObject(ResultSet rs, String columnLabel, Class<T> returnType)
Gets values from ResultSet in given position
voidsqlSetObject(PreparedStatement st, int index, Object object)
Sets parameter for preparedStatement in given index position with given value
static doublesqr(double v)
Returns the square of the given value (v2)
doublestep(double height, double stepTime)
Returns 0 until the stepTime and then returns height
doubletime()
Returns the current model (logical) time.
doubletime(TimeUnits units)
Returns the current model (logical) time.
DatetimeToDate(double t)
Converts the given model time to date with respect to the start date, start time and model time unit settings, null if the time is infinity.
static DatetoDate(int year, int month, int day)
Returns the date in the default time zone with given field values and the time set to a midnight.
static DatetoDate(int year, int month, int day, int hourOfDay, int minute, int second)
Returns the date in the default time zone with given field values.
static DatetoDate(String dateFormat, String text)
Parses the date from the given string using date format pattern.
static longtoDateInMillis(int year, int month, int day, int hourOfDay, int minute, int second)
Same as toDate(int, int, int, int, int, int) but returns the date in its milliseconds representation (see Date.getTime()), i.e.
static doubletoLatitude(int degrees, int minutes, double seconds, boolean northOrSouth)
Converts latitude from human-readable format (e.g.
static doubletoLongitude(int degrees, int minutes, double seconds, boolean eastOrWest)
Converts longitude from human-readable format (e.g.
doubletoModelRate(double value, RateUnits units)
Converts the given rate (in rate units) to units based on model time units (used e.g.
doubletoModelTime(double value, TimeUnits units)
Converts the given timeout (in units) to model time units (used e.g.
doubletoRateUnits(double modelRateValue, RateUnits units)
Converts the rate (in units based on model time units) to the given units
static StringtoStringAlignedNameValues(int minNameLength, Object... nameValueRows) 
doubletoTimeout(int timeUnit, double amount)
Deprecated.
doubletoTimeout(TimeUnits timeUnit, double amount)
Deprecated.
doubletoTimeoutInCalendar(TimeUnits timeUnit, double amount)
Returns timeout, in model time units, which equals to the given amount of timeUnits from current model date
e.g.
doubletoTimeUnits(double modelTimeValue, TimeUnits units)
Converts the timeout (in model time units) to the given units
static voidtrace(Object o)
Prints a string representation of an object to the standard output stream.
static voidtrace(String textFormat, Object... args)
The same as trace(Object) but allows text format syntax like in String.format(String, Object...) method
static voidtraceln()
Prints a line delimiter to the standard output stream.
static voidtraceln(Color color, Object o)
Prints a string representation of an object with a line delimiter at the end to the standard output stream.
static voidtraceln(Color color, String textFormat, Object... args)
The same as traceln(Object) but allows text format syntax like in String.format(String, Object...) method.
static voidtraceln(Object o)
Prints a string representation of an object with a line delimiter at the end to the standard output stream.
static voidtraceln(String textFormat, Object... args)
The same as traceln(Object) but allows text format syntax like in String.format(String, Object...) method
voidtraceToDB(Object o)
Prints a string representation of an object with a line delimiter at the end to the standard output stream.
voidtraceToDB(String textFormat, Object... args)
The same as traceln(Object) but allows text format syntax like in String.format(String, Object...) method
static doubletriangular(double min, double max, double left, double mode, double right, Random r)
Generates a sample of truncated Triangular distribution using the specified random number generator.
Distribution triangular(left, right, mode) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval.
static doubletriangular(double min, double max, double mode, Random r)
Generates a sample of the Triangular distribution using the specified random number generator.
static doubletriangularAV(double average, double variability, Random r)
Generates a sample of the Triangular distribution with mode set to average.
Defines distribution in the form like "roughly this, +/-20%".
Is equivalent to triangular( average * (1 - variability), average * (1 + variability) ) .
static doubleuniform(double min, double max, Random r)
Generates a sample of the Uniform distribution on the interval [min, max) using the specified random number generator.
static doubleuniform(Random r)
Generates a random value uniformly distributed on the interval [0,1), using the specified random number generator.
static intuniform_discr(int min, int max, Random r)
Generates a sample of the Discrete Uniform distribution on the interval [min, max] using the specified random number generator, both 0 and max included! For more details see UtilitiesRandom.uniform_discr(int,int).
static doubleuniform_pos(Random r)
Generates a positive random value uniformly distributed on the interval (0,1), using the specified random number generator.
UpdateQueryupdate(com.querydsl.sql.RelationalPathBase<?> table)
Returns UpdateQuery that allows to build queries by chaining calls
abstract voidwarning(String warningText)
Signals a warning during the model run with warningText preceded by the agent full name.
Warnings may be turned off in the AnyLogic preferences (runtime section) or by API: AnyLogicRuntimePreferences.setEnableWarnings(Boolean).
This method checks against numerous warnings output: In case of multiple warnings having equal warningText, only the first 10 of them are displayed.
abstract voidwarning(String warningTextFormat, Object... args)
Signals a warning during the model run with warningText preceded by the agent full name.
doubleweek()
Returns a time value equal to one week according to the current time unit setting.
static doubleweibull(double min, double max, double alpha, double shift, double stretch, Random r)
Generates a sample of truncated Weibull distribution using the specified random number generator.
Distribution weibull(alpha, stretch, 0) is shifted to the right by shift and then truncated to fit in [min, max] interval.
static doubleweibull(double alpha, double beta, double min, Random r)
Generates a sample of the Weibull distribution using the specified random number generator.
static doublexidz(double a, double b, double x)
Tries to divide the first argument by the second.
doubleyear()
Returns a time value equal to 365 days according to the current time unit setting.
static doublezidz(double a, double b)
Tries to divide the first argument by the second.

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

SUNDAY

public static final int SUNDAY
Value of the getDayOfWeek(Date) method indicating Sunday.
See Also:
getDayOfWeek(Date)getDayOfWeek()Engine.getDayOfWeek()Constant Field Values

MONDAY

public static final int MONDAY
Value of the getDayOfWeek(Date) method indicating Monday.
See Also:
getDayOfWeek(Date)getDayOfWeek()Engine.getDayOfWeek()Constant Field Values

TUESDAY

public static final int TUESDAY
Value of the getDayOfWeek(Date) method indicating Tuesday.
See Also:
getDayOfWeek(Date)getDayOfWeek()Engine.getDayOfWeek()Constant Field Values

WEDNESDAY

public static final int WEDNESDAY
Value of the getDayOfWeek(Date) method indicating Wednesday.
See Also:
getDayOfWeek(Date)getDayOfWeek()Engine.getDayOfWeek()Constant Field Values

THURSDAY

public static final int THURSDAY
Value of the getDayOfWeek(Date) method indicating Thursday.
See Also:
getDayOfWeek(Date)getDayOfWeek()Engine.getDayOfWeek()Constant Field Values

FRIDAY

public static final int FRIDAY
Value of the getDayOfWeek(Date) method indicating Friday.
See Also:
getDayOfWeek(Date)getDayOfWeek()Engine.getDayOfWeek()Constant Field Values

SATURDAY

public static final int SATURDAY
Value of the getDayOfWeek(Date) method indicating Saturday.
See Also:
getDayOfWeek(Date)getDayOfWeek()Engine.getDayOfWeek()Constant Field Values

JANUARY

public static final int JANUARY
Value of the getMonth(Date) method indicating the first month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

FEBRUARY

public static final int FEBRUARY
Value of the getMonth(Date) method indicating the second month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

MARCH

public static final int MARCH
Value of the getMonth(Date) method indicating the third month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

APRIL

public static final int APRIL
Value of the getMonth(Date) method indicating the fourth month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

MAY

public static final int MAY
Value of the getMonth(Date) method indicating the fifth month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

JUNE

public static final int JUNE
Value of the getMonth(Date) method indicating the sixth month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

JULY

public static final int JULY
Value of the getMonth(Date) method indicating the seventh month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

AUGUST

public static final int AUGUST
Value of the getMonth(Date) method indicating the eighth month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

SEPTEMBER

public static final int SEPTEMBER
Value of the getMonth(Date) method indicating the ninth month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

OCTOBER

public static final int OCTOBER
Value of the getMonth(Date) method indicating the tenth month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

NOVEMBER

public static final int NOVEMBER
Value of the getMonth(Date) method indicating the eleventh month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

DECEMBER

public static final int DECEMBER
Value of the getMonth(Date) method indicating the twelfth month of the year in the Gregorian and Julian calendars.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

UNDECIMBER

@AnyLogicLegacyAPI
public static final int UNDECIMBER
Value of the getMonth(Date) method indicating the thirteenth month of the year. Although GregorianCalendar does not use this value, lunar calendars do.
See Also:
getMonth(Date)getMonth()Engine.getMonth()Constant Field Values

AM

public static final int AM
Value of the getAmPm(Date) method indicating the period of the day from midnight to just before noon.
See Also:
getAmPm(Date)getAmPm()Engine.getAmPm()Constant Field Values

PM

public static final int PM
Value of the getAmPm(Date) method indicating the period of the day from noon to just before midnight.
See Also:
getAmPm(Date)getAmPm()Engine.getAmPm()Constant Field Values

TIME_UNIT_MILLISECOND

@AnyLogicLegacyAPI
public static final long TIME_UNIT_MILLISECOND
One of the possible time units. Equals 1.
See Also:
Constant Field Values

TIME_UNIT_SECOND

@AnyLogicLegacyAPI
public static final long TIME_UNIT_SECOND
One of the possible time units. Equals the number of milliseconds in a second.
See Also:
Constant Field Values

TIME_UNIT_MINUTE

@AnyLogicLegacyAPI
public static final long TIME_UNIT_MINUTE
One of the possible time units. Equals the number of milliseconds in a minute.
See Also:
Constant Field Values

TIME_UNIT_HOUR

@AnyLogicLegacyAPI
public static final long TIME_UNIT_HOUR
One of the possible time units. Equals the number of milliseconds in an hour.
See Also:
Constant Field Values

TIME_UNIT_DAY

@AnyLogicLegacyAPI
public static final long TIME_UNIT_DAY
One of the possible time units. Equals the number of milliseconds in a day.
See Also:
Constant Field Values

TIME_UNIT_WEEK

@AnyLogicLegacyAPI
public static final long TIME_UNIT_WEEK
One of the possible time units. Equals the number of milliseconds in a week.
See Also:
Constant Field Values

TIME_UNIT_MONTH

@AnyLogicLegacyAPI
public static final long TIME_UNIT_MONTH
One of the possible time units. Equals the number of milliseconds in 30 days.
See Also:
Constant Field Values

TIME_UNIT_YEAR

@AnyLogicLegacyAPI
public static final long TIME_UNIT_YEAR
One of the possible time units. Equals the number of milliseconds in 365 days.
See Also:
Constant Field Values

LENGTH_UNIT_CENTIMETER

public static final LengthUnits LENGTH_UNIT_CENTIMETER

LENGTH_UNIT_INCH

public static final LengthUnits LENGTH_UNIT_INCH

LENGTH_UNIT_METER

public static final LengthUnits LENGTH_UNIT_METER

LENGTH_UNIT_FOOT

public static final LengthUnits LENGTH_UNIT_FOOT

LENGTH_UNIT_KILOMETER

public static final LengthUnits LENGTH_UNIT_KILOMETER

LENGTH_UNIT_MILE

public static final LengthUnits LENGTH_UNIT_MILE

Constructor Details

Utilities

public Utilities()

Method Details

error

public RuntimeException error(String errorText)
Signals an error during the model run by throwing a RuntimeException with errorText preceded by the agent full name.
Parameters:
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw error("my message");

error

public RuntimeException error(String errorTextFormat,
 Object... args)
The same as error(String) but allows error format syntax like in String.format(String, Object...) method
See Also:

errorInModel

public RuntimeException errorInModel(String errorText)
Signals an model logic error during the model run by throwing a ModelException with errorText preceded by the agent full name.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments. Examples are 'entity was unable to leave flowchart block because subsequent block was busy', 'insufficient capacity of pallet rack' etc.
Parameters:
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw errorInModel("my message");

errorInModel

public RuntimeException errorInModel(String errorTextFormat,
 Object... args)
The same as errorInModel(String) but allows error format syntax like in String.format(String, Object...) method
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments. Examples are 'entity was unable to leave flowchart block because subsequent block was busy', 'insufficient capacity of pallet rack' etc.
See Also:

error

public abstract RuntimeException error(Throwable cause,
 String errorText)
Signals an error during the model run by throwing a RuntimeException with errorText preceded by the agent full name.
Parameters:
cause - the cause (which will be saved for more detailed message), may be null
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw error("my message");

error

public RuntimeException error(Throwable cause,
 String errorTextFormat,
 Object... args)
The same as error(String) but allows error format syntax like in String.format(String, Object...) method
Parameters:
cause - the cause (which will be saved for more detailed message), may be null
See Also:

errorInModel

public abstract RuntimeException errorInModel(Throwable cause,
 String errorText)
Signals an model logic error during the model run by throwing a ModelException with errorText preceded by the agent full name.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments. Examples are 'entity was unable to leave flowchart block because subsequent block was busy', 'insufficient capacity of pallet rack' etc.
Parameters:
cause - the cause (which will be saved for more detailed message), may be null
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw errorInModel("my message");

errorInModel

public RuntimeException errorInModel(Throwable cause,
 String errorTextFormat,
 Object... args)
The same as errorInModel(String) but allows error format syntax like in String.format(String, Object...) method
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments. Examples are 'entity was unable to leave flowchart block because subsequent block was busy', 'insufficient capacity of pallet rack' etc.
Parameters:
cause - the cause (which will be saved for more detailed message), may be null
See Also:

warning

public abstract void warning(String warningText)
Signals a warning during the model run with warningText preceded by the agent full name.
Warnings may be turned off in the AnyLogic preferences (runtime section) or by API: AnyLogicRuntimePreferences.setEnableWarnings(Boolean).
This method checks against numerous warnings output:
  • In case of multiple warnings having equal warningText, only the first 10 of them are displayed.
  • When more than 1000 warnings having different warningText occur, all the subsequent warnings (including new occurrences of those in the first 1000) will stop displaying.
  • Be careful with using dynamically changing warningText (e.g. listing names of agents), it could be better to use warning(String, Object...).
Parameters:
warningText - the text describing the warning that will be displayed.
Since:
8.6

warning

public abstract void warning(String warningTextFormat,
 Object... args)
Signals a warning during the model run with warningText preceded by the agent full name. The method allows warning format syntax like in String.format(String, Object...) method.
Warnings may be turned off in the AnyLogic preferences (runtime section) or by API: AnyLogicRuntimePreferences.setEnableWarnings(Boolean).
This method checks against numerous warnings output:
  • In case of multiple warnings having equal warningTextFormat, only the first 10 of them are displayed.
  • It is safe to raise numerous warnings with equal format string (which defines the warning type) but varying args - AnyLogic will take care to display only 10 first warnings of each warning type.
  • When more than 1000 warnings having different warningTextFormat occur, all the subsequent warnings (including new occurrences of those in the first 1000) will stop displaying.
  • Don't use dynamically changing warningTextFormat (e.g. listing names of agents), use args instead.
Since:
8.6
See Also:

selectFrom

public SelectQuery selectFrom(com.querydsl.sql.RelationalPathBase<?> table)
Returns SelectQuery that allows to build queries by chaining calls
Parameters:
table - to select from
Returns:
SelectQuery that allows to build queries by chaining calls

insertInto

public InsertQuery insertInto(com.querydsl.sql.RelationalPathBase<?> table)
Returns InsertQuery that allows to build queries by chaining calls
Parameters:
table - to insert into
Returns:
InsertQuery that allows to build queries by chaining calls

deleteFrom

public DeleteQuery deleteFrom(com.querydsl.sql.RelationalPathBase<?> table)
Returns DeleteQuery that allows to build queries by chaining calls
Parameters:
table - to delete from
Returns:
DeleteQuery that allows to build queries by chaining calls

update

public UpdateQuery update(com.querydsl.sql.RelationalPathBase<?> table)
Returns UpdateQuery that allows to build queries by chaining calls
Parameters:
table - to update
Returns:
UpdateQuery that allows to build queries by chaining calls

isLoggingToDB

@AnyLogicInternalCodegenAPI
public boolean isLoggingToDB(LoggingType loggingType)
Returns true if this agent and its internals may log their data/changes/activity to AnyLogic built-in database (logging options are configurable in the properties of Database / Log in the Projects tree inside AnyLogic)
Parameters:
loggingType - type of logging
Returns:
true if logged, false otherwise

isLoggingClassToDB

@AnyLogicInternalAPI
public boolean isLoggingClassToDB(LoggingType loggingType)
Returns true if this agent type with all internals may log their data/changes/activity to AnyLogic built-in database (logging options are configurable in the properties of Database / Log in the Projects tree inside AnyLogic)
Parameters:
loggingType - type of logging
Returns:
true if logged, false otherwise

selectExists

public boolean selectExists(String sql,
 Object... params)
Returns true if the given sql and params returns at least one result This function caches its results, to speed up default behavior Use selectExists(false, sql, params) to get non cached result every time
Parameters:
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column

selectExists

public boolean selectExists(boolean cached,
 String sql,
 Object... params)
Returns true if the given sql and params returns at least one result This function caches its results, to speed up default behavior Use selectExists(false, sql, params) to get non cached result every time
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column

selectFirstValue

public <T> T selectFirstValue(String sql,
 Object... params)
Returns first result for given sql and params or null if no result is found This function caches its results, to speed up default behavior Use selectFirstValue(false, sql, params) to get non cached result every time
Parameters:
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column

selectUniqueValue

public <T> T selectUniqueValue(String sql,
 Object... params)
Returns an unique result for given sql and params This function caches its results, to speed up default behavior Use selectUniqueValue(false, sql, params) to get non cached result every time
Parameters:
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column
Throws:
RuntimeException - if there is no matching results or more than one matching result

selectFirstValue

public <T> T selectFirstValue(Class<T> returnType,
 String sql,
 Object... params)
Returns first result for given sql and params or null if no result is found This function caches its results, to speed up default behavior Use selectFirstValue(false, returnType, sql, params) to get non cached result every time
Parameters:
returnType - type required to be returned by this function
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column

selectUniqueValue

public <T> T selectUniqueValue(Class<T> returnType,
 String sql,
 Object... params)
Returns an unique result for given sql and params This function caches its results, to speed up default behavior Use selectUniqueValue(false, returnType, sql, params) to get non cached result every time
Parameters:
returnType - type required to be returned by this function
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column
Throws:
RuntimeException - if there is no matching results or more than one matching result

selectFirstValue

public <T> T selectFirstValue(boolean cached,
 String sql,
 Object... params)
Returns first result for given sql and params or null if no result is found
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column

selectUniqueValue

public <T> T selectUniqueValue(boolean cached,
 String sql,
 Object... params)
Returns an unique result for given sql and params This function caches its results, to speed up default behavior Use selectUniqueValue(false, sql, params) to get non cached result every time
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column
Throws:
RuntimeException - if there is no matching results or more than one matching result

selectFirstValue

public <T> T selectFirstValue(boolean cached,
 Class<T> returnType,
 String sql,
 Object... params)
Returns first result for given sql and params or null if no result is found This function caches its results, to speed up default behavior Use selectFirstValue(false, returnType, sql, params) to get non cached result every time
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
returnType - type required to be returned by this function
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column

selectUniqueValue

public <T> T selectUniqueValue(boolean cached,
 Class<T> returnType,
 String sql,
 Object... params)
Returns an unique result for given sql and params This function caches its results, to speed up default behavior Use selectUniqueValue(false, returnType, sql, params) to get non cached result every time
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
returnType - type required to be returned by this function
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column
Throws:
RuntimeException - if there is no matching results or more than one matching result

getResult

@AnyLogicInternalAPI
public <T> T getResult(boolean cached,
 boolean mustBeUnique,
 Class<T> returnType,
 String sql,
 Object... params)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.

selectValues

public <T> List<T> selectValues(String sql,
 Object... params)
List the results for given sql and params Given sql query must return single column An empty list is returned for no results
Parameters:
sql - string containing select query
params - array containing select query params
Returns:
List list of resulting values

selectValues

public <T> List<T> selectValues(Class<T> returnType,
 String sql,
 Object... params)
List the results for given sql and params Given sql query must return single column An empty list is returned for no results
Parameters:
returnType - required type of elements returned by this function
sql - string containing select query
params - array containing select query params
Returns:
List list of resulting values

selectArrayOfDouble

public double[] selectArrayOfDouble(String sql,
 Object... params)
Returns the array of numbers from the first column returned by the given sql and params. Given sql query must return single column An empty array is returned for no results
Parameters:
sql - string containing select query
params - array containing select query params
Returns:
array of 'double' numbers

selectArrayOfInt

public int[] selectArrayOfInt(String sql,
 Object... params)
Returns the array of numbers from the first column returned by the given sql and params. Given sql query must return single column An empty array is returned for no results
Parameters:
sql - string containing select query
params - array containing select query params
Returns:
array of 'int' numbers

selectResultSet

public ResultSet selectResultSet(String sql,
 Object... params)
Get the results as a result set object for the given sql and params
Parameters:
sql - string containing select query
params - array containing select query params
Returns:
ResultSet selected ResultSet

selectAndDoForEach

public int selectAndDoForEach(Consumer<ResultSet> action,
 String sql,
 Object... params)
Perform some action with each of results for the given sql and params.
Example:
 selectAndDoForEach( rs -> myCollection.add( rs.getString(1) ), "SELECT name FROM parts_table WHERE priority = ?", "high" );
Parameters:
action - what to do with each record (use get... methods of the given result set)
sql - string containing select query
params - array containing select query params
Returns:
number of selected records

executeStatement

public int executeStatement(String sql,
 Object... params)
Executes insert, delete and update statements in AnyLogic database with given sql query string and parameters
Parameters:
sql - string containing statement
params - array containing statement params
Returns:
number of affected rows

selectTableFunction

public TableFunction selectTableFunction(TableFunction tableFunction,
 String sql,
 Object... params)
Executes the given SELECT query which should return data in 2 columns:
  • the first column contains arguments numbers,
  • the second column contains values numbers.
Parameters:
tableFunction - the table function to fill
sql - string containing statement
params - array containing statement params
Returns:
the given table function, for convenience

getDatabaseConnection

public Connection getDatabaseConnection()
Returns connection to AnyLogic database
Returns:
Connection to database

createTableElementDatabaseBuilder

@AnyLogicInternalAPI
public TableElementDatabaseBuilder createTableElementDatabaseBuilder()

sqlSetObject

public void sqlSetObject(PreparedStatement st,
 int index,
 Object object)
Sets parameter for preparedStatement in given index position with given value
Parameters:
st - PreparedStatement
index - of given parameter in query
object - parameter value

sqlGetObject

public <T> T sqlGetObject(ResultSet rs,
 String columnLabel,
 Class<T> returnType)
Gets values from ResultSet in given position
Parameters:
rs - ResultSet with selected values
columnLabel - name of column
returnType - type that will be returned

sqlGetObject

public <T> T sqlGetObject(ResultSet rs,
 String columnLabel,
 Class<T> returnType)
Gets values from AnyLogic wrapper for ResultSet in given position
Parameters:
rs - AnyLogic wrapper for ResultSet with selected values
columnLabel - name of column
returnType - type that will be returned

sqlGetObject

public <T> T sqlGetObject(ResultSet rs,
 int index,
 Class<T> returnType)
Gets values from ResultSet in given position
Parameters:
st - PreparedStatement built with prepareStatement(String sql) method
index - of given parameter in query
returnType - type that will be returned

sqlGetObject

public <T> T sqlGetObject(ResultSet rs,
 int index,
 Class<T> returnType)
Gets values from AnyLogic wrapper for ResultSet in given position
Parameters:
rs - AnyLogic wrapper for ResultSet with selected values
index - of result
returnType - type that will be returned

prepareStatement

public PreparedStatement prepareStatement(String sql,
 Object... params)
                                   throws SQLException
Creates a PreparedStatement object (which may be used to executes insert, delete and update statements in AnyLogic database) with the given SQL query string and and fills in the given objects as parameters.
Objects passed as parameters are converted automatically to match database format (e.g. option list / enum constants are written as their text names).

Caller is responsible to invoke close() method on the returned 'prepared statement' object after usage.
Parameters:
sql - string containing statement
params - array containing statement params
Returns:
PreparedStatement object
Throws:
SQLException

castTypes

@AnyLogicInternalAPI
public <RT> RT castTypes(Object result,
 Class<RT> returnType)
Makes both implicit and explicit casts returnType might be equal to Object.class, then convertation will be done only based on result type like Timestamp -> Date

castTypesBack

public Object castTypesBack(Object value)

castNumberTypes

@AnyLogicInternalAPI
public <RT> RT castNumberTypes(Number number,
 Class<RT> returnType)

executeAction

public void executeAction(String code,
 Object... argDescriptors)
Executes action.
Example: executeAction("event.restart(dt);", "dt", 1000);
Parameters:
code - the source code
argDescriptors - array of pairs: argName1, argValue1, argName2, argValue2, ...

executeExpression

public <T> T executeExpression(String code,
 Object... argDescriptors)
Executes/evaluates the given code, e.g. executeExpression( "exponential( 10 )" ).
If provided, uses the given arguments, specified in the form of pair: name, value. In the following example:
executeExpression( "agent.getName() + index", "agent", agent, "index", i - 1 )
the code will operate with variables agent and index of types Agent and Integer
Parameters:
code - java code of expression / action
argDescriptors - array of pairs: argName1, argValue1, argName2, argValue2, ...
Returns:
evaluated expression result

executeExpression

public <T> T executeExpression(Class<T> returnType,
 String code,
 Object... argDescriptors)
Executes/evaluates the given code, e.g. executeExpression( "exponential( 10 )" ).
If provided, uses the given arguments, specified in the form of pair: name, value. In the following example:
executeExpression( "agent.getName() + index", "agent", agent, "index", i - 1 )
the code will operate with variables agent and index of types Agent and Integer
Parameters:
returnType - return-type of expression, may be void.class - for actions
code - java code of expression / action
argDescriptors - array of pairs: argName1, argValue1, argName2, argValue2, ...
Returns:
evaluated expression result

time

public double time()
Returns the current model (logical) time. Time stays constant during an event execution and is only advanced between events.
Returns:
current model time

time

public double time(TimeUnits units)
Returns the current model (logical) time. Time stays constant during an event execution and is only advanced between events.
Parameters:
units - the time units
Returns:
current model time

getTime

@Deprecated
public double getTime()
Deprecated.
Use time() instead

date

public Date date()
Returns the current model date with respect to the start time/date and the model time unit.
Returns:
the current model date

timeToDate

public Date timeToDate(double t)
Converts the given model time to date with respect to the start date, start time and model time unit settings, null if the time is infinity.
Parameters:
t - the model time
Returns:
the date corresponding to the given model time, or null

dateToTime

public double dateToTime(Date d)
Converts the given date to model time with respect to the start date, start time and model time unit settings
Parameters:
d - the date to convert
Returns:
the model time corresponding to date

getMillisecond

public static int getMillisecond(Date date)
Returns the millisecond within the second of the given date.
E.g., at 10:04:15.250 PM the result is 250.
Parameters:
date - the date for which millisecond is returned
Returns:
the millisecond within the second of the given date

getSecond

public static int getSecond(Date date)
Returns the second within the minute of the given date.
E.g., at 10:04:15.250 PM the result is 15.
Parameters:
date - the date for which second is returned
Returns:
the second within the minute of the given date

getMinute

public static int getMinute(Date date)
Returns the minute within the hour of the given date.
E.g., at 10:04:15.250 PM the result is 4.
Parameters:
date - the date for which minute is returned
Returns:
the minute within the hour of the given date

getHour

public static int getHour(Date date)
Returns the hour of the morning or afternoon of the given date.
This method is used for the 12-hour clock.
Noon and midnight are represented by 0, not by 12.
E.g., at 10:04:15.250 PM the result is 10.
Parameters:
date - the date for which hour is returned
Returns:
the hour of the morning or afternoon of the given date
See Also:
getAmPm(Date)getHourOfDay(Date)

getAmPm

public static int getAmPm(Date date)
Indicates whether the hour of the given date is before (AM) or after (PM) noon.
This method is used for the 12-hour clock.
E.g., at 10:04:15.250 PM the result is PM.
Parameters:
date - the date for AM/PM information is returned
Returns:
AM or PM depending on the hour of the given date
See Also:
getHour(Date)getHourOfDay(Date)

getHourOfDay

public static int getHourOfDay(Date date)
Returns the hour of day of the given date.
This method is used for the 24-hour clock.
E.g., at 10:04:15.250 PM the result is 22.
Parameters:
date - the date for which hour of day is returned
Returns:
the hour of day of the given date
See Also:
getHour(Date)getAmPm(Date)

getDayOfWeek

public static int getDayOfWeek(Date date)
Returns the day of the week of the given date.
Returned value is one of:
Parameters:
date - the date for which day of the week is returned
Returns:
the day of the week of the given date

getDayOfMonth

public static int getDayOfMonth(Date date)
Returns the day of the month of the given date.
The first day of the month has value 1.
Parameters:
date - the date for which day of the month is returned
Returns:
the day of the month of the given date

getDayOfYear

public static int getDayOfYear(Date date)
Returns the day of the year of the given date.
The first day of the year has value 1.
Parameters:
date - the date for which day of the year is returned
Returns:
the day of the year of the given date

getMonth

public static int getMonth(Date date)
Returns the month of the given date.
This is a calendar-specific value.
The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.
Possible values:
Parameters:
date - the date for which month is returned
Returns:
the month of the given date

getYear

public static int getYear(Date date)
Returns the year of the given date.
This is a calendar-specific value
Parameters:
date - the date for which year is returned
Returns:
the year of the given date

getMillisecond

public int getMillisecond()
Returns the millisecond within the second of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 250.
Returns:
the millisecond within the second of the current model date with respect to the start time/date and the model time unit

getSecond

public int getSecond()
Returns the second within the minute of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 15.
Returns:
the second within the minute of the current model date with respect to the start time/date and the model time unit

getMinute

public int getMinute()
Returns the minute within the hour of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 4.
Returns:
the minute within the hour of the current model date with respect to the start time/date and the model time unit

getHour

public int getHour()
Returns the hour of the morning or afternoon of the current model date with respect to the start time/date and the model time unit.
This method is used for the 12-hour clock.
Noon and midnight are represented by 0, not by 12.
E.g., at 10:04:15.250 PM the result is 10.
Returns:
the hour of the morning or afternoon of the current model date with respect to the start time/date and the model time unit
See Also:
getAmPm(Date)getHourOfDay(Date)

getAmPm

public int getAmPm()
Indicates whether the hour of the current model date with respect to the start time/date and the model time unit is before (AM) or after (PM) noon.
This method is used for the 12-hour clock.
E.g., at 10:04:15.250 PM the result is PM.
Returns:
AM or PM depending on the hour of the current model date with respect to the start time/date and the model time unit
See Also:
getHour(Date)getHourOfDay(Date)

getHourOfDay

public int getHourOfDay()
Returns the hour of day of the current model date with respect to the start time/date and the model time unit.
This method is used for the 24-hour clock.
E.g., at 10:04:15.250 PM the result is 22.
Returns:
the hour of day of the current model date with respect to the start time/date and the model time unit
See Also:
getHour(Date)getAmPm(Date)

getDayOfWeek

public int getDayOfWeek()
Returns the day of the week of the current model date with respect to the start time/date and the model time unit.
Returned value is one of:
Returns:
the day of the week of the current model date with respect to the start time/date and the model time unit

getDayOfMonth

public int getDayOfMonth()
Returns the day of the month of the current model date with respect to the start time/date and the model time unit.
The first day of the month has value 1.
Returns:
the day of the month of the current model date with respect to the start time/date and the model time unit

getMonth

public int getMonth()
Returns the month of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value.
The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.
Possible values:
Returns:
the month of the current model date with respect to the start time/date and the model time unit

getYear

public int getYear()
Returns the year of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value
Returns:
the year of the current model date with respect to the start time/date and the model time unit

toTimeout

@Deprecated
public double toTimeout(int timeUnit,
 double amount)
Deprecated.
Returns timeout, in model time units, which equals to the given amount of timeUnits from current model date
e.g. toTimeout( DAY, 1 ) returns timeout in model time units from date() to the ( date() + 1 day )
Note, that the result of this method also depends on the current model date (because of leap years, different month lengths, daylight saving time tweaks) and therefore this method shouldn't be used for initialization of any constants

One of examples where this method should be used:
A model scheduling an event occurring each day at fixed time (e.g. 8:00): this method will return correct timeout on each call (even when time is switched to daylight-saving mode)
unlike day() which will always return timeout for 24 hours and may result in events scheduled at 7:00 or 9:00
Parameters:
timeUnit - time unit, possible values:
amount - the number of time units (may be negative - in this case result will be also negative)
Returns:
timeout, in model time units, which may be used e.g. to schedule an event in the given amount of timeUnits

toTimeout

@Deprecated
public double toTimeout(TimeUnits timeUnit,
 double amount)
Deprecated.

toTimeoutInCalendar

public double toTimeoutInCalendar(TimeUnits timeUnit,
 double amount)
Returns timeout, in model time units, which equals to the given amount of timeUnits from current model date
e.g. toTimeout( DAY, 1 ) returns timeout in model time units from date() to the ( date() + 1 day )
Note, that the result of this method also depends on the current model date (because of leap years, different month lengths, daylight saving time tweaks) and therefore this method shouldn't be used for initialization of any constants

One of examples where this method should be used:
A model scheduling an event occurring each day at fixed time (e.g. 8:00): this method will return correct timeout on each call (even when time is switched to daylight-saving mode)
unlike day() which will always return timeout for 24 hours and may result in events scheduled at 7:00 or 9:00
Parameters:
timeUnit - time unit, possible values:
amount - the number of time units (may be negative - in this case result will be also negative)
Returns:
timeout, in model time units, which may be used e.g. to schedule an event in the given amount of timeUnits

getTimeoutToNextTime

public double getTimeoutToNextTime(int hourOfDay,
 int minute,
 int second)
Returns timeout, in model time units, to the nearest date which will have the specified in-day time (in the default time zone)
Parameters:
hourOfDay - the hour of day (using 24-hour clock)
minute - the minute
second - the second
Returns:
timeout, in model time units, which may be used e.g. to schedule an event to the nearest time moment

addToDate

public static Date addToDate(Date date,
 TimeUnits timeUnit,
 double amount)
Returns the date, which will be after the given amount of timeUnits from the given date
e.g. addToDate( DAY, 1 ) returns the 'tomorrow' date: ( date + 1 day )
Note, that this method correctly handles leap years, daylight saving time tweaks, e.g. its ( DAY, 1 ) may actually add to the date 23 or 25 hours during DST switch, in order to get the correct result
Parameters:
timeUnit - time unit, possible values:
date - the base date
amount - the number of time units (may be negative - in this case the returned date will be in the past relative to the given date)
Returns:
the new date obtained by adding amount of timeUnits to the given date

addToDate

@AnyLogicLegacyAPI
public static Date addToDate(Date date,
 int timeUnit,
 double amount)
Returns the date, which will be after the given amount of timeUnits from the given date
e.g. addToDate( DAY, 1 ) returns the 'tomorrow' date: ( date + 1 day )
Note, that this method correctly handles leap years, daylight saving time tweaks, e.g. its ( DAY, 1 ) may actually add to the date 23 or 25 hours during DST switch, in order to get the correct result
Parameters:
timeUnit - time unit, possible values:
date - the base date
amount - the number of time units (may be negative - in this case the returned date will be in the past relative to the given date)
Returns:
the new date obtained by adding amount of timeUnits to the given date

differenceInDateUnits

@Deprecated
public static double differenceInDateUnits(TimeUnits timeUnit,
 Date date1,
 Date date2)
Deprecated.

differenceInCalendarUnits

public static double differenceInCalendarUnits(TimeUnits timeUnit,
 Date date1,
 Date date2)
Returns the difference (date2 - date1) between two dates in the given time units.
Result is the number of time units that should be added to date1 to obtain date2
The result may be negative and may have fractional part depending on the given dates.
Parameters:
timeUnit - the time units for difference computation, possible values:
date1 - the first date
date2 - the second date
Returns:
the difference (date2 - date1) in the given time units

differenceInDateUnits

@Deprecated
public static double differenceInDateUnits(int timeUnit,
 Date date1,
 Date date2)
Deprecated.
Returns the difference (date2 - date1) between two dates in the given time units.
Result is the number of time units that should be added to date1 to obtain date2
The result may be negative and may have fractional part depending on the given dates.
Parameters:
timeUnit - the time units for difference computation, possible values:
date1 - the first date
date2 - the second date
Returns:
the difference (date2 - date1) in the given time units

differenceInDateUnits

@Deprecated
public double differenceInDateUnits(TimeUnits timeUnit,
 double time1,
 double time2)

differenceInCalendarUnits

public double differenceInCalendarUnits(TimeUnits timeUnit,
 double time1,
 double time2)
Returns the difference (time2 - time1) between two model dates (corresponding to the given model times) in the given time units.
Result is the number of date units that should be added to the model time time1 to obtain time2
The result may be negative and may have fractional part depending on the given dates.
Parameters:
timeUnit - the time units for difference computation, possible values:
time1 - the first model time
time2 - the second model time
Returns:
the difference (time2 - time1) in the given date units

differenceInDateUnits

@Deprecated
public double differenceInDateUnits(int timeUnit,
 double time1,
 double time2)
Deprecated.
Returns the difference (time2 - time1) between two model dates (corresponding to the given model times) in the given time units.
Result is the number of date units that should be added to the model time time1 to obtain time2
The result may be negative and may have fractional part depending on the given dates.
Parameters:
timeUnit - the time units for difference computation, possible values:
time1 - the first model time
time2 - the second model time
Returns:
the difference (time2 - time1) in the given date units

dropTime

public static Date dropTime(Date date)
This utility method drops time-of-the-day information and returns the date with the time 00:00:00.000
Parameters:
date - the date
Returns:
the date with the time 00:00:00.000

trace

public static void trace(Object o)
Prints a string representation of an object to the standard output stream.
Parameters:
o - the object to print

trace

public static void trace(String textFormat,
 Object... args)
The same as trace(Object) but allows text format syntax like in String.format(String, Object...) method
See Also:

traceln

public static void traceln()
Prints a line delimiter to the standard output stream.

traceln

public static void traceln(Object o)
Prints a string representation of an object with a line delimiter at the end to the standard output stream.
Parameters:
o - the object to print

traceln

public static void traceln(String textFormat,
 Object... args)
The same as traceln(Object) but allows text format syntax like in String.format(String, Object...) method
See Also:

traceln

public static void traceln(Color color,
 Object o)
Prints a string representation of an object with a line delimiter at the end to the standard output stream. Uses the given color in the model's Developer panel console.
Parameters:
color - the color to print with, or null for the default color
o - the object to print
Since:
8.3

traceln

public static void traceln(Color color,
 String textFormat,
 Object... args)
The same as traceln(Object) but allows text format syntax like in String.format(String, Object...) method. Uses the given color in the model's Developer panel console.
Parameters:
color - the color to print with, or null for the default color
See Also:

logToDB

public void logToDB(StatisticsContinuous statistics,
 String name)
Writes the given element to the corresponding log table of model database.
If logging is enabled this method should be called in #onDestroy() method

logToDB

public void logToDB(StatisticsDiscrete statistics,
 String name)
Writes the given element to the corresponding log table of model database.
If logging is enabled this method should be called in #onDestroy() method

logToDB

public void logToDB(DataSet dataSet,
 String name)
Writes the given element to the corresponding log table of model database.
If logging is enabled this method should be called in #onDestroy() method

logToDB

public void logToDB(HistogramData histogramData,
 String name)
Writes the given element to the corresponding log table of model database.
If logging is enabled this method should be called in #onDestroy() method

traceToDB

public void traceToDB(Object o)
Prints a string representation of an object with a line delimiter at the end to the standard output stream.
Parameters:
o - the object to print

traceToDB

public void traceToDB(String textFormat,
 Object... args)
The same as traceln(Object) but allows text format syntax like in String.format(String, Object...) method
See Also:

setDefaultRandomGenerator

public void setDefaultRandomGenerator(Random r)
Sets the random number generator used by all probability distributions by default, i.e. if no particular generator is specified in the call to a probability distribution function. Only the Random.nextDouble() and Random.nextGaussian() methods of the specified random number generator are called.
Parameters:
r - new random number generator.
See Also:
getDefaultRandomGenerator()

getDefaultRandomGenerator

public Random getDefaultRandomGenerator()
Retrieves the random number generator used by all probability distributions by default, i.e. if no particular generator is specified in the call to a probability distribution function.
Specified by:
getDefaultRandomGenerator in interface UtilitiesRandom
Returns:
the default random number generator.
See Also:

randomColor

public Color randomColor()
Returns random standard color, one of possible standard colors
Returns:
random standard color

getRandom

@AnyLogicLegacyAPI
public <T> T getRandom(Collection<T> collection)
Same as #randomFrom(Collection)

getRandom

@AnyLogicLegacyAPI
public static <T> T getRandom(Collection<T> collection,
 Random r)
Same as #randomFrom(Collection, Random)

uniform

public static double uniform(Random r)
Generates a random value uniformly distributed on the interval [0,1), using the specified random number generator.
Parameters:
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

uniform_pos

public static double uniform_pos(Random r)
Generates a positive random value uniformly distributed on the interval (0,1), using the specified random number generator.
Parameters:
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

uniform

public static double uniform(double min,
 double max,
 Random r)
Generates a sample of the Uniform distribution on the interval [min, max) using the specified random number generator. For more details see UtilitiesRandom.uniform(double,double).
Parameters:
min - the minimum x value (included into the interval).
max - the maximum x value (excluded from the interval).
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

uniform_discr

public static int uniform_discr(int min,
 int max,
 Random r)
Generates a sample of the Discrete Uniform distribution on the interval [min, max] using the specified random number generator, both 0 and max included! For more details see UtilitiesRandom.uniform_discr(int,int).
Parameters:
min - the minimum x value (included into the interval).
max - the maximum x value (also included into the interval).
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

randomTrue

public static boolean randomTrue(double p,
 Random r)
Generates true with the given probability p using the specified random number generator.
For more details see UtilitiesRandom.randomTrue(double)
Parameters:
p - the probability of true.
r - the random number generator.
Returns:
true with probability p, false with probability 1 - p.
See Also:

randomFalse

public static boolean randomFalse(double p,
 Random r)
Generates false with the given probability p using the specified random number generator.
For more details see UtilitiesRandom.randomFalse(double)
Parameters:
p - the probability of false.
r - the random number generator.
Returns:
false with probability p, true with probability 1 - p
See Also:

randomFrom

public static <T> T randomFrom(Iterable<T> collection,
 Random r)
Returns the randomly chosen element of the given collection. Uses the specified random number generator to choose the element.
For more details see UtilitiesRandom.randomFrom(Iterable)
Parameters:
collection - the collection to select an element from
r - the random number generator.
Returns:
the randomly chosen element or null, if collection is empty
See Also:
UtilitiesRandom

randomWhere

public static <T> T randomWhere(Iterable<T> collection,
 Predicate<T> condition,
 Random r)
Returns the randomly chosen element of the given collection which meets the given condition. Uses the specified random number generator to choose the element.
For more details see UtilitiesRandom.randomWhere(Iterable, Predicate)
Parameters:
collection - the collection to select an element from
condition - the condition to test
r - the random number generator.
Returns:
the randomly chosen element or null, if collection is empty
See Also:
UtilitiesRandom

randomFrom

public static <T> T randomFrom(T[] array,
 Random r)
Returns the randomly chosen element of the given array. Uses the specified random number generator to choose the element.
For more details see #randomFrom(T[])
Parameters:
array - the array to select an element from
r - the random number generator
Returns:
the randomly chosen element or null, if the array is empty
See Also:
UtilitiesRandom

randomWhere

public static <T> T randomWhere(T[] array,
 Predicate<T> condition,
 Random r)
Returns the randomly chosen element of the given array which meets the given condition. Uses the specified random number generator to choose the element.
For more details see #randomFrom(T[])
Parameters:
array - the array to select an element from
condition - the condition to test
r - the random number generator
Returns:
the randomly chosen element or null, if the array is empty
See Also:
UtilitiesRandom

randomFrom

public static <T extends Enum<T>> T randomFrom(Class<T> enumeration,
 Random r)
Returns the randomly chosen enumeration constant. Uses the specified random number generator to choose the constant.
Throws NullPointerException if the given class is null or not an enumeration class
Parameters:
enumeration - the enumeration class
r - the random number generator
Returns:
the randomly chosen enumeration constant
See Also:
UtilitiesRandom

randomlyCreate

public static <T> T randomlyCreate(Random r,
 Supplier<? extends T>... constructors)
Creates a randomly chosen object using one of the given constructors. The choice is made using the specified random number generator. Example usage (in the Source.newCar field of Rail Library):
 randomlyCreate( myRandom,
        OpenCar::new,
        BoxCar::new,
        HopperCar::new
 )
Parameters:
constructors - constructors or other functions / lambda expressions which return object instances
Returns:
randomly chosen object, or null if there are no constructors provided
Since:
7.3.5
See Also:
UtilitiesRandom

randomlyCreate

public static <T> T randomlyCreate(Random r,
 Class<? extends T>... classes)
Creates a randomly chosen object using one of the given constructors. The choice is made using the specified random number generator. Example usage (in the Source.newCar field of Rail Library):
 randomlyCreate( myRandom,
        OpenCar.class,
        BoxCar.class,
        HopperCar.class
 )
Parameters:
classes - object classes
Returns:
randomly chosen and created object, or null if there are no classes provided
Since:
7.3.5
See Also:
UtilitiesRandom

bernoulli

public static int bernoulli(double p,
 Random r)
Generates a sample of the Bernoulli distribution using the specified random number generator. For more details see UtilitiesRandom.bernoulli(double).
Parameters:
p - the probability of 1.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

beta

public static double beta(double p,
 double q,
 double min,
 double max,
 Random r)
Generates a sample of the Beta distribution using the specified random number generator. For more details see UtilitiesRandom.beta(double,double,double,double).
Parameters:
p - the lower shape parameter > 0.
q - the upper shape parameter > 0.
min - the minimum x value.
max - the maximum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

beta

public static double beta(double min,
 double max,
 double p,
 double q,
 double shift,
 double stretch,
 Random r)
Generates a sample of truncated Beta distribution using the specified random number generator.
Distribution beta(p, q, 0, 1) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see UtilitiesRandom.beta(double, double, double, double)
Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use -infinity for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use +infinity for "No limit".
p - the lower shape parameter > 0. Also known as alpha parameter
q - the upper shape parameter > 0. Also known as beta parameter
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

binomial

public static int binomial(double p,
 int n,
 Random r)
Generates a sample of the Binomial distribution using the specified random number generator.
Parameters:
p - the probability of the event occurrence.
n - the number of trials.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

binomial

public static double binomial(double min,
 double max,
 double p,
 double n,
 double shift,
 double stretch,
 Random r)
Generates a sample of truncated Binomial distribution using the specified random number generator.
Distribution binomial(p, n) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see UtilitiesRandom.binomial(double, int)
Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use -infinity for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use +infinity for "No limit".
p - the probability of the event occurrence.
n - the number of trials. If n is not an integer it will be rounded to the nearest integer.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample, note that in common case it is not an integer (because of stretching).
See Also:
UtilitiesRandom

cauchy

public static double cauchy(double lambda,
 double theta,
 Random r)
Generates a sample of the Cauchy distribution using the specified random number generator. For more details see UtilitiesRandom.cauchy(double,double).
Parameters:
lambda - the scaling parameter > 0.
theta - the mode, or central peak position.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

chi2

public static double chi2(double nu,
 double min,
 Random r)
Generates a sample of the Chi Squared distribution using the specified random number generator. For more details see UtilitiesRandom.chi2(double,double).
Parameters:
nu - the shape parameter.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

erlang

public static double erlang(double beta,
 int m,
 double min,
 Random r)
Generates a sample of the Erlang distribution using the specified random number generator. For more details see UtilitiesRandom.erlang(double,int,double).
Parameters:
beta - the scale factor > 0.
m - the shape factor (positive integer).
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

exponential

public static double exponential(double lambda,
 double min,
 Random r)
Generates a sample of the Exponential distribution using the specified random number generator. For more details see UtilitiesRandom.exponential(double,double).
Parameters:
lambda - the shape parameter.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

exponential

public static double exponential(double min,
 double max,
 double shift,
 double stretch,
 Random r)
Generates a sample of truncated Exponential distribution using the specified random number generator.
Distribution exponential(1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see UtilitiesRandom.exponential(double, double)
Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use -infinity for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use +infinity for "No limit".
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample
See Also:
UtilitiesRandom

gamma

public static double gamma(double alpha,
 double beta,
 double min,
 Random r)
Generates a sample of the Gamma distribution using the specified random number generator. For more details see UtilitiesRandom.gamma(double,double,double).
Parameters:
alpha - the shape parameter > 0.
beta - the scale parameter > 0.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

gamma

public static double gamma(double min,
 double max,
 double alpha,
 double shift,
 double stretch,
 Random r)
Generates a sample of truncated Gamma distribution using the specified random number generator.
Distribution gamma(alpha, 1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see UtilitiesRandom.gamma(double, double, double)
Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use -infinity for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use +infinity for "No limit".
alpha - the shape parameter > 0. Also known as order. If less than 1, then 1 will be used.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample
See Also:
UtilitiesRandom

geometric

public static int geometric(double p,
 Random r)
Generates a sample of the Geometric distribution using the specified random number generator. For more details see UtilitiesRandom.geometric(double).
Parameters:
p - the probability of occurrence.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

hypergeometric

public static int hypergeometric(int ss,
 int dn,
 int ps,
 Random r)
Generates a sample of the Hypergeometric distribution using the specified random number generator. For more details see UtilitiesRandom.hypergeometric(int,int,int).
Parameters:
ss - the sample size.
dn - the number of defects in the population.
ps - the size of the population.
Returns:
the generated sample.
See Also:
UtilitiesRandom

gumbel1

public static double gumbel1(double a,
 double b,
 Random r)
Generates a sample of the Type I Gumbel distribution using the specified random number generator. For more details see UtilitiesRandom.gumbel1(double,double).
Parameters:
a - the 'a' parameter
b - the 'b' parameter
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

gumbel2

public static double gumbel2(double a,
 double b,
 Random r)
Generates a sample of the Type II Gumbel distribution using the specified random number generator. For more details see UtilitiesRandom.gumbel2(double,double).
Parameters:
a - the 'a' parameter
b - the 'b' parameter
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

laplace

public static double laplace(double phi,
 double theta,
 Random r)
Generates a sample of the Laplace distribution using the specified random number generator. For more details see UtilitiesRandom.laplace(double,double).
Parameters:
phi - the scaling parameter.
theta - the mode, or central peak position.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

logarithmic

public static int logarithmic(double theta,
 Random r)
Generates a sample of the Logarithmic distribution using the specified random number generator. For more details see UtilitiesRandom.logarithmic(double).
Parameters:
theta - the shape/scale parameter 0<theta<1
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

logistic

public static double logistic(double beta,
 double alpha,
 Random r)
Generates a sample of the Logistic distribution using the specified random number generator. For more details see UtilitiesRandom.logistic(double,double).
Parameters:
beta - the scale parameter > 0.
alpha - the shift parameter.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

lognormal

public static double lognormal(double mu,
 double sigma,
 double min,
 Random r)
Generates a sample of the Lognormal distribution using the specified random number generator. For more details see UtilitiesRandom.lognormal(double,double,double).
Parameters:
mu - the mean of the included Normal.
sigma - the standard deviation of the included Normal.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

negativeBinomial

public static int negativeBinomial(double p,
 double n,
 Random r)
Generates a sample of the Negative Binomial distribution using the specified random number generator. For more details see UtilitiesRandom.negativeBinomial(double,double).
Parameters:
p - the probability of event (in the interval (0,1)).
n - the number of desired events.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

negativeBinomial

public static double negativeBinomial(double min,
 double max,
 double p,
 double n,
 double shift,
 double stretch,
 Random r)
Generates a sample of truncated Negative Binomial distribution using the specified random number generator.
Distribution negativeBinomial(p, n) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see UtilitiesRandom.negativeBinomial(double, double)
Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use -infinity for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use +infinity for "No limit".
p - the probability of the event occurrence.
n - the number of trials. If n is not an integer it will be rounded to the nearest integer.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample
See Also:
UtilitiesRandom

normal

public static double normal(double sigma,
 double mean,
 Random r)
Generates a sample of the Normal distribution using the specified random number generator. For more details see UtilitiesRandom.normal(double,double)
Parameters:
sigma - the shape parameter = standard deviation.
mean - the shift parameter = mean value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

normal

public static double normal(double min,
 double max,
 double shift,
 double stretch,
 Random r)
Generates a sample of truncated Normal distribution using the specified random number generator.
Distribution normal(1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see UtilitiesRandom.normal(double, double)
Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use -infinity for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use +infinity for "No limit".
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right = mean value
stretch - the stretch parameter that indicates how much the distribution will be stretched = standard deviation
r - the random number generator.
Returns:
the generated sample
See Also:
UtilitiesRandom

pareto

public static double pareto(double alpha,
 double min,
 Random r)
Generates a sample of the Pareto distribution using the specified random number generator. For more details see UtilitiesRandom.pareto(double,double).
Parameters:
alpha - the scale parameter > 0.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

pert

public static double pert(double min,
 double max,
 double mode,
 Random r)
Generates a sample of the PERT distribution using the specified random number generator. For more details see UtilitiesRandom.pert(double, double, double)
Parameters:
min - the minimum x value.
mode - the most likely x value.
max - the maximum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

poisson

public static int poisson(double lambda,
 Random r)
Generates a sample of the Poisson distribution using the specified random number generator. For more details see UtilitiesRandom.poisson(double).
Parameters:
lambda - the rate of occurrence.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

poisson

public static double poisson(double min,
 double max,
 double mean,
 double shift,
 double stretch,
 Random r)
Generates a sample of truncated Poisson distribution using the specified random number generator.
Distribution poisson(mean) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see UtilitiesRandom.poisson(double)
Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use -infinity for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use +infinity for "No limit".
mean - the mean value for the distribution = rate of event occurrence
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample, note that in common case it is not an integer (because of stretching).
See Also:
UtilitiesRandom

rayleigh

public static double rayleigh(double sigma,
 double min,
 Random r)
Generates a sample of the Rayleigh distribution using the specified random number generator. For more details see UtilitiesRandom.rayleigh(double,double)
Parameters:
sigma - the scale parameter > 0.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

triangularAV

public static double triangularAV(double average,
 double variability,
 Random r)
Generates a sample of the Triangular distribution with mode set to average.
Defines distribution in the form like "roughly this, +/-20%".
Is equivalent to triangular( average * (1 - variability), average * (1 + variability) ) . For more details see triangular(double, double, double, Random). Uses the specified random number generator.
Parameters:
average - the most likely x value
variability - the percent [0...1] of average representing the half of distribution range, where the generated sample falls
r - the random number generator.
Returns:
the generated sample.
Since:
7.1
See Also:
UtilitiesRandom

triangular

public static double triangular(double min,
 double max,
 double mode,
 Random r)
Generates a sample of the Triangular distribution using the specified random number generator. For more details see UtilitiesRandom.triangular(double,double,double).
Parameters:
min - the minimum x value.
max - the maximum x value.
mode - the most likely x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

triangular

public static double triangular(double min,
 double max,
 double left,
 double mode,
 double right,
 Random r)
Generates a sample of truncated Triangular distribution using the specified random number generator.
Distribution triangular(left, right, mode) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see UtilitiesRandom.triangular(double, double, double)
Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use -infinity for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use +infinity for "No limit".
left - the minimum x value for triangular distribution.
mode - the most likely x value for triangular distribution.
right - the maximum x value for triangular distribution.
r - the random number generator.
Returns:
the generated sample
See Also:
UtilitiesRandom

weibull

public static double weibull(double alpha,
 double beta,
 double min,
 Random r)
Generates a sample of the Weibull distribution using the specified random number generator. For more details see UtilitiesRandom.weibull(double,double,double).
Parameters:
alpha - the shape parameter > 0.
beta - the scale parameter > 0.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.
See Also:
UtilitiesRandom

weibull

public static double weibull(double min,
 double max,
 double alpha,
 double shift,
 double stretch,
 Random r)
Generates a sample of truncated Weibull distribution using the specified random number generator.
Distribution weibull(alpha, stretch, 0) is shifted to the right by shift and then truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see UtilitiesRandom.weibull(double, double, double)
Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use -infinity for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use +infinity for "No limit".
alpha - the shape parameter > 0.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the scale parameter.
r - the random number generator.
Returns:
the generated sample
See Also:
UtilitiesRandom

sqr

public static double sqr(double v)
Returns the square of the given value (v2)
Parameters:
v - the value
Returns:
v * v
See Also:
UtilitiesMath

isFinite

public static boolean isFinite(double v)
Returns true if the given value is finite (not +/-infinity or NaN)
Parameters:
v - the value
Returns:
the result of -infinity < v && v < +infinity
See Also:
UtilitiesMath

roundToInt

public static int roundToInt(double v)
Returns int closest to the given value. Unlike Math.round(double), returns int value (instead of long) which may be more convenient for some operations.
The result is equal to the value of the expression:

(int) floor(v + 0.5)
Special cases:
  • If the argument is NaN, the result is 0.
  • If the argument is negative infinity or any value less than or equal to the value of Integer.MIN_VALUE, the result is equal to the value of Integer.MIN_VALUE.
  • If the argument is positive infinity or any value greater than or equal to the value of Integer.MAX_VALUE, the result is equal to the value of Integer.MAX_VALUE.
Parameters:
v - floating-point value to be rounded to a int.
Returns:
the value rounded to the nearest int value.
See Also:
Integer.MAX_VALUEInteger.MIN_VALUEUtilitiesMath

getLength

public static final double getLength(double dx,
 double dy)
Returns the length of the vector (dx, dy)
Parameters:
dx - the x coordinate of the vector
dy - the y coordinate of the vector
Returns:
the length of the vector (dx, dy)

getLengthSq

public static final double getLengthSq(double dx,
 double dy)
Returns the square of length of the vector (dx, dy)
Parameters:
dx - the x coordinate of the vector
dy - the y coordinate of the vector
Returns:
the length of the vector (dx, dy)

getLength

public static final double getLength(double dx,
 double dy,
 double dz)
Returns the length of the vector (dx, dy, dz)
Parameters:
dx - the x coordinate of the vector
dy - the y coordinate of the vector
dz - the z coordinate of the vector
Returns:
the length (euclidean norm) of the vector (dx, dy, dz)

getLengthSq

public static final double getLengthSq(double dx,
 double dy,
 double dz)
Returns the square of length of the vector (dx, dy, dz)
Parameters:
dx - the x coordinate of the vector
dy - the y coordinate of the vector
dz - the z coordinate of the vector
Returns:
the length (euclidean norm) of the vector (dx, dy, dz)

getDistance

public static final double getDistance(double x1,
 double y1,
 double x2,
 double y2)
Returns the distance between two given points (x1, y1) and (x2, y2)
Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
Returns:
the distance between points

getDistanceSq

public static final double getDistanceSq(double x1,
 double y1,
 double x2,
 double y2)
Returns the square of the distance between two given points (x1, y1) and (x2, y2).
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with getDistance()
Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
Returns:
the square of the distance between points

getDistance

public static final double getDistance(double x1,
 double y1,
 double z1,
 double x2,
 double y2,
 double z2)
Returns the distance between two given points (x1, y1, z1) and (x2, y2, z2)
Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
z1 - the z coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
z2 - the z coordinate of the second point
Returns:
the distance between points

getDistanceGIS

public static double getDistanceGIS(double latitude1,
 double longitude1,
 double latitude2,
 double longitude2)
Returns the distance measured in meters between two given points
Parameters:
latitude1 - the latitude of first point measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
longitude1 - the longitude of first point measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latitude2 - the latitude of second point measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
longitude2 - the longitude of second point measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
Returns:
distance between two points measured in meters

getDistanceGIS

public static double getDistanceGIS(double latitude1,
 double longitude1,
 double latitude2,
 double longitude2,
 LengthUnits units)
Returns the distance measured in meters between two given points
Parameters:
latitude1 - the latitude of first point measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
longitude1 - the longitude of first point measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latitude2 - the latitude of second point measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
longitude2 - the longitude of second point measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
units - the units of length
Returns:
distance between two points measured in given length units

getDistanceSq

public static final double getDistanceSq(double x1,
 double y1,
 double z1,
 double x2,
 double y2,
 double z2)
Returns the square of the distance between two given points (x1, y1, z1) and (x2, y2, z2).
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with getDistance()
Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
z1 - the z coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
z2 - the z coordinate of the second point
Returns:
the square of the distance between points

isPointOnTheSameLine

public static final boolean isPointOnTheSameLine(double x1,
 double y1,
 double x2,
 double y2,
 double x3,
 double y3)
Tests if the three point lie on the same line
Parameters:
x1 - the X coordinate of point 1
y1 - the Y coordinate of point 1
x2 - the X coordinate of point 2
y2 - the Y coordinate of point 2
x3 - the X coordinate of point 3
y3 - the Y coordinate of point 3
Returns:
true if 3 points lie on one line, otherwise false
Since:
6.8

isPointInsideRay

public static final boolean isPointInsideRay(double x1,
 double y1,
 double x2,
 double y2,
 double px,
 double py)
Tests if the specified point is inside the given ray.
Parameters:
x1 - the x coordinate of the start point of the ray
y1 - the y coordinate of the start point of the ray
x2 - the x coordinate of some point belonging the ray
y2 - the y coordinate of some point belonging the ray
px - the X coordinate of the point to test
py - the Y coordinate of the point to test
Returns:
true if the point is lying on the ray, otherwise false
Since:
7.0

isPointInsideSegment

public static final boolean isPointInsideSegment(double x1,
 double y1,
 double x2,
 double y2,
 double px,
 double py)
Tests if the specified point is inside the given segment.
Parameters:
x1 - the x coordinate of the first point of the segment
y1 - the y coordinate of the first point of the segment
x2 - the x coordinate of the second point of the segment
y2 - the y coordinate of the second point of the segment
px - the X coordinate of the point to test
py - the Y coordinate of the point to test
Returns:
true if the point is within the segment, otherwise false
Since:
7.0

isPointInsideRectangle

public static final boolean isPointInsideRectangle(double rx,
 double ry,
 double rw,
 double rh,
 double px,
 double py)
Tests if the specified point is inside the given rectangle.
Parameters:
rx - the X coordinate of top-left corner of the rectangle
ry - the Y coordinate of top-left corner of the rectangle
rw - the width of the rectangle
rh - the height of the rectangle
px - the X coordinate of the point to test
py - the Y coordinate of the point to test
Returns:
true if the point is within the rectangle boundary, otherwise false
Since:
6.8

isLineIntersectingLine

public static final boolean isLineIntersectingLine(double x1,
 double y1,
 double x2,
 double y2,
 double x3,
 double y3,
 double x4,
 double y4)
Tests if the line segment from (x1,y1) to (x2,y2) intersects the line segment from (x3,y3) to (x4,y4).
Parameters:
x1 - the X coordinate of the start point of the first specified line segment
y1 - the Y coordinate of the start point of the first specified line segment
x2 - the X coordinate of the end point of the first specified line segment
y2 - the Y coordinate of the end point of the first specified line segment
x3 - the X coordinate of the start point of the second specified line segment
y3 - the Y coordinate of the start point of the second specified line segment
x4 - the X coordinate of the end point of the second specified line segment
y4 - the Y coordinate of the end point of the second specified line segment
Returns:
true if the first specified line segment and the second specified line segment intersect each other; false otherwise.
Since:
6.8

isRayIntersectingSegment

public static final boolean isRayIntersectingSegment(double rx1,
 double ry1,
 double rx2,
 double ry2,
 double sx1,
 double sy1,
 double sx2,
 double sy2)
Tests if the ray from (rx1,ry1) in direction to (rx2,ry2) intersects the line segment from (lx1,ly1) to (lx2,ly2).
Parameters:
rx1 - the X coordinate of the start point of the ray
ry1 - the Y coordinate of the start point of the ray
rx2 - the X coordinate of some point on the ray
ry2 - the Y coordinate of some point on the ray
sx1 - the X coordinate of the start point of the line segment
sy1 - the Y coordinate of the start point of the line segment
sx2 - the X coordinate of the end point of the segment
sy2 - the Y coordinate of the end point of the segment
Returns:
true if the first specified ray and the second specified line segment intersect each other; false otherwise.
Since:
7.0

isLineIntersectingRectangle

public static final boolean isLineIntersectingRectangle(double x1,
 double y1,
 double x2,
 double y2,
 double rx,
 double ry,
 double rw,
 double rh)
Check if the line intersects the given rectangle
Parameters:
x1 - the X coordinate of the start point of the specified line
y1 - the Y coordinate of the start point of the specified line
x2 - the X coordinate of the end point of the specified line
y2 - the Y coordinate of the end point of the specified line
rx - the X coordinate of top-left corner of the rectangle
ry - the Y coordinate of top-left corner of the rectangle
rw - the width of the rectangle
rh - the height of the rectangle
Returns:
true if the line intersects rectangle (has at least one common point, even lying on the rectangle's boundary)
Since:
6.8

getDistanceFromPointToLine

public static final double getDistanceFromPointToLine(double x1,
 double y1,
 double x2,
 double y2,
 double px,
 double py)
Returns the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.
Parameters:
x1 - the X coordinate of the start point of the specified line
y1 - the Y coordinate of the start point of the specified line
x2 - the X coordinate of the end point of the specified line
y2 - the Y coordinate of the end point of the specified line
px - the X coordinate of the specified point being measured against the specified line
py - the Y coordinate of the specified point being measured against the specified line
Returns:
a double value that is the distance from the specified point to the specified line.
Since:
6.8
See Also:

getDistanceFromPointToLineSq

public static final double getDistanceFromPointToLineSq(double x1,
 double y1,
 double x2,
 double y2,
 double px,
 double py)
Returns the square of the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.
Parameters:
x1 - the X coordinate of the start point of the specified line
y1 - the Y coordinate of the start point of the specified line
x2 - the X coordinate of the end point of the specified line
y2 - the Y coordinate of the end point of the specified line
px - the X coordinate of the specified point being measured against the specified line
py - the Y coordinate of the specified point being measured against the specified line
Returns:
a double value that is the square of the distance from the specified point to the specified line.
Since:
6.8
See Also:

getDistanceFromPointToSegment

public static final double getDistanceFromPointToSegment(double x1,
 double y1,
 double x2,
 double y2,
 double px,
 double py)
Returns the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.
Parameters:
x1 - the X coordinate of the start point of the specified line segment
y1 - the Y coordinate of the start point of the specified line segment
x2 - the X coordinate of the end point of the specified line segment
y2 - the Y coordinate of the end point of the specified line segment
px - the X coordinate of the specified point being measured against the specified line segment
py - the Y coordinate of the specified point being measured against the specified line segment
Returns:
a double value that is the distance from the specified point to the specified line segment.
Since:
6.8
See Also:

getDistanceFromPointToSegmentSq

public static final double getDistanceFromPointToSegmentSq(double x1,
 double y1,
 double x2,
 double y2,
 double px,
 double py)
Returns the square of the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.
Parameters:
x1 - the X coordinate of the start point of the specified line segment
y1 - the Y coordinate of the start point of the specified line segment
x2 - the X coordinate of the end point of the specified line segment
y2 - the Y coordinate of the end point of the specified line segment
px - the X coordinate of the specified point being measured against the specified line segment
py - the Y coordinate of the specified point being measured against the specified line segment
Returns:
a double value that is the square of the distance from the specified point to the specified line segment.
Since:
6.8
See Also:

getDistanceFromPointToSegment

public static final double getDistanceFromPointToSegment(double x1,
 double y1,
 double z1,
 double x2,
 double y2,
 double z2,
 double px,
 double py,
 double pz)
Returns the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.
Parameters:
x1 - the X coordinate of the start point of the specified line segment
y1 - the Y coordinate of the start point of the specified line segment
z1 - the Z coordinate of the start point of the specified line segment
x2 - the X coordinate of the end point of the specified line segment
y2 - the Y coordinate of the end point of the specified line segment
z2 - the Z coordinate of the end point of the specified line segment
px - the X coordinate of the specified point being measured against the specified line segment
py - the Y coordinate of the specified point being measured against the specified line segment
pz - the Z coordinate of the specified point being measured against the specified line segment
Returns:
a double value that is the distance from the specified point to the specified line segment.
Since:
7.0
See Also:

getDistanceFromPointToSegmentSq

public static final double getDistanceFromPointToSegmentSq(double x1,
 double y1,
 double z1,
 double x2,
 double y2,
 double z2,
 double px,
 double py,
 double pz)
Returns the square of the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.
Parameters:
x1 - the X coordinate of the start point of the specified line segment
y1 - the Y coordinate of the start point of the specified line segment
x2 - the X coordinate of the end point of the specified line segment
y2 - the Y coordinate of the end point of the specified line segment
px - the X coordinate of the specified point being measured against the specified line segment
py - the Y coordinate of the specified point being measured against the specified line segment
Returns:
a double value that is the square of the distance from the specified point to the specified line segment.
Since:
7.0
See Also:

getNearestPointOnSegment

public static final Point getNearestPointOnSegment(Point out,
 double x1,
 double y1,
 double x2,
 double y2,
 double px,
 double py)
Finds a point on a segment that is closest to a given point. It may be either a height point or one of the segment ends.
Z-coordinate of output point isn't changed
Parameters:
out - the point to write result to, may be null - in this case new Point instance will be created
x1 - the x coordinate of the first point of the segment
y1 - the y coordinate of the first point of the segment
x2 - the x coordinate of the second point of the segment
y2 - the y coordinate of the second point of the segment
px - the x coordinate of the given point
py - the y coordinate of the given point
Returns:
out the point on segment
Since:
7.0

createTrajectoryGIS

@Deprecated
public static float[] createTrajectoryGIS(double lonFrom,
 double latFrom,
 double lonTo,
 double latTo,
 int numberOfSegments)
Deprecated.

getNearestPointOnSegment

public static final Point getNearestPointOnSegment(Point out,
 double x1,
 double y1,
 double z1,
 double x2,
 double y2,
 double z2,
 double px,
 double py,
 double pz)
Finds a point on a segment that is closest to a given point. It may be either a height point or one of the segment ends.
Parameters:
out - the point to write result to, may be null - in this case new Point instance will be created
x1 - the x coordinate of the first point of the segment
y1 - the y coordinate of the first point of the segment
z1 - the z coordinate of the first point of the segment
x2 - the x coordinate of the second point of the segment
y2 - the y coordinate of the second point of the segment
z2 - the z coordinate of the second point of the segment
px - the x coordinate of the given point
py - the y coordinate of the given point
pz - the z coordinate of the given point
Returns:
out the point on segment
Since:
7.0

zidz

public static double zidz(double a,
 double b)
Tries to divide the first argument by the second. If the result is infinity or not a number, returns 0, otherwise returns the division result.
Parameters:
a - first value
b - second value
Returns:
division result or 0

xidz

public static double xidz(double a,
 double b,
 double x)
Tries to divide the first argument by the second. If the result is infinity or not a number, returns the third argument, otherwise returns the division result.
Parameters:
a - first value
b - second value
x - defines return result in case of unsuccessful division
Returns:
division result or x

limitMin

public static double limitMin(double min,
 double x)
Returns x if it is greater or equal to min, otherwise returns min. May be more self-explanatory than the function max as explicitly says "x is left-limited by min".
Parameters:
min - left bound
x - the value
Returns:
x or min

limitMin

public static int limitMin(int min,
 int x)
Returns x if it is greater or equal to min, otherwise returns min. May be more self-explanatory than the function max as explicitly says "x is left-limited by min".
Parameters:
min - left bound
x - the value
Returns:
x or min

limitMax

public static double limitMax(double x,
 double max)
Returns x if it is less or equal to max, otherwise returns max. May be more self-explanatory than the function min as explicitly says "x is right-limited by max".
Parameters:
x - the value
max - right bound
Returns:
x or max

limitMax

public static int limitMax(int x,
 int max)
Returns x if it is less or equal to max, otherwise returns max. May be more self-explanatory than the function min as explicitly says "x is right-limited by max".
Parameters:
x - the value
max - right bound
Returns:
x or max

limit

public static double limit(double min,
 double x,
 double max)
Returns x if it is within [min,max] interval, otherwise returns the closest bound.
Parameters:
min - left bound
x - the value
max - right bound
Returns:
min, x or max

limit

public static int limit(int min,
 int x,
 int max)
Returns x if it is within [min,max] interval, otherwise returns the closest bound.
Parameters:
min - left bound
x - the value
max - right bound
Returns:
min, x or max

gammaLog

public static double gammaLog(double x)
Returns the natural logarithm of the gamma function of x:
ln(Γ(x)).
The gamma function is an extension of the factorial function that works on all positive values of x.
If n is a positive integer, then: Γ(n) = (n - 1)!.

The gammaLog function may be useful in System Dynamics models for computing combinatorial factors.
Parameters:
x - the value.
Returns:
ln(Γ(x))

step

public double step(double height,
 double stepTime)
Returns 0 until the stepTime and then returns height
Parameters:
height -
stepTime -
Returns:
0 until the stepTime and then returns height

pulse

public double pulse(double startTime,
 double pulseWidth)
Returns 1, starting at startTime, and lasting for interval pulseWidth; 0 is returned at all other times.
Parameters:
startTime - the pulse start time
pulseWidth - the length of pulse time interval
Returns:
1 for pulse (when time is within [start, start+width)), otherwise 0

pulseTrain

public double pulseTrain(double startTime,
 double pulseWidth,
 double timeBetweenPulses,
 double endTime)
Returns 1, starting at startTime, and lasting for interval pulseWidth and then repeats this pattern every timeBetweenPulses time until endTime; 0 is returned at all other times.
If the value of timeBetweenPulses is smaller than pulseWidth then 1 will be returned between startTime and endTime.
Parameters:
startTime - the first pulse start time
pulseWidth - the length of pulse time interval
timeBetweenPulses - the length of time interval between starts pulses
endTime - the end time of pulses, since this time the method returns 0
Returns:
1 for pulses, 0 otherwise

ramp

public double ramp(double slope,
 double startTime,
 double endTime)
Returns 0 until the startTime and then slopes upward until endTime and then holds constant.
Parameters:
slope - the coefficient of returned value growth between startTime and endTime
startTime - the start time of the ramp
endTime - the end time of the ramp
Returns:
zero until the startTime, then slope until endTime and then constant.

quantum

public static double quantum(double value,
 double quantizer)
Returns the number smaller (by absolute value) than or equal to value that is an integer multiple of quantizer.
If quantizer is less than or equal to zero, then value is returned unchanged.
For example, quantum(PI, 0.01) will return 3.14
Parameters:
value -
quantizer -
Returns:
quantized value
See Also:
UtilitiesMath

difference

public static double difference(BasicDataSet ds,
 TableFunction f)
Difference function which is always not-negative and reflects difference between given data set and table function in their common arguments range
Parameters:
ds - data set
f - table function with linear interpolation
Returns:
square root of the average of square of difference between linearly interpolated data set and table function
The integration range is the intersection of argument ranges of data set and function

difference

public static double difference(BasicDataSet ds1,
 BasicDataSet ds2)
Difference function which is always not-negative and reflects difference between 2 given data sets in their common arguments range
Parameters:
ds1 - data set
ds2 - data set
Returns:
square root of the average of square of difference between linearly interpolated data sets
The integration range is the intersection of argument ranges of data sets

atan2fast

public static double atan2fast(double y,
 double x)
Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi. Comparing with Math.atan2(double, double), instead of computation of value every time, this method uses precomputed table of values Math.atan2(double, double). Therefore atan2fast is approximately 20 times faster than Math.atan2(double, double). Average error (comparing to Math.atan2(double, double)) is 3e-5 radians, max error is 1e-4 radians. This Method does not accept special arguments like NaN or Infinities. It's recommended to use when you don't need extremely high accuracy and have assurance that your arguments are finite.
Parameters:
y -
x -
Returns:
arctangent(y/x)

toModelTime

public double toModelTime(double value,
 TimeUnits units)
Converts the given timeout (in units) to model time units (used e.g. in basic API of events)
Parameters:
value - the value in the given units
units - units
Returns:
the converted value in model time units

toTimeUnits

public double toTimeUnits(double modelTimeValue,
 TimeUnits units)
Converts the timeout (in model time units) to the given units
Parameters:
modelTimeValue - the value in model time units (used e.g. in basic API of events)
units - units
Returns:
the converted value in the given units

toModelRate

@AnyLogicInternalCodegenAPI
public double toModelRate(double value,
 RateUnits units)
Converts the given rate (in rate units) to units based on model time units (used e.g. in basic API of events)
Parameters:
value - the value in the given units
units - units
Returns:
the value converted to units based on model time units

toRateUnits

@AnyLogicInternalCodegenAPI
public double toRateUnits(double modelRateValue,
 RateUnits units)
Converts the rate (in units based on model time units) to the given units
Parameters:
modelRateValue - the value in units based on model time units (used e.g. in basic API of events)
units - units
Returns:
the converted value in the given units

millisecond

public double millisecond()
Returns a time value equal to one millisecond according to the current time unit setting.
Returns:
a time value equal to one millisecond

second

public double second()
Returns a time value equal to one second according to the current time unit setting.
Returns:
a time value equal to one second

minute

public double minute()
Returns a time value equal to one minute according to the current time unit setting.
Returns:
a time value equal to one minute

hour

public double hour()
Returns a time value equal to one hour according to the current time unit setting.
Returns:
a time value equal to one hour

day

public double day()
Returns a time value equal to 24-hour day according to the current time unit setting. Note that in some cases the returned may be not equal to the real day length (which can be 23 or 25 hours during daylight saving time tweaks). If you need the precise "one day" timeout value, please call toTimeout(AgentConstants.DAY, 1) method
Returns:
a time value equal to 24-hour day

week

public double week()
Returns a time value equal to one week according to the current time unit setting.
Returns:
a time value equal to one week

month

public double month()
Returns a time value equal to 30 days according to the current time unit setting. Note that the returned is not the real month length (which can be 28..31). If you need the precise "one month" timeout value, please call toTimeout(AgentConstants.MONTH, 1) method
Returns:
a time value equal to 30 days

year

public double year()
Returns a time value equal to 365 days according to the current time unit setting. Note that the returned is not the real year length (which can be 366). If you need the precise "one year" timeout value, please call toTimeout(AgentConstants.YEAR, 1) method
Returns:
a time value equal to 365 days

briefInfoOn

public static String briefInfoOn(Object object)
Returns a brief one-line textual information on the given object. Supports most frequently used types: most numeric types, Color, Date, Agent, collections, HyperArray, events, transitions, etc. If the argument type is not supported, returns its default toString(). If the argument is null, returns null.
Parameters:
object - the object to give info on
Returns:
brief one-line textual information on the object

inspectOf

public static String inspectOf(Object object)
Returns a textual info on the object that can be displayed in the multi-line Inspect window. This info is an extended version of what is given by briefInfoOn().
Parameters:
object - the object being inspected
Returns:
an extended textual info on the object

getFullName

public static String getFullName(Agent agent)
Returns the name of the agent prefixed by the path from the top-level agent to this one. Or null if the given agent is null.
This is a convenient function for formatting full name of some agent when it may be null.
Parameters:
agent - the agent, may be null
Returns:
the full name of the object including path from root or null

getName

public static String getName(Agent agent)
Returns the name of the agent or null if the given agent is null.
This is a convenient function for formatting name of some agent when it may be null.
Parameters:
agent - the agent, may be null
Returns:
the name of the object or null

copyToClipboard

public void copyToClipboard(String text)
Copies the given text to the system clipboard
Due to the security policy of the browser, the actual copying may be preceded by a prompt.
Parameters:
text - the text to copy

copyToClipboard

@Deprecated
public static void copyToClipboard(List<List<Object>> table)
Deprecated.

copyToClipboard

@AnyLogicInternalAPI
public static void copyToClipboard(List<List<Object>> table,
 List<Integer> sqlTypes)

format

public static String format(double value)
Formats a double value using the default AnyLogic formatter
Parameters:
value - the double value to be formatted.
Returns:
the string containing the formatted value

format

public static String format(double value,
 IUnits<?> units)
Formats a double value with units, using the default AnyLogic formatter
Parameters:
value - the double value to be formatted.
units - units
Returns:
the string containing the formatted value
Since:
8.0

format

public static String format(int value)
Formats an integer value using the default AnyLogic formatter
Parameters:
value - the integer value to be formatted.
Returns:
the string containing the formatted value

format

public static String format(long value)
Formats a long value using the default AnyLogic formatter
Parameters:
value - the long value to be formatted.
Returns:
the string containing the formatted value

format

public static String format(Date date)
Formats a date using the default AnyLogic formatter
Parameters:
date - the date to be formatted.
Returns:
the string containing the formatted value

formatDayOfWeek

public static String formatDayOfWeek(int dayOfWeek,
 boolean fullName)
Returns the full or short name of the weekday
Parameters:
dayOfWeek - one of MONDAY, TUESDAY, ... constants
fullName - if true, then returns the full name ("Monday", "Tuesday", etc.), otherwise - short ("Mon", "Tue", etc.)
Returns:
the name of the weekday

formatMonth

public static String formatMonth(int month,
 boolean fullName)
Returns the full or short name of the month
Parameters:
month - one of JANUARY, FEBRUARY, ... constants
fullName - if true, then returns the full name ("January", "February", etc.), otherwise - short ("Jan", "Feb", etc.)
Returns:
the name of the month

formatLengthUnits

public static String formatLengthUnits(LengthUnits unit,
 boolean fullName)
Returns the full or short name of the length units
Parameters:
unit - length units
fullName - if true, then returns the full name ("meter", "foot", etc.), otherwise - short ("m", "ft", etc.)
Returns:
the name of the units

formatAmountUnits

public static String formatAmountUnits(double value,
 AmountUnits units)
Converts value to required units and turns it into String
Parameters:
value - value in cubic meters or kilograms
units - required units
Returns:
string representation

formatFlowRateUnits

public static String formatFlowRateUnits(double value,
 FlowRateUnits units)
Converts value to required units and turns it into String
Parameters:
value - value in cubic meters per second or kilograms per second
units - required units
Returns:
string representation

formatLengthUnits

public static String formatLengthUnits(double value,
 LengthUnits units)
Converts value to required units and turns it into String
Parameters:
value - value in meters
units - required units
Returns:
string representation

formatSpeedUnits

public static String formatSpeedUnits(double value,
 SpeedUnits units)
Converts value to required units and turns it into String
Parameters:
value - value in meters per second
units - required units
Returns:
string representation

format

public static String format(boolean value)
Formats a boolean value
Parameters:
value - the boolean value to be formatted.
Returns:
the string containing the formatted value ("true" or "false")

format

public static String format(char value)
Formats a character to String
Parameters:
value - the character value to be formatted.
Returns:
the string containing the formatted value

formatTimeInterval

public String formatTimeInterval(double dt)
Returns a string representation of a given time interval, according to the current time unit settings, in the form 123 days 21h 0'56".
Parameters:
dt - the time interval
Returns:
string representation of the time interval

convertMarkupSegmentDescriptors_xjal

@AnyLogicInternalCodegenAPI
public static MarkupSegment[] convertMarkupSegmentDescriptors_xjal(MarkupSegmentDescriptor[] descriptors)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.

getCanonicalPath

@AnyLogicInternalAPI
public static String getCanonicalPath(File file)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Tries getting canonical path for the given file, on any error return absolute path
Parameters:
file -
Returns:
canonical path of the given file, if available
Since:
7.2

findExistingFile

@AnyLogicInternalAPI
public static String findExistingFile(String filePath)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Since:
7.2

formatLongitude

public static String formatLongitude(double degrees)
Formats longitude
Parameters:
degrees - the longitude in decimal degrees
Returns:
formatted longitude, e.g. E30°20'0"

formatLatitude

public static String formatLatitude(double degrees)
Formats latitude
Parameters:
degrees - the latitude in decimal degrees
Returns:
formatted latitude, e.g. N59°56'0"

formatGeoHeading

public static String formatGeoHeading(double radians)
Formats given heading angle (measured in radians CW, starting from North direction) as human-readable geographical heading (azimuth). E.g. PI / 7 will be formatted as "26° NNE"
Parameters:
radians - the heading angle (measured in radians CW, starting from North direction)
Returns:
formatted human-readable geographical heading (angle in degrees CW from North)

layoutTypeToString

@Deprecated
public static String layoutTypeToString(LayoutType layoutType)
Deprecated.
please use LayoutType.formatName() instead

dirToAngle

public static double dirToAngle(CellDirection dir)
Returns the angle value corresponding to the given direction
Parameters:
dir - the direction constant
Returns:
the angle value (from 0 to 2*PI)

toLatitude

public static double toLatitude(int degrees,
 int minutes,
 double seconds,
 boolean northOrSouth)
Converts latitude from human-readable format (e.g. 59° 56' 0" North) to format used in the model
Parameters:
degrees - number of degrees, 0...90
minutes - number of minutes (1/60 of degree), 0...59
seconds - number of seconds (1/60 of minute), 0 <= seconds < 60
northOrSouth - true for North, false for South
Returns:
the resulting latitude, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

toLongitude

public static double toLongitude(int degrees,
 int minutes,
 double seconds,
 boolean eastOrWest)
Converts longitude from human-readable format (e.g. 30° 20' 0" East) to format used in the model
Parameters:
degrees - number of degrees, 0...180
minutes - number of minutes (1/60 of degree), 0...59
seconds - number of seconds (1/60 of minute), 0 <= seconds < 60
eastOrWest - true for East, false for West
Returns:
the resulting longitude, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

toDate

public static Date toDate(int year,
 int month,
 int day)
Returns the date in the default time zone with given field values and the time set to a midnight.
Parameters:
year - the year
month - the month, is 0-based. e.g., 0 for January.
Following values may be used:
day - the day of the month
Since:
8.3

toDate

public static Date toDate(int year,
 int month,
 int day,
 int hourOfDay,
 int minute,
 int second)
Returns the date in the default time zone with given field values.
Parameters:
year - the year
month - the month, is 0-based. e.g., 0 for January.
Following values may be used:
day - the day of the month
hourOfDay - the hour of day (using 24-hour clock)
minute - the minute
second - the second

toDate

public static Date toDate(String dateFormat,
 String text)
Parses the date from the given string using date format pattern. Throws error in the format is wrong or text can't be parsed.
Parameters:
dateFormat - the date format pattern, for example: "MM/dd/yyyy HH:ss" for more details see the documentation or SimpleDateFormat class. Here are the most used symbols.
Symbol Date/Time Component Examples
y Year 1994; 94
M Month in year June; Jun; 06
d Day in month 27
a Am/pm marker AM
H Hour in day (0-23) 17
h Hour in am/pm (1-12) 12
m Minute in hour 35
s Second in minute 15
S Millisecond 123
text - the text to be parsed as a date
Returns:
the successfully parsed date
Since:
8.3

getDateWithTimeNextTo

public static Date getDateWithTimeNextTo(Date date,
 int hourOfDay,
 int minute,
 int second)
Returns the date which the next date after the given date and has the specified time (in the default time zone)
Parameters:
date - the date
hourOfDay - the hour of day (using 24-hour clock)
minute - the minute
second - the second
Returns:
the date with the given time

toDateInMillis

public static long toDateInMillis(int year,
 int month,
 int day,
 int hourOfDay,
 int minute,
 int second)
Same as toDate(int, int, int, int, int, int) but returns the date in its milliseconds representation (see Date.getTime()), i.e. the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the date.
See Also:

createURL_xjal

@AnyLogicInternalCodegenAPI
public static URL createURL_xjal(String url)
Creates an URL object from the String representation
Parameters:
url - the String to parse as a URL.
Returns:
an URL object

prepareBeforeExperimentStart_xjal

@AnyLogicInternalCodegenAPI
public static void prepareBeforeExperimentStart_xjal(Class<?> experimentClass)
This method is internal and isn't intended to be called by user (may be removed in future releases)

joinArrays_xjal

@AnyLogicInternalCodegenAPI
public static int[] joinArrays_xjal(boolean replaceAlways,
 boolean replaceWithNotEmpty,
 int[] a1,
 int[] a2)
This method is internal and isn't intended to be called by user (may be removed in future releases)

roundToDecimal

public static double roundToDecimal(double v,
 int nDecimalDigits)
Rounds the value to the given precision. Returns the number closest to the given value, retaining the given number of decimal digits in the fractional / integer part.
The result is equal to the value of the expression:

floor(v * 10nDecimalDigits+ 0.5) / 10nDecimalDigits
Parameters:
v - floating-point value to be rounded to the given precision.
nDecimalDigits - if positive, fractional part will be affected, if negative, integer part will be
Returns:
the value rounded to the given precision
Since:
7.3
See Also:
UtilitiesMath

getPerformanceParallelWorkersCount_xjal

@AnyLogicLegacyAPI
public static int getPerformanceParallelWorkersCount_xjal()
Returns number of processors (threads) when running parallel (multi-thread) experiments (with multiple runs) and some other features supporting parallel execution.
To get the number of processors reported by Java virtual machine, please use Runtime.getRuntime().availableProcessors() Please note that both methods shouldn't be generally used in the model logic because their results are inpredictable, not reproducible and depend on the underlying machine and AnyLogic installation
Returns:
the number of processors configured by AnyLogic

toStringAlignedNameValues

@AnyLogicInternalAPI
public static String toStringAlignedNameValues(int minNameLength,
 Object... nameValueRows)