com.xj.anylogic.engine
Class ExperimentOptimization<ROOT extends ActiveObject>

java.lang.Object
  extended by com.xj.anylogic.engine.Presentable
      extended by com.xj.anylogic.engine.Utilities
          extended by com.xj.anylogic.engine.Experiment<ROOT>
              extended by com.xj.anylogic.engine.ExperimentOptimization<ROOT>
Type Parameters:
ROOT - class of root object
All Implemented Interfaces:
java.io.Serializable

public abstract class ExperimentOptimization<ROOT extends ActiveObject>
extends Experiment<ROOT>

Experiment used to search for optimal solutions. Uses OptQuest optimizer. To use this experiment you need to subclass from it and define the methods setupRootParameters(ActiveObject, boolean) which needs to retrieve the parameter values suggested by OptQuest and Experiment.onEngineFinished() to set the objective according to simulation output.

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
Serialized Form

Field Summary
static int CONFIDENCE_LEVEL_80
          Confidence level constant 80%
static int CONFIDENCE_LEVEL_90
          Confidence level constant 90%
static int CONFIDENCE_LEVEL_95
          Confidence level constant 95%
static int CONFIDENCE_LEVEL_98
          Confidence level constant 98%
static int CONFIDENCE_LEVEL_99
          Confidence level constant 99%
static int CONFIDENCE_LEVEL_99_9
          Confidence level constant 99.9%
 
Fields inherited from class com.xj.anylogic.engine.Experiment
ERROR, FINISHED, IDLE, modelExecutionCommandQueue, mutexModelActionQueue, OPEN_RESULTS, OPEN_SNAPSHOT, PAUSE, PAUSED, PLEASE_WAIT, RUN, RUNNING, SAVE_RESULTS, SAVE_SNAPSHOT, STEP, STOP
 
Fields inherited from class com.xj.anylogic.engine.Utilities
AM, APRIL, AUGUST, DAY, DECEMBER, FEBRUARY, FRIDAY, HOUR, infinity, JANUARY, JULY, JUNE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_SECOND, TIME_UNIT_WEEK, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK, YEAR
 
Fields inherited from class com.xj.anylogic.engine.Presentable
ALIGNMENT_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, CAD_ANTIALIASING, CAD_INVERTED, LINE_STYLE_DASHED, LINE_STYLE_DOTTED, LINE_STYLE_SOLID, NAVIGATION_FULL, NAVIGATION_LIMITED_TO_Z_ABOVE_ZERO, NAVIGATION_NONE, NAVIGATION_ROTATION_ONLY, SHAPE_ARC, SHAPE_BUTTON, SHAPE_CAD, SHAPE_CHART_BAR, SHAPE_CHART_HISTOGRAM, SHAPE_CHART_HISTOGRAM2D, SHAPE_CHART_PIE, SHAPE_CHART_PLOT, SHAPE_CHART_STACK, SHAPE_CHART_TIME_COLOR, SHAPE_CHART_TIME_PLOT, SHAPE_CHART_TIME_STACK, SHAPE_CHECKBOX, SHAPE_COMBOBOX, SHAPE_CURVE, SHAPE_EMBEDDED_OBJECT, SHAPE_FILECHOOSER, SHAPE_GROUP, SHAPE_IMAGE, SHAPE_LINE, SHAPE_LISTBOX, SHAPE_OVAL, SHAPE_PIXEL, SHAPE_POLYLINE, SHAPE_PROGRESSBAR, SHAPE_RADIOBUTTONS, SHAPE_RECTANGLE, SHAPE_ROUNDED_RECTANGLE, SHAPE_SLIDER, SHAPE_TEXT, SHAPE_TEXTFIELD
 
Constructor Summary
ExperimentOptimization()
          Creates the experiment, a new simulation engine, and a new optimizer that will be used throughout the whole experiment execution.
ExperimentOptimization(boolean allowParallelEvaluations)
          Same as ExperimentOptimization() but allows to disable parallel evaluations on multicore/multiprocessor systems (which are enabled by default)
 
Method Summary
 void addConstraint(com.opttek.optquest.COptQuestConstraint constraint)
          Adds the constraint defined by the input parameter to the optimization

This is optimization setup method, user should not call it
 void addConstraint(com.opttek.optquest.COptQuestStringConstraint constraint)
          Adds the string constraint defined by the input parameter to the optimization

This is optimization setup method, user should not call it
 void addLinearConstraintVariable(com.opttek.optquest.COptQuestConstraint constraint, com.opttek.optquest.COptQuestVariable variable, double coefficient)
          Adds a variable and its coefficient to the linear expression
This method is called for each variable that is used in the left hand side expression
For example, the constraint 2*Var1 + 3*Var2 + 1.5*Var3 <= 100 would call addLinearConstraintVariable(Var1,2), addLinearConstraintVariable(Var2, 3) and addLinearConstraintVariable(Var3,1.5)

This is optimization setup method, user should not call it
 void addParameterVariable(com.opttek.optquest.COptQuestVariable variable)
          Adds the variable defined by the input parameter to the optimization

This is optimization setup method, user should not call it
 void addRequirement(com.opttek.optquest.COptQuestRequirement requirement)
          Adds the requirement defined by the input parameter to the optimization

This is optimization setup method, user should not call it
 void addSuggestedSolution()
          This method signals the completion of a suggested solution definition.
static com.opttek.optquest.COptQuestOptimization createOptimization(Engine engine)
          Creates and returns new OptQuest optimization instance for Custom Experiment
This method should only be used in custom experiment code
This method is designed for use in the AnyLogic Professional only
static com.opttek.optquest.COptQuestOptimization createOptimization(Engine engine, OptimizationCallback callback)
          Creates and returns new OptQuest optimization instance for Custom Experiment with objective function defined in a free form using evaluate method of a special callback.
 boolean doesOptimizationExist()
           
 int getBestFeasibleIteration()
          Deprecated. call isBestSolutionFeasible() and check its result:
if it returns true, use getBestIteration();
otherwise there is no best feasible iteration
 double getBestFeasibleObjectiveValue()
          Deprecated. call isBestSolutionFeasible() and check its result:
if it returns true, use getBestObjectiveValue();
otherwise there is no best feasible solution
 double getBestFeasibleParamValue(com.opttek.optquest.COptQuestVariable optimizationParameterVariable)
          Deprecated. call isBestSolutionFeasible() and check its result:
if it returns true, use getBestParamValue(COptQuestVariable);
otherwise there is no best feasible solution
 int getBestFeasibleReplicationsNumber()
          Deprecated. call isBestSolutionFeasible() and check its result:
if it returns true, use getBestReplicationsNumber();
otherwise there is no best feasible solution
 int getBestIteration()
          Returns the iteration that resulted in the best solution thus far
(solution may be infeasible)
Ensure optimization exists before calling this method (doesOptimizationExist())
 double getBestObjectiveValue()
          Returns the value of the objective function for the best solution found thus far
Returned value may be infeasible
Ensure optimization exists before calling this method (doesOptimizationExist())
 double getBestParamValue(com.opttek.optquest.COptQuestVariable optimizationParameterVariable)
          Returns the value of the given optimization parameter variable for the best solution found thus far
(solution may be infeasible)
 int getBestReplicationsNumber()
          Returns the number of replications that were run for the best solution
(solution may be infeasible)
Ensure optimization exists (doesOptimizationExist()) and replications are used (isUseReplications()) before calling this method
 int getCurrentIteration()
          Returns the current value of iteration counter
Ensure optimization exists before calling this method (doesOptimizationExist())
 double getCurrentObjectiveValue()
          Returns the value of the objective function for the current solution
Ensure optimization exists before calling this method (doesOptimizationExist())
 double getCurrentParamValue(com.opttek.optquest.COptQuestVariable optimizationParameterVariable)
          Returns the value of the given optimization parameter variable for the current solution
 int getCurrentReplication()
          Returns the replication number for the current solution being evaluated
Ensure optimization exists (doesOptimizationExist()) and replications are used (isUseReplications()) before calling this method
 Engine getEngine()
          It is strongly recommended not to call this method because of possible parallel execution environment.
 int getMaximumIterations()
          Returns the number of iterations set by setMaximumIterations(int)
 java.lang.Object getMutexRead_xjal()
           
 java.lang.Object getMutexWrite_xjal()
           
 int getNumberOfCompletedIterations()
          Returns the current value of iteration counter
Ensure optimization exists before calling this method (doesOptimizationExist())
 com.opttek.optquest.COptQuestOptimization getOptimization_xjal()
          Returns the optimization engine.
 int getParallelEvaluatorsCount()
          Returns the number of parallel evaluators used in this experiment.
 double getProgress()
          Returns the progress of the experiment: a number between 0 and 1 corresponding to the part of the experiment completed so far (based on iteration count or time limit), or -1 if this cannot be calculated.
 int getRunCount()
          Returns the number of the current simulation run, more precisely the number of times the model was destroyed.
 double getRunTimeSeconds()
          Returns the real duration of the experiment in seconds.
 int getSelectedNthBestIteration()
          Returns the iteration number for the Nth best solution, where the Nth best solution is identified by the method selectNthBestSolution(int)
Ensure optimization exists before calling this method (doesOptimizationExist())
 double getSelectedNthBestObjectiveValue()
          Returns the objective value for the Nth best solution, identified by the method selectNthBestSolution(int)
Ensure optimization exists before calling this method (doesOptimizationExist())
 double getSelectedNthBestParamValue(com.opttek.optquest.COptQuestVariable optimizationParameterVariable)
          Used to retrieve the value of the variable for the solution that produced the Nth best objective value
The Nth best solution is identified by calling selectNthBestSolution(int)
 int getSelectedNthBestReplicationsNumber()
          Returns the number of replications for the Nth best solution, where the Nth best solution is identified by the method selectNthBestSolution(int)
Ensure optimization exists (doesOptimizationExist()) and replications are used (isUseReplications()) before calling this method
 double[] getSimulationProgress_xjal(double[] output)
          This method is not designed to be called by user and may be changed/removed in the future releases.
 int getState()
          Returns the current state of the experiment.
 long getStep()
          Returns the number of events executed by the engine.
 boolean isBestSolutionFeasible()
          Returns true if the best solution satisfies all constraints and requirements
Ensure optimization exists before calling this method (doesOptimizationExist())
 boolean isCommandEnabled(int cmd)
          Checks if a command can be executed.
 boolean isCurrentSolutionBest()
          Returns true if current solution is the best one at this moment
 boolean isCurrentSolutionFeasible()
          Returns true if current solution satisfies all constraints and requirements
Ensure optimization exists before calling this method (doesOptimizationExist())
 boolean isLastReplication()
          Return true if we have run the last replication for the current solution

This is optimization setup method, user should not call it
 boolean isSelectedNthBestSolutionFeasible()
          Returns true if nth best solution satisfies all constraints and requirements
Ensure optimization exists before calling this method (doesOptimizationExist())
 boolean isUseReplications()
          Returns true if optimization uses replications
 void onAfterIteration()
          User's extension point for after iteration code
By default does nothing
 void pause()
          Pauses the model execution.
 void registerPresentation_xjal(Presentation presentation)
          This method isn't designed to be called by user.
 void run()
          Runs the model from the current state.
 void selectNthBestSolution(int bestSolutionIndex)
          Called by the user to identify the Nth best soluiton.
 void setAutoStop(boolean stop)
          Sets the auto stop option.
 void setConstraintEquation(com.opttek.optquest.COptQuestStringConstraint constraint, java.lang.String equation)
          Sets the mathematical expression that defines the constraint

This is optimization setup method, user should not call it
 void setCurrentObjectiveValue(double value)
          Used to set the value of the objective for the current solution.
 void setCurrentRequirementValue_xjal(com.opttek.optquest.COptQuestRequirement requirement, double value)
          Used to set the value of the requirement for the current solution.
 void setFixedReplicationsNumber(int replicationsNumber)
          Sets experiment to use a fixed number of replications.
 void setLinearConstraintRHS(com.opttek.optquest.COptQuestConstraint constraint, double value)
          Sets the right hand side value of a linear constraint

This is optimization setup method, user should not call it
 void setLogBufferLength(int length)
           
 void setMaximumIterations(int numberOfIterations)
          Sets the number of iterations the optimization should perform before stopping.
 void setObjectiveMaximize()
          Sets the goal of the optimization to maximize the objective value

This is optimization setup method, user should not call it
 void setObjectiveMinimize()
          Sets the goal of the optimization to minimize the objective value

This is optimization setup method, user should not call it
 void setParameterVariableLowerBound(com.opttek.optquest.COptQuestVariable variable, double value)
          Sets lower bound size for optimization parameter variable

This is optimization setup method, user should not call it
 void setParameterVariableName(com.opttek.optquest.COptQuestVariable variable, java.lang.String name)
          Assigns a name to the variable
Names must be alphanumeric and cannot be a function name

This is optimization setup method, user should not call it
 void setParameterVariableStepSize(com.opttek.optquest.COptQuestVariable variable, double value)
          Sets step size for optimization parameter variable
Used for discrete variables

This is optimization setup method, user should not call it
 void setParameterVariableSuggestedValue(com.opttek.optquest.COptQuestVariable variable, double value)
          Allows the user to suggest a solution by setting a suggested value for each variable
addSuggestedSolution() indicates the suggested solution is complete and should be added to the set of solutions to be evaluated.
 void setParameterVariableUpperBound(com.opttek.optquest.COptQuestVariable variable, double value)
          Sets upper bound size for optimization parameter variable

This is optimization setup method, user should not call it
 void setRejectNonLinear(boolean reject)
          Directs the OptQuest Engine to reject solutions that violate non-linear constraints without performing simulation.
 void setRequirementLowerBound(com.opttek.optquest.COptQuestRequirement requirement, double value)
          Sets the lower bound of requirement to the input value

This is optimization setup method, user should not call it
 void setRequirementUpperBound(com.opttek.optquest.COptQuestRequirement requirement, double value)
          Sets the upper bound of requirement to the input value

This is optimization setup method, user should not call it
abstract  void setupRootParameters(ROOT root, boolean callOnChangeActions)
          Is called to setup parameters of root active object.
 void setUserControlledStop(boolean stop)
          Indicates the user will stop the optimization by calling the stopOptimization() method

This is optimization setup method, user should not call it
 void setUseReplications(boolean useReplications)
          Sets optimization to use replications

This is optimization setup method, user should not call it
 void setVariableReplicationsNumber(int minimumReplications, int maximumReplications, int confidenceLevel)
          Deprecated. This method is deprecated.
Use setVariableReplicationsNumber(int, int, int, double) instead
 void setVariableReplicationsNumber(int minimumReplications, int maximumReplications, int confidenceLevel, double errorPercent)
          Sets experiment to stop replications after the minimum replications when the confidence level is reached (i.e. mean confidence is within the given percentage errorPercent of the value obtained at the last replication) maximum replications number is reached For fixed number of replications use setFixedReplicationsNumber(int)

This is optimization setup method, user should not call it
 void step()
          Performs one step of the model execution.
 void stop()
          Terminates the model execution, destroys and forgets the model and calls garbage collector, but keeps all experiment data.
 void stopOptimization()
          Stops the currently running optimization

This is optimization setup method, user should not call it
 
Methods inherited from class com.xj.anylogic.engine.Experiment
close, createRoot, error, getCommandLineArguments, getName, getPresentation, getSnapshotFileName, getWindowHeight, getWindowWidth, initDefaultRandomNumberGenerator, isLoadRootFromSnapshot, onBeforeSimulationRun, onDestroy_xjal, onDestroy, onEngineFinished, onError, reset, setCommandLineArguments_xjal, setLoadRootFromSnapshot, setName, setup, setupEngine
 
Methods inherited from class com.xj.anylogic.engine.Utilities
bernoulli, bernoulli, beta, beta, beta, beta, beta, binomial, binomial, binomial, binomial, binomial, briefInfoOn, cauchy, cauchy, cauchy, chi2, chi2, chi2, copyToClipboard, createURL_xjal, date, dateToTime, day, difference, difference, differenceInDateUnits, differenceInDateUnits, dropTime, erlang, erlang, erlang, error, exponential, exponential, exponential, exponential, exponential, exponential, format, format, format, format, format, format, formatDayOfWeek, formatGeoHeading, formatLatitude, formatLongitude, formatMonth, formatTimeInterval, gamma_frac, gamma, gamma, gamma, gamma, gamma, gammaLog, geometric, geometric, getAmPm, getAmPm, getDayOfMonth, getDayOfMonth, getDayOfWeek, getDayOfWeek, getDayOfYear, getDefaultRandomGenerator, getDistance, getDistance, getDistanceFromPointToLine, getDistanceFromPointToLineSq, getDistanceFromPointToSegment, getDistanceFromPointToSegmentSq, getDistanceSq, getDistanceSq, getHour, getHour, getHourOfDay, getHourOfDay, getLength, getLength, getMillisecond, getMillisecond, getMinute, getMinute, getMonth, getMonth, getRandom, getRandom, getSecond, getSecond, getTime, getYear, getYear, gumbel1, gumbel1, gumbel2, gumbel2, hour, hypergeometric, hypergeometric, inspectOf, isLineIntersectingLine, isLineIntersectingRectangle, isPointInsideRectangle, isPointOnTheSameLine, laplace, laplace, limit, limitMax, limitMin, logarithmic, logarithmic, logistic, logistic, lognormal, lognormal, millisecond, minute, negativeBinomial, negativeBinomial, negativeBinomial, negativeBinomial, normal, normal, normal, normal, normal, normal, pareto, pareto, pareto, pert, pert, poisson, poisson, poisson, poisson, prepareBeforeExperimentStart_xjal, pulse, pulseTrain, quantum, ramp, randomFalse, randomFalse, randomTrue, randomTrue, rayleigh, rayleigh, rayleigh, second, setDefaultRandomGenerator, sqr, step, time, timeToDate, toDate, toDateInMillis, toLatitude, toLongitude, toTimeout, trace, traceln, traceln, traceln, triangular, triangular, triangular, triangular, triangular, uniform_discr, uniform_discr, uniform_discr, uniform_pos, uniform_pos, uniform, uniform, uniform, uniform, uniform, week, weibull, weibull, weibull, weibull, weibull, xidz, zidz
 
Methods inherited from class com.xj.anylogic.engine.Presentable
contains, drawCollection, drawDatabase, drawDataset, drawExcelFile, drawFunction, drawHistogram2DData, drawHistogramData, drawInsert, drawKeyValueTable, drawModel, drawModelElements, drawPlainVariable, drawPresentation, drawQuery, drawSchedule, drawShape, drawStatistics, drawTableFunction, drawTextFile, drawUpdate, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, finishReadObject_xjal, getExperiment, getNameOfShape, getPersistentShape, getShapeArcAngle, getShapeArcAngle, getShapeArcStartAngle, getShapeArcStartAngle, getShapeCADCustomLayerColors, getShapeCADDrawingAttributes, getShapeCADDrawingAttributes, getShapeCADFileName, getShapeCADFileName, getShapeCADVisibleLayerNames, getShapeChartColorFromDouble, getShapeChartDataColors, getShapeChartDataItems, getShapeChartDataPlotOptions, getShapeChartDataSets, getShapeChartDataTitles, getShapeChartHistogram2DOptions, getShapeChartHistogramOptions, getShapeChartHistograms, getShapeChartHistograms2D, getShapeChartProperties, getShapeControl, getShapeControl, getShapeControlDefaultValueBoolean, getShapeControlDefaultValueBoolean, getShapeControlDefaultValueDouble, getShapeControlDefaultValueDouble, getShapeControlDefaultValueInt, getShapeControlDefaultValueInt, getShapeControlDefaultValueString, getShapeControlDefaultValueString, getShapeControlManager, getShapeControlMaximum, getShapeControlMaximum, getShapeControlMinimum, getShapeControlMinimum, getShapeControlMultipleSelectionMode, getShapeControlMultipleSelectionMode, getShapeControlProgressString, getShapeControlProgressString, getShapeControlTexts, getShapeControlTexts, getShapeControlTexts2D, getShapeControlTexts2D, getShapeControlType, getShapeControlType, getShapeControlValueType, getShapeControlValueType, getShapeEmbeddedObject, getShapeEmbeddedObject, getShapeFillColor, getShapeFillColor, getShapeFont, getShapeFont, getShapeGroupContent, getShapeHeight, getShapeHeight, getShapeImageFileNames, getShapeImageFileNames, getShapeImageNumber, getShapeImageNumber, getShapeLineColor, getShapeLineColor, getShapeLineDx, getShapeLineDx, getShapeLineDy, getShapeLineDy, getShapeLineStyle, getShapeLineStyle, getShapeLineWidth, getShapeLineWidth, getShapeNPoints, getShapeNPoints, getShapePackagePrefix, getShapePointsDx, getShapePointsDx, getShapePointsDy, getShapePointsDy, getShapeRadiusX, getShapeRadiusX, getShapeRadiusY, getShapeRadiusY, getShapeReplication, getShapeRotation, getShapeRotation, getShapeScaleX, getShapeScaleX, getShapeScaleY, getShapeScaleY, getShapeText, getShapeText, getShapeTextAlignment, getShapeTextAlignment, getShapeType, getShapeWidth, getShapeWidth, getShapeX, getShapeX, getShapeY, getShapeY, getViewAreas, iconContains, isShapeCADNegative, isShapeCADNegative, isShapeClosed, isShapeClosed, isShapeControlEnabled, isShapeControlEnabled, isShapeControlVertical, isShapeControlVertical, isShapePublic, isShapeVisible, isShapeWithManualControlPoints, isShapeWithManualControlPoints, modelElementContains, modelElementContains, onClickIconAt, onClickModelAt, onClickPresentationAt, onItemRemoved, onSelectionChanged, onShapeClick, onShapeClickAt, onShapeGroupDraw, presentationContains, readCustomData, setControlValueToDefault, setControlValueToDefault, writeCustomData
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIDENCE_LEVEL_80

public static final int CONFIDENCE_LEVEL_80
Confidence level constant 80%

See Also:
setVariableReplicationsNumber(int, int, int, double), Constant Field Values

CONFIDENCE_LEVEL_90

public static final int CONFIDENCE_LEVEL_90
Confidence level constant 90%

See Also:
setVariableReplicationsNumber(int, int, int, double), Constant Field Values

CONFIDENCE_LEVEL_95

public static final int CONFIDENCE_LEVEL_95
Confidence level constant 95%

See Also:
setVariableReplicationsNumber(int, int, int, double), Constant Field Values

CONFIDENCE_LEVEL_98

public static final int CONFIDENCE_LEVEL_98
Confidence level constant 98%

See Also:
setVariableReplicationsNumber(int, int, int, double), Constant Field Values

CONFIDENCE_LEVEL_99

public static final int CONFIDENCE_LEVEL_99
Confidence level constant 99%

See Also:
setVariableReplicationsNumber(int, int, int, double), Constant Field Values

CONFIDENCE_LEVEL_99_9

public static final int CONFIDENCE_LEVEL_99_9
Confidence level constant 99.9%

See Also:
setVariableReplicationsNumber(int, int, int, double), Constant Field Values
Constructor Detail

ExperimentOptimization

public ExperimentOptimization()
Creates the experiment, a new simulation engine, and a new optimizer that will be used throughout the whole experiment execution. A user-controlled objective is added to the optimizer at this time.


ExperimentOptimization

public ExperimentOptimization(boolean allowParallelEvaluations)
Same as ExperimentOptimization() but allows to disable parallel evaluations on multicore/multiprocessor systems (which are enabled by default)

Parameters:
allowParallelEvaluations - if false, the iterations/replications of experiment will be performed sequentially
See Also:
getParallelEvaluatorsCount()
Method Detail

isCommandEnabled

public boolean isCommandEnabled(int cmd)
Description copied from class: Experiment
Checks if a command can be executed. The possible command ids are: OPEN_RESULTS, SAVE_RESULTS, OPEN_SNAPSHOT, SAVE_SNAPSHOT, RUN, STEP PAUSE, STOP.

Overrides:
isCommandEnabled in class Experiment<ROOT extends ActiveObject>
Parameters:
cmd - the command id
Returns:
true if the command can be executed, false otherwise

getProgress

public final double getProgress()
Returns the progress of the experiment: a number between 0 and 1 corresponding to the part of the experiment completed so far (based on iteration count or time limit), or -1 if this cannot be calculated.

Returns:
the progress of the experiment

doesOptimizationExist

public boolean doesOptimizationExist()

getMaximumIterations

public int getMaximumIterations()
Returns the number of iterations set by setMaximumIterations(int)

Returns:
the total number of iterations

getCurrentIteration

public int getCurrentIteration()
Returns the current value of iteration counter
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
the current value of iteration counter

getNumberOfCompletedIterations

public int getNumberOfCompletedIterations()
Returns the current value of iteration counter
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
the current value of iteration counter

isCurrentSolutionBest

public boolean isCurrentSolutionBest()
Returns true if current solution is the best one at this moment

Returns:
true if current solution is the best one at this moment, false otherwise

getCurrentReplication

public int getCurrentReplication()
Returns the replication number for the current solution being evaluated
Ensure optimization exists (doesOptimizationExist()) and replications are used (isUseReplications()) before calling this method

Returns:
the number of replications run thus far

getCurrentObjectiveValue

public double getCurrentObjectiveValue()
Returns the value of the objective function for the current solution
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
the value of the objective function for the current solution

getCurrentParamValue

public double getCurrentParamValue(com.opttek.optquest.COptQuestVariable optimizationParameterVariable)
Returns the value of the given optimization parameter variable for the current solution

Returns:
the value of the given optimization parameter variable for the current solution

isCurrentSolutionFeasible

public boolean isCurrentSolutionFeasible()
Returns true if current solution satisfies all constraints and requirements
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
true if current solution satisfies all constraints and requirements, false otherwise

getBestIteration

public int getBestIteration()
Returns the iteration that resulted in the best solution thus far
(solution may be infeasible)
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
the iteration that resulted in the best solution
See Also:
isBestSolutionFeasible()

getBestReplicationsNumber

public int getBestReplicationsNumber()
Returns the number of replications that were run for the best solution
(solution may be infeasible)
Ensure optimization exists (doesOptimizationExist()) and replications are used (isUseReplications()) before calling this method

Returns:
the number of replications that were run for the best solution
(solution may be infeasible)
See Also:
isBestSolutionFeasible()

getBestObjectiveValue

public double getBestObjectiveValue()
Returns the value of the objective function for the best solution found thus far
Returned value may be infeasible
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
the value of the objective function for the best solution found thus far
See Also:
isBestSolutionFeasible()

getBestParamValue

public double getBestParamValue(com.opttek.optquest.COptQuestVariable optimizationParameterVariable)
Returns the value of the given optimization parameter variable for the best solution found thus far
(solution may be infeasible)

Returns:
the value of the given optimization parameter variable for the best solution found thus far
See Also:
isBestSolutionFeasible()

isBestSolutionFeasible

public boolean isBestSolutionFeasible()
Returns true if the best solution satisfies all constraints and requirements
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
true if the best solution satisfies all constraints and requirements, false otherwise
See Also:
getBestObjectiveValue()

getBestFeasibleIteration

@Deprecated
public int getBestFeasibleIteration()
Deprecated. call isBestSolutionFeasible() and check its result:
if it returns true, use getBestIteration();
otherwise there is no best feasible iteration

Returns the iteration that resulted in the best feasible solution thus far
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
iteration or -1 if no feasible solution was found

getBestFeasibleReplicationsNumber

@Deprecated
public int getBestFeasibleReplicationsNumber()
Deprecated. call isBestSolutionFeasible() and check its result:
if it returns true, use getBestReplicationsNumber();
otherwise there is no best feasible solution

Returns the number of replications evaluated for the best feasible solution
Ensure optimization exists (doesOptimizationExist()) and replications are used (isUseReplications()) before calling this method

Returns:
number of replications or -1 if no feasible solution was found

getBestFeasibleObjectiveValue

@Deprecated
public double getBestFeasibleObjectiveValue()
Deprecated. call isBestSolutionFeasible() and check its result:
if it returns true, use getBestObjectiveValue();
otherwise there is no best feasible solution

Returns the value of the objective function for the best feasible solution found thus far
May return Double.NaN if no feasible solution was found
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
the value of the objective function for the best feasible solution found thus far
See Also:
getBestFeasibleParamValue(COptQuestVariable)

getBestFeasibleParamValue

@Deprecated
public double getBestFeasibleParamValue(com.opttek.optquest.COptQuestVariable optimizationParameterVariable)
Deprecated. call isBestSolutionFeasible() and check its result:
if it returns true, use getBestParamValue(COptQuestVariable);
otherwise there is no best feasible solution

Returns the value of the given optimization parameter variable for the best feasible solution found thus far
May return Double.NaN if no feasible solution was found
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
the value of the given optimization parameter variable for the best feasible solution found thus far

selectNthBestSolution

public void selectNthBestSolution(int bestSolutionIndex)
Called by the user to identify the Nth best soluiton.
Subsequent calles to getSelectedNthBestObjectiveValue() and getSelectedNthBestParamValue(COptQuestVariable) methods use this setting to identify the solution. This method locates the Nth best solution and sets up data for subsequent calls that retrieve specific pieces of information
Ensure optimization exists before calling this method (doesOptimizationExist())

Parameters:
bestSolutionIndex - 1 for the best solution, 2 for the second best etc.
See Also:
getSelectedNthBestObjectiveValue(), getSelectedNthBestParamValue(COptQuestVariable)

getSelectedNthBestIteration

public int getSelectedNthBestIteration()
Returns the iteration number for the Nth best solution, where the Nth best solution is identified by the method selectNthBestSolution(int)
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
the iteration of the Nth best solution
See Also:
selectNthBestSolution(int)

getSelectedNthBestReplicationsNumber

public int getSelectedNthBestReplicationsNumber()
Returns the number of replications for the Nth best solution, where the Nth best solution is identified by the method selectNthBestSolution(int)
Ensure optimization exists (doesOptimizationExist()) and replications are used (isUseReplications()) before calling this method

Returns:
the number of replications in the nth best solution
See Also:
selectNthBestSolution(int)

getSelectedNthBestObjectiveValue

public double getSelectedNthBestObjectiveValue()
Returns the objective value for the Nth best solution, identified by the method selectNthBestSolution(int)
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
the objective value of the Nth best solution. Returns 0 if the solution doesn't exist
See Also:
selectNthBestSolution(int)

getSelectedNthBestParamValue

public double getSelectedNthBestParamValue(com.opttek.optquest.COptQuestVariable optimizationParameterVariable)
Used to retrieve the value of the variable for the solution that produced the Nth best objective value
The Nth best solution is identified by calling selectNthBestSolution(int)

Parameters:
optimizationParameterVariable -
Returns:
the variable's value for the Nth best solution
See Also:
selectNthBestSolution(int)

isSelectedNthBestSolutionFeasible

public boolean isSelectedNthBestSolutionFeasible()
Returns true if nth best solution satisfies all constraints and requirements
Ensure optimization exists before calling this method (doesOptimizationExist())

Returns:
true if nth best solution satisfies all constraints and requirements, false otherwise
See Also:
selectNthBestSolution(int)

getOptimization_xjal

public com.opttek.optquest.COptQuestOptimization getOptimization_xjal()
Returns the optimization engine. May return null (if experiment hasn't yet been started).
This method is internal and may be removed in future releases

Returns:
the optimization engine instance

setObjectiveMinimize

public void setObjectiveMinimize()
Sets the goal of the optimization to minimize the objective value

This is optimization setup method, user should not call it


setObjectiveMaximize

public void setObjectiveMaximize()
Sets the goal of the optimization to maximize the objective value

This is optimization setup method, user should not call it


setParameterVariableName

public void setParameterVariableName(com.opttek.optquest.COptQuestVariable variable,
                                     java.lang.String name)
Assigns a name to the variable
Names must be alphanumeric and cannot be a function name

This is optimization setup method, user should not call it

Parameters:
variable -
name -

setParameterVariableLowerBound

public void setParameterVariableLowerBound(com.opttek.optquest.COptQuestVariable variable,
                                           double value)
Sets lower bound size for optimization parameter variable

This is optimization setup method, user should not call it

Parameters:
variable -
value -

setParameterVariableUpperBound

public void setParameterVariableUpperBound(com.opttek.optquest.COptQuestVariable variable,
                                           double value)
Sets upper bound size for optimization parameter variable

This is optimization setup method, user should not call it

Parameters:
variable -
value -

setParameterVariableSuggestedValue

public void setParameterVariableSuggestedValue(com.opttek.optquest.COptQuestVariable variable,
                                               double value)
Allows the user to suggest a solution by setting a suggested value for each variable
addSuggestedSolution() indicates the suggested solution is complete and should be added to the set of solutions to be evaluated.

This is optimization setup method, user should not call it

Parameters:
variable -
value -

setParameterVariableStepSize

public void setParameterVariableStepSize(com.opttek.optquest.COptQuestVariable variable,
                                         double value)
Sets step size for optimization parameter variable
Used for discrete variables

This is optimization setup method, user should not call it

Parameters:
variable -
value -

addParameterVariable

public void addParameterVariable(com.opttek.optquest.COptQuestVariable variable)
Adds the variable defined by the input parameter to the optimization

This is optimization setup method, user should not call it

Parameters:
variable -

addSuggestedSolution

public void addSuggestedSolution()
This method signals the completion of a suggested solution definition.
setParameterVariableSuggestedValue(COptQuestVariable, double) is used to set a value for each variable.
This method signals a value has been set for each variable.
The solution is added to the set of suggested solution and will be one of the first solutions evaluated if the optimization has not started.
If the optimization is running, the suggested solution will be one of the next solutions to be evaluated

This is optimization setup method, user should not call it


setLinearConstraintRHS

public void setLinearConstraintRHS(com.opttek.optquest.COptQuestConstraint constraint,
                                   double value)
Sets the right hand side value of a linear constraint

This is optimization setup method, user should not call it

Parameters:
constraint -
value -

addLinearConstraintVariable

public void addLinearConstraintVariable(com.opttek.optquest.COptQuestConstraint constraint,
                                        com.opttek.optquest.COptQuestVariable variable,
                                        double coefficient)
Adds a variable and its coefficient to the linear expression
This method is called for each variable that is used in the left hand side expression
For example, the constraint 2*Var1 + 3*Var2 + 1.5*Var3 <= 100 would call addLinearConstraintVariable(Var1,2), addLinearConstraintVariable(Var2, 3) and addLinearConstraintVariable(Var3,1.5)

This is optimization setup method, user should not call it

Parameters:
constraint -
variable -
coefficient -

addConstraint

public void addConstraint(com.opttek.optquest.COptQuestConstraint constraint)
Adds the constraint defined by the input parameter to the optimization

This is optimization setup method, user should not call it

Parameters:
constraint -

setConstraintEquation

public void setConstraintEquation(com.opttek.optquest.COptQuestStringConstraint constraint,
                                  java.lang.String equation)
Sets the mathematical expression that defines the constraint

This is optimization setup method, user should not call it

Parameters:
constraint -
equation -

addConstraint

public void addConstraint(com.opttek.optquest.COptQuestStringConstraint constraint)
Adds the string constraint defined by the input parameter to the optimization

This is optimization setup method, user should not call it

Parameters:
constraint -

setRequirementLowerBound

public void setRequirementLowerBound(com.opttek.optquest.COptQuestRequirement requirement,
                                     double value)
Sets the lower bound of requirement to the input value

This is optimization setup method, user should not call it

Parameters:
requirement -
value -

setRequirementUpperBound

public void setRequirementUpperBound(com.opttek.optquest.COptQuestRequirement requirement,
                                     double value)
Sets the upper bound of requirement to the input value

This is optimization setup method, user should not call it

Parameters:
requirement -
value -

addRequirement

public void addRequirement(com.opttek.optquest.COptQuestRequirement requirement)
Adds the requirement defined by the input parameter to the optimization

This is optimization setup method, user should not call it

Parameters:
requirement -

setCurrentObjectiveValue

public void setCurrentObjectiveValue(double value)
Used to set the value of the objective for the current solution. This method should be called from the Experiment.onEngineFinished() method when the user is calculating the objective value

This is optimization setup method, user should not call it

Parameters:
value -

setCurrentRequirementValue_xjal

public void setCurrentRequirementValue_xjal(com.opttek.optquest.COptQuestRequirement requirement,
                                            double value)
Used to set the value of the requirement for the current solution. This method should be called from the Experiment.onEngineFinished() method when the user is calculating the requirement value

This is optimization setup method, user should not call it

Parameters:
value -

stopOptimization

public void stopOptimization()
Stops the currently running optimization

This is optimization setup method, user should not call it


setRejectNonLinear

public void setRejectNonLinear(boolean reject)
Directs the OptQuest Engine to reject solutions that violate non-linear constraints without performing simulation.
Non-linear constraints can be checked for feasibility before the simulation. If the solution violates any non-linear constraints, the simulation is not needed.
The default value is false

This is optimization setup method, user should not call it

Parameters:
reject - true if infeasible solutions should be rejected.
false if they should be evaluated

setUseReplications

public void setUseReplications(boolean useReplications)
Sets optimization to use replications

This is optimization setup method, user should not call it

Parameters:
useReplications -
See Also:
setFixedReplicationsNumber(int), setVariableReplicationsNumber(int, int, int, double)

isUseReplications

public final boolean isUseReplications()
Returns true if optimization uses replications

Returns:
true if optimization uses replications, false otherwise

setFixedReplicationsNumber

public void setFixedReplicationsNumber(int replicationsNumber)
Sets experiment to use a fixed number of replications.
No confidence testing is to be used
For confidence testing use setVariableReplicationsNumber(int, int, int, double)

This is setup method, user should not call it

Parameters:
replicationsNumber - the number of replications to be run
See Also:
setUseReplications(boolean)

setVariableReplicationsNumber

public void setVariableReplicationsNumber(int minimumReplications,
                                          int maximumReplications,
                                          int confidenceLevel,
                                          double errorPercent)
Sets experiment to stop replications after the minimum replications when For fixed number of replications use setFixedReplicationsNumber(int)

This is optimization setup method, user should not call it

Parameters:
minimumReplications - minimum number of replications
maximumReplications - minimum number of replications
confidenceLevel - one of
errorPercent - the error percentage as a value > 0 and < 1.
See Also:
setUseReplications(boolean)

setMaximumIterations

public void setMaximumIterations(int numberOfIterations)
Sets the number of iterations the optimization should perform before stopping. If multiple stop options are set, the optimization will stop at the first option that is satisfied

This is optimization setup method, user should not call it

Parameters:
numberOfIterations - number of optimization iterations to be performed

setAutoStop

public void setAutoStop(boolean stop)
Sets the auto stop option.
If the input parameter is true, auto stop is turned on. The default is auto stop is turned off.
When automatic stop is set, the optimization stops when it is determined that the variance of the best solutions indicates that the current solution is not likely to improve significantly

This is optimization setup method, user should not call it

Parameters:
stop - true if auto stop is to be used, false if it is not used

setUserControlledStop

public void setUserControlledStop(boolean stop)
Indicates the user will stop the optimization by calling the stopOptimization() method

This is optimization setup method, user should not call it

Parameters:
stop - true if the user will stop the optimization
false if the optimization will be stopped by setting the number of iterations or the maximum time

isLastReplication

public boolean isLastReplication()
Return true if we have run the last replication for the current solution

This is optimization setup method, user should not call it

Returns:
true if this is the last replication of the iteration

setupRootParameters

public abstract void setupRootParameters(ROOT root,
                                         boolean callOnChangeActions)
Is called to setup parameters of root active object. This method must be defined in a subclass.

Parameters:
root - the root active object instance
callOnChangeActions - if true this method should use set_* methods of root to setup parameters, otherwise parameter values should be simply assigned to the fields of root

setLogBufferLength

public void setLogBufferLength(int length)

createOptimization

public static com.opttek.optquest.COptQuestOptimization createOptimization(Engine engine)
Creates and returns new OptQuest optimization instance for Custom Experiment
This method should only be used in custom experiment code
This method is designed for use in the AnyLogic Professional only

Parameters:
engine - the engine instance
Returns:
new OptQuest optimization instance
See OptQuest API documentation for further usage information
See Also:
createOptimization(Engine, OptimizationCallback)

createOptimization

public static com.opttek.optquest.COptQuestOptimization createOptimization(Engine engine,
                                                                           OptimizationCallback callback)
Creates and returns new OptQuest optimization instance for Custom Experiment with objective function defined in a free form using evaluate method of a special callback. For more information see the example of such optimization.
This method should only be used in custom experiment code
This method is designed for use in the AnyLogic Professional only

Parameters:
engine - the engine instance
callback - the callback for evaluate (and monitorStatus) methods
Returns:
new OptQuest optimization instance
See OptQuest API documentation for further usage information

getEngine

public final Engine getEngine()
It is strongly recommended not to call this method because of possible parallel execution environment. Use root.getEngine() instead. Although, the method will most likely return the expected engine, this could be conceptually better to get engine by using root.getEngine() where root - is the root (main) active object class.

Returns:
the engine executing the model. There may be different engines running at a time - in parallel - in this case the returned engine depends on the context (where this method is called from).

getStep

public long getStep()
Description copied from class: Experiment
Returns the number of events executed by the engine.

Overrides:
getStep in class Experiment<ROOT extends ActiveObject>
Returns:
the number of events executed

getSimulationProgress_xjal

public double[] getSimulationProgress_xjal(double[] output)
This method is not designed to be called by user and may be changed/removed in the future releases.
Returns the progress of the parallel simulation runs: an array of numbers between 0 and 1. The length of the array is the number of parallel processors. Progress is the part of model time simulated so far in case the stop time is set, or -1 if it is not set.

Parameters:
output - will be used for output if its length matches the number of processors, otherwise new array will be created and returned
Returns:
the progress of the parallel simulation runs.
See Also:
Engine.getProgress()

getRunCount

public final int getRunCount()
Description copied from class: Experiment
Returns the number of the current simulation run, more precisely the number of times the model was destroyed.

Overrides:
getRunCount in class Experiment<ROOT extends ActiveObject>
Returns:
the number of the current simulation run, more precisely the number of times the model was destroyed.

setVariableReplicationsNumber

@Deprecated
public void setVariableReplicationsNumber(int minimumReplications,
                                                     int maximumReplications,
                                                     int confidenceLevel)
Deprecated. This method is deprecated.
Use setVariableReplicationsNumber(int, int, int, double) instead

Sets experiment to stop replications after the minimum replications when the confidence level is reached


onAfterIteration

public void onAfterIteration()
User's extension point for after iteration code
By default does nothing


getMutexRead_xjal

public java.lang.Object getMutexRead_xjal()
Overrides:
getMutexRead_xjal in class Experiment<ROOT extends ActiveObject>

getMutexWrite_xjal

public java.lang.Object getMutexWrite_xjal()
Overrides:
getMutexWrite_xjal in class Experiment<ROOT extends ActiveObject>

registerPresentation_xjal

public void registerPresentation_xjal(Presentation presentation)
Description copied from class: Experiment
This method isn't designed to be called by user.
Public due to technical reasons
May be removed in future releases


getParallelEvaluatorsCount

public int getParallelEvaluatorsCount()
Returns the number of parallel evaluators used in this experiment. On multicore/multiprocessor systems this number may be greater than one - for improved performance.

Returns:
the number of parallel evaluators used in this experiment

getState

public final int getState()
Returns the current state of the experiment. Possible states are: IDLE, RUNNING, PAUSED, FINISHED, ERROR, and PLEASE_WAIT

Specified by:
getState in class Experiment<ROOT extends ActiveObject>
Returns:
the current state of the experiment

getRunTimeSeconds

public final double getRunTimeSeconds()
Returns the real duration of the experiment in seconds.
This includes simulation run time and excludes pause times.

Specified by:
getRunTimeSeconds in class Experiment<ROOT extends ActiveObject>
Returns:
the real duration of the experiment in seconds

run

public final void run()
Runs the model from the current state. If model is not yet existing, resets the experiment, creates and starts the model.

Specified by:
run in class Experiment<ROOT extends ActiveObject>

step

public final void step()
Performs one step of the model execution. If model is not yet existing, resets the experiment, creates and starts the model (not making a step).

Specified by:
step in class Experiment<ROOT extends ActiveObject>

pause

public final void pause()
Pauses the model execution.
This method has different behavior depending on context where it is called:

Specified by:
pause in class Experiment<ROOT extends ActiveObject>

stop

public final void stop()
Terminates the model execution, destroys and forgets the model and calls garbage collector, but keeps all experiment data.
This method has different behavior depending on context where it is called:

Specified by:
stop in class Experiment<ROOT extends ActiveObject>


Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.