Class Optimization
- All Implemented Interfaces:
IOptimizationEventListener
,IOptimization
Optimization
the ILicenseManager
and the IOptimizationScheme
are
set, all the INode
, IResource
and Properties
are added and the IEntity
can be accessed.- Since:
- Sep 27, 2019
- Version:
- Sep 27, 2019
- Author:
- Jens Richter
-
Field Summary
Modifier and TypeFieldDescriptionprotected com.dna.jopt.revision.algorithm.IOptimizationAlgorithm.OptimizationAlgorithmStart
The initial optimization mode GE.protected com.dna.jopt.revision.algorithm.IOptimizationAlgorithm.OptimizationAlgorithmStart
The initial optimization mode SA.protected String
-
Constructor Summary
ConstructorDescriptionInstantiates a new optimization.Optimization
(com.dna.jopt.framework.body.setup.IOptimizationSetup optimizationSetup) Instantiates a new optimization.Optimization
(com.dna.jopt.framework.body.setup.IOptimizationSetup optimizationSetup, OptimizationEvents optimizationEvents) Instantiates a new optimization. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDistanceMatrix
(double[][] distanceMatrix) Deprecated.void
addElement
(INode node) Adds anINode
to the optimization.void
addElement
(IPillarNode pillarnode) Adds aIPillarNode
to the optimization.void
addElement
(IResource res) Adds anIResource
to the optimization.void
addElement
(Properties properties) Sets the given properties asgetUserProperties()
and invokes the user properties.void
Adds allnodes
in the list to the optimization.void
addReassignNodes
(List<INode> nodes) Adds reassign nodes.void
addReassignResources
(List<IResource> ress) Adds reassign resources.void
addResources
(List<IResource> resources) Adds allresources
in the list to the optimization.void
addTimeMatrix
(double[][] timeMatrix) Deprecated.void
Clean up none optimizable elements detail holder.boolean
Clean up optimization boolean.CallsIEntity.getAllEntityElements()
andINodeUnassigner.getUnassignedNodes()
, then returns all of these elements.getAllRoutesElements
(String resourceId) com.dna.jopt.revision.algorithm.IOptimizationAlgorithm
getFirstMatchingRoute
(INode node) getFirstMatchingRoute
(String nodeId) long
getId()
Gets the id of the current thread.Gets thegetNodeConnector()
.protected Map<String,
ILogicRouteElementDetailItem> Gets the none optimizable elements detail holder.Gets thegetNoneOptimizableElementsDetailHolder()
.getNoneOptimizableNodDetail
(String elementId) Gets the value in thegetNoneOptimizableElementsDetailHolder()
for the givenelementId
.Gets the optimization element.getOptimizationElement
(String id, boolean includeUnassignedElements) Gets the optimization element.Gets the optimization run ident.Gets the definedIOptimizationScheme
.com.dna.jopt.framework.body.setup.IOptimizationSetup
Gets theIOptimizationSetup
.int
com.dna.jopt.framework.inputplausibility.properties.IPropertyProvider
Gets the property provider throughIOptimizationSetup.getPropertyProvider()
.Gets thethreadPrefix
, the standard value is"JOPT-"
.Gets an unassigned element if present.Gets theINodeUnassigner
of the optimization.Gets theuserEntityCoreBuildOptionsOpt
.Deprecated.getVersionForStatus
(String desc, String propertyPrefix, Properties props) Gets theworkEntity
.void
Handle on error interruption state after throwable in preparation stateboolean
CheckshasEntitySetByUser()
, the default value isfalse
.boolean
Used internally to keep track if the optimization is stopped.void
Checks thatgetCurrentOptimizationAlgo()
is notnull
, then callsIOptimizationAlgorithm.jumpToEnd()
.void
onAfterNodeFilteringOptimizationResult
(IOptimizationResult requestedresult) void
onAsynchronousOptimizationResult
(IOptimizationResult rapoptResult) On asynchronous optimization result.void
onBeforeNodeFilteringOptimizationResult
(IOptimizationResult requestedresult) void
On error.void
onError
(IErrorEvent errorEvent) On error.void
onNodeFiltering
(int code, String message, List<INodeFilterReason> filterReasons) On node filtering.void
onNodeFiltering
(NodeFilteringEvent nodeFilteringEvent) On node filtering.void
onProgress
(IOptimizationProgress progress) On progress.void
onProgress
(String progressString) Deprecated.void
onRequestCodeExecutionDone
(String executionId) On asynch execution done.void
On status.void
onStatus
(IStatusEvent statusEvent) On status.void
On warning.void
onWarning
(IWarningEvent warningEvent) On warning.void
pause()
void
void
proceed()
Checks thatgetCurrentOptimizationAlgo()
is notnull
, then callsIOptimizationAlgorithm.proceed()
which wakes up all threads that are waiting on this object's monitor.protected void
putAllNoneOptimizableNodDetail
(Map<String, ILogicRouteElementDetailItem> noneOptimizableElementsDetailHolder) Put all none optimizable nod detail.void
putNoneOptimizableNodDetail
(String elementId, ILogicRouteElementDetailItem details) Puts a value atelementId
ingetNoneOptimizableElementsDetailHolder()
.void
Requested asynchronous optimization result.void
requestExportState
(OutputStream output, String executionId) Request export state with 100 Days of internal timeOut.void
requestExportState
(OutputStream output, String executionId, Duration timeOut) Request export state with time out.void
Requesting aIOptimizationProgress progress
which will be provided in an async.void
Requesting an intermediateIOptimizationResult result
which will be provided in an async.void
Reset initial entity.void
setAutoFilterExecutionSchedule
(List<Double> userExecutionList) void
setInitialEntity
(IEntity initialEntity) void
setInitialEntity
(IEntity initialEntity, boolean reassignUnassignedNode) Sets the givenIEntity
as the initial Entity.void
setInitialEntityRenewAutoFilterControllers
(IEntity initialEntity) Deprecated.void
setLicenceKey
(String textkey) Deprecated.void
setLicense
(com.dna.jopt.framework.licensing.IRapotLicense license) Deprecated.void
setLicense
(File file) Deprecated.void
setLicense
(ObjectInputStream licensestream) Deprecated.void
setLicenseJSON
(File file) void
setLicenseJSON
(String jsonLic) void
setNodeConnector
(INodeEdgeConnector nodeConnector) Sets thegetNodeConnector()
.void
setOptimizationAlgorithmStart
(com.dna.jopt.revision.algorithm.IOptimizationAlgorithm.OptimizationAlgorithmStart modeSA, com.dna.jopt.revision.algorithm.IOptimizationAlgorithm.OptimizationAlgorithmStart modeGE) Sets theinitialOptimizationModeGE
andinitialOptimizationModeSA
, both have the default valueSTATE_MODE_BATCH
.boolean
setOptimizationCreator
(String creator) boolean
setOptimizationRunIdent
(String ident) Sets the optimization run identification string.void
setOptimizationScheme
(IOptimizationScheme optimizationScheme) Sets theIOptimizationScheme
.void
setThreadPrefix
(String threadPrefix) Sets thegetThreadPrefix()
, the default value is"JOPT-"
.void
Internally called to settle the optimization, e.g.void
setUnassignNodeManager
(INodeUnassigner unassignNodeManager) Sets theINodeUnassigner
.void
setUserEntityCoreBuildOptions
(Properties userEntityCoreBuildOptions) SetsuserEntityCoreBuildOptionsOpt
as anOptional
with the parameter values if notnull
.void
setWorkEntity
(IEntity workEntity) Sets theworkEntity
.void
Deprecated.Start run async.startRunAsync
(ObjectInputStream license) Deprecated.startRunSync
(long timeout, TimeUnit unit) Start run sync.void
Checks thatgetCurrentOptimizationAlgo()
is notnull
, then setsisStopOptimization()
totrue
and callsIOptimizationAlgorithm.jumpToEnd()
.
-
Field Details
-
initialOptimizationModeSA
protected com.dna.jopt.revision.algorithm.IOptimizationAlgorithm.OptimizationAlgorithmStart initialOptimizationModeSAThe initial optimization mode SA. -
initialOptimizationModeGE
protected com.dna.jopt.revision.algorithm.IOptimizationAlgorithm.OptimizationAlgorithmStart initialOptimizationModeGEThe initial optimization mode GE. -
jsonLic
-
-
Constructor Details
-
Optimization
public Optimization()Instantiates a new optimization. -
Optimization
public Optimization(com.dna.jopt.framework.body.setup.IOptimizationSetup optimizationSetup) Instantiates a new optimization.- Parameters:
optimizationSetup
- the optimization setup
-
Optimization
public Optimization(com.dna.jopt.framework.body.setup.IOptimizationSetup optimizationSetup, OptimizationEvents optimizationEvents) Instantiates a new optimization.- Parameters:
optimizationSetup
- the optimization setupoptimizationEvents
- the optimization events
-
-
Method Details
-
setOptimizationCreator
- Specified by:
setOptimizationCreator
in interfaceIOptimization
-
getOptimizationCreator
- Specified by:
getOptimizationCreator
in interfaceIOptimization
-
setOptimizationRunIdent
Description copied from interface:IOptimization
Sets the optimization run identification string. This can be an arbitrary user provided String to identify a run. If no ident is provided, the Optimizer will generate an ident whenever the optimization is saved.- Specified by:
setOptimizationRunIdent
in interfaceIOptimization
- Parameters:
ident
- the ident- Returns:
- true, if accepted
-
getOptimizationRunIdent
Description copied from interface:IOptimization
Gets the optimization run ident. If no ident was provided the Optimizer creates an ident on the first call of this method.- Specified by:
getOptimizationRunIdent
in interfaceIOptimization
- Returns:
- the optimization run ident
-
setAutoFilterExecutionSchedule
Description copied from interface:IOptimization
- Specified by:
setAutoFilterExecutionSchedule
in interfaceIOptimization
- Parameters:
userExecutionList
- theList<Double>
to be set as userExecutionList
-
getId
public long getId()Description copied from interface:IOptimization
Gets the id of the current thread.- Specified by:
getId
in interfaceIOptimization
- Returns:
- the long thread id
- See Also:
-
getOptimizationEvents
Description copied from interface:IOptimization
Gets theOptimizationEvents
which are backed by multipleReplaySubject
andCompletableFuture
.OptimizationEvents
can be used to subscribe to different events of the optimization.- Specified by:
getOptimizationEvents
in interfaceIOptimization
- Returns:
- the optimizationevents
-
setOptimizationAlgorithmStart
public void setOptimizationAlgorithmStart(com.dna.jopt.revision.algorithm.IOptimizationAlgorithm.OptimizationAlgorithmStart modeSA, com.dna.jopt.revision.algorithm.IOptimizationAlgorithm.OptimizationAlgorithmStart modeGE) Description copied from interface:IOptimization
Sets theinitialOptimizationModeGE
andinitialOptimizationModeSA
, both have the default valueSTATE_MODE_BATCH
.- Specified by:
setOptimizationAlgorithmStart
in interfaceIOptimization
- Parameters:
modeSA
- the modeSAmodeGE
- the modeGE
-
putNoneOptimizableNodDetail
Description copied from interface:IOptimization
Puts a value atelementId
ingetNoneOptimizableElementsDetailHolder()
.- Specified by:
putNoneOptimizableNodDetail
in interfaceIOptimization
- Parameters:
elementId
- the string id for the value to be putdetails
- the iLogicRouteElementDetailItem that is supposed to be put
-
putAllNoneOptimizableNodDetail
protected void putAllNoneOptimizableNodDetail(Map<String, ILogicRouteElementDetailItem> noneOptimizableElementsDetailHolder) Put all none optimizable nod detail.- Parameters:
noneOptimizableElementsDetailHolder
- the none optimizable elements detail holder
-
getNoneOptimizableNodDetail
Description copied from interface:IOptimization
Gets the value in thegetNoneOptimizableElementsDetailHolder()
for the givenelementId
. This method is primarily used for internal purpose. Please try to extract details from the route itself.- Specified by:
getNoneOptimizableNodDetail
in interfaceIOptimization
- Parameters:
elementId
- the string key for the value- Returns:
- the value of the elementId in noneOptimizableElementsDetailHolder
-
getNoneOptimizableElementsDetailHolder
Gets the none optimizable elements detail holder.- Returns:
- the none optimizable elements detail holder
-
cleanUpNoneOptimizableElementsDetailHolder
Description copied from interface:IOptimization
Clean up none optimizable elements detail holder.- Specified by:
cleanUpNoneOptimizableElementsDetailHolder
in interfaceIOptimization
- Parameters:
deadIds
- the dead ids
-
getNoneOptimizableElementsDetails
Description copied from interface:IOptimization
Gets thegetNoneOptimizableElementsDetailHolder()
.- Specified by:
getNoneOptimizableElementsDetails
in interfaceIOptimization
- Returns:
- none optimizable elements details
-
requestedAsynchronousOptimizationResult
Description copied from interface:IOptimization
Requested asynchronous optimization result.- Specified by:
requestedAsynchronousOptimizationResult
in interfaceIOptimization
- Specified by:
requestedAsynchronousOptimizationResult
in interfaceIOptimizationEventListener
- Parameters:
result
- the result to print
-
getOptimizationSetup
public com.dna.jopt.framework.body.setup.IOptimizationSetup getOptimizationSetup()Description copied from interface:IOptimization
Gets theIOptimizationSetup
.- Specified by:
getOptimizationSetup
in interfaceIOptimization
- Returns:
- the optimizationSetup
-
setOptimizationScheme
Description copied from interface:IOptimization
Sets theIOptimizationScheme
.- Specified by:
setOptimizationScheme
in interfaceIOptimization
- Parameters:
optimizationScheme
- the iOptimizationscheme to add
-
getOptimizationScheme
Description copied from interface:IOptimization
Gets the definedIOptimizationScheme
.- Specified by:
getOptimizationScheme
in interfaceIOptimization
- Returns:
- the optimizationscheme
-
setNodeConnector
Description copied from interface:IOptimization
Sets thegetNodeConnector()
.Cannot be
null
.- Specified by:
setNodeConnector
in interfaceIOptimization
- Parameters:
nodeConnector
- the new node connector
-
getNodeConnector
Description copied from interface:IOptimization
Gets thegetNodeConnector()
.- Specified by:
getNodeConnector
in interfaceIOptimization
- Returns:
- the node connector
-
getUnassignNodeManager
Description copied from interface:IOptimization
Gets theINodeUnassigner
of the optimization.- Specified by:
getUnassignNodeManager
in interfaceIOptimization
- Returns:
- the unassignNodeManager
-
setUnassignNodeManager
Description copied from interface:IOptimization
Sets theINodeUnassigner
.Cannot be
null
.- Specified by:
setUnassignNodeManager
in interfaceIOptimization
- Parameters:
unassignNodeManager
- the unassign node manager
-
getPropertyProvider
public com.dna.jopt.framework.inputplausibility.properties.IPropertyProvider getPropertyProvider()Description copied from interface:IOptimization
Gets the property provider throughIOptimizationSetup.getPropertyProvider()
.- Specified by:
getPropertyProvider
in interfaceIOptimization
- Returns:
- the propertyProvider
-
addElement
Description copied from interface:IOptimization
Adds anINode
to the optimization.- Specified by:
addElement
in interfaceIOptimization
- Parameters:
node
- the element to be added.
-
addNodes
Description copied from interface:IOptimization
Adds allnodes
in the list to the optimization.- Specified by:
addNodes
in interfaceIOptimization
- Parameters:
nodes
- thelist<INode>
of nodes to be added
-
addReassignNodes
Description copied from interface:IOptimization
Adds reassign nodes. In case a custom solution is usedIOptimization.setInitialEntity(com.dna.jopt.member.bucket.entity.IEntity)
, or the optimization is resumed from a snapshot additional nodes can be added. In contrast toIOptimization.addElement(com.dna.jopt.member.unit.node.INode)
, nodes are put in an optimized fashion into the existing solution.If no solution by the user is provided, calling this method has the same effect as
IOptimization.addElement(com.dna.jopt.member.unit.node.INode)
.- Specified by:
addReassignNodes
in interfaceIOptimization
- Parameters:
nodes
- the nodes
-
getReassignNodes
- Specified by:
getReassignNodes
in interfaceIOptimization
-
addReassignResources
Description copied from interface:IOptimization
Adds reassign resources. In case a custom solution is usedIOptimization.setInitialEntity(com.dna.jopt.member.bucket.entity.IEntity)
, or the optimization is resumed from a snapshot additional resources can be added.If no solution by the user is provided, calling this method has the same effect as
IOptimization.addElement(com.dna.jopt.member.unit.node.INode)
.- Specified by:
addReassignResources
in interfaceIOptimization
- Parameters:
ress
- the resources
-
getReassignResources
- Specified by:
getReassignResources
in interfaceIOptimization
-
addResources
Description copied from interface:IOptimization
Adds allresources
in the list to the optimization.- Specified by:
addResources
in interfaceIOptimization
- Parameters:
resources
- thelist<IResource>
to be added
-
addElement
Description copied from interface:IOptimization
Adds aIPillarNode
to the optimization.- Specified by:
addElement
in interfaceIOptimization
- Parameters:
pillarnode
- the pillarnode to be added
-
addElement
Description copied from interface:IOptimization
Adds anIResource
to the optimization.- Specified by:
addElement
in interfaceIOptimization
- Parameters:
res
- the resource
-
addElement
Description copied from interface:IOptimization
Sets the given properties asgetUserProperties()
and invokes the user properties.A list of all properties can be generated by the following code example:
public static void printJOptProperties() { List<String> categories = new ArrayList<>(); categories.add("CATEGORY_MISC"); categories.add("CATEGORY_SYSTEM"); categories.add("CATEGORY_OPTIMIZATION_GENERAL_SETUP"); categories.add("CATEGORY_OPTIMIZATION_CONSTRUCTION"); categories.add("CATEGORY_OPTIMIZATION_PRE_OPTIMIZATION_SETUP"); categories.add("CATEGORY_OPTIMIZATION_GENETIC_SETUP"); categories.add("CATEGORY_OPTIMIZATION_2OPT"); categories.add("CATEGORY_OPTIMIZATION_WEIGHTS"); categories.add("CATEGORY_OPTIMIZATION_AUTOFILTER"); categories.add("CATEGORY_OPTIMIZATION_CO_SETUP"); categories.add("CATEGORY_OPTIMIZATION_DEPRECATED"); IOptimization myDummyOptimization = new Optimization(); // Read out current properties List<PropertyItem> categorySortedPropItems = myDummyOptimization.getPropertyProvider() .getPropertyItems() .stream() .sorted((o1,o2)->Integer.compare(o1.getCategoryIdent(), o2.getCategoryIdent())) .collect(Collectors.toList()); categorySortedPropItems .stream() .forEach( i -> { if (i.getCategoryIdent() == PropertyItem.CATEGORY_OPTIMIZATION_DEPRECATED) { System.out.print("\n-== DEPRECATED PROPERTY ==-"); } else { System.out.print("\n"); } System.out.print( "\nCategory: " + categories.get(i.getCategoryIdent()) + "\nDescription: " + i.getDescription() + "\nDefault Key: " + i.getValidatedPropertyName() + "\nDefault Value: " + i.getDefaultValue() + "\nAllowed Values: " + i.getAllowedValues() + "\n"); }); }
- Specified by:
addElement
in interfaceIOptimization
- Parameters:
properties
- the properties
-
getUserProperties
Description copied from interface:IOptimization
- Specified by:
getUserProperties
in interfaceIOptimization
- Returns:
- the userProperties
-
setLicenseJSON
- Specified by:
setLicenseJSON
in interfaceIOptimization
-
setLicenseJSON
- Specified by:
setLicenseJSON
in interfaceIOptimization
- Throws:
IOException
-
setLicense
Deprecated.Description copied from interface:IOptimization
Sets the license key via a file object.- Specified by:
setLicense
in interfaceIOptimization
- Parameters:
file
- the key- Throws:
IOException
- the io exception
-
setLicenceKey
Deprecated.Description copied from interface:IOptimization
Sets the licence key.- Specified by:
setLicenceKey
in interfaceIOptimization
- Parameters:
textkey
- the string new licence key
-
setLicense
Deprecated.Description copied from interface:IOptimization
Sets the license key loaded from a file and already read in license object.- Specified by:
setLicense
in interfaceIOptimization
- Parameters:
license
- the iRapotLicense new license
-
setLicense
Deprecated.Description copied from interface:IOptimization
Sets the license key via an input stream.The following code example can be used to read in a file from a resource folder:
public class ExampleLicenseHelper { private static final String LICNCES_PATH = "src/test/resources/myKeyFile.dli"; private ExampleLicenseHelper() { // Nothing to do } public static boolean setLicense(IOptimization opti) { try { ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File(ExampleLicenseHelper.LICNCES_PATH))); opti.setLicense(ois); return true; } catch (IOException e) { e.printStackTrace(); return false; } } }
- Specified by:
setLicense
in interfaceIOptimization
- Parameters:
licensestream
- the objectinputstream
-
startAsynchronousOptimizationRun
Deprecated.Description copied from interface:IOptimization
CallsIOptimization.startRunSync(long, TimeUnit)
withMAX_VALUE
aslong
andMILLISECONDS
asTimeUnit
.- Specified by:
startAsynchronousOptimizationRun
in interfaceIOptimization
- Throws:
InvalidLicenceException
- the invalid licence exception
-
startRunSync
public IOptimizationResult startRunSync(long timeout, TimeUnit unit) throws InvalidLicenceException, InterruptedException, ExecutionException, TimeoutException Description copied from interface:IOptimization
Start run sync. internally creates acompletable future
. The optimization is started within aForkJoinPool
. Internallyget()
is called on it so that the code will block until thecompletable future
returns. However, as the run is outsourced into multiple threads the Optimization object itself stays responsive to allow for example to request an intermediate optimization result.The
timeout
sets the time within which thecompletable future
needs to return, otherwise aTimeoutException
is thrownFor use without a timeout please use
IOptimization.startRunAsync()
- Specified by:
startRunSync
in interfaceIOptimization
- Parameters:
timeout
- the long number of the to be defined time unit until timeoutunit
- the timeUnit of the timeout- Returns:
- the ioptimization result
- Throws:
InvalidLicenceException
- the invalid licence exceptionInterruptedException
- the interrupted exceptionExecutionException
- the execution exceptionTimeoutException
- the timeout exception if the completable future has not been done within the timeout
-
startRunAsync
Description copied from interface:IOptimization
Start run async. creates acompletable future
which is returned.- Specified by:
startRunAsync
in interfaceIOptimization
- Returns:
- completable future
- Throws:
InvalidLicenceException
- the invalid licence exception
-
handleOnErrorInterruptionState
Description copied from interface:IOptimization
Handle on error interruption state after throwable in preparation state- Specified by:
handleOnErrorInterruptionState
in interfaceIOptimization
- Parameters:
e
- the e
-
prePreparation
public void prePreparation() -
startRunAsync
@Deprecated public CompletableFuture<IOptimizationResult> startRunAsync(ObjectInputStream license) throws InvalidLicenceException Deprecated.Description copied from interface:IOptimization
Start run async by providing an additional license stream.- Specified by:
startRunAsync
in interfaceIOptimization
- Parameters:
license
- the license- Returns:
- the completable future
- Throws:
InvalidLicenceException
- the invalid licence exception- See Also:
-
getVersionForStatus
-
setInitialEntity
Description copied from interface:IOptimization
Sets the initialIEntity
as the workEntity andhasEntitySetByUser()
totrue
. This method is used to load custom solutions and is used during the loading of a snapshot.Will throw an
IllegalStateException
if the initial entity isnull
.- Specified by:
setInitialEntity
in interfaceIOptimization
- Parameters:
initialEntity
- the new initial entity
-
resetInitialEntity
public void resetInitialEntity()Description copied from interface:IOptimization
Reset initial entity. This method will reset an entity that was assigned to the optimization. It is only allowed to reset an entity before the optimization is started.This methods helps to use an existing solution to be used only as data provider, ignoring an existing solution.
- Specified by:
resetInitialEntity
in interfaceIOptimization
-
setInitialEntityRenewAutoFilterControllers
Deprecated.Description copied from interface:IOptimization
SetshasEntitySetByUser()
andtryRenewAutoFilterController
totrue
, then sets the input initialEntity as thegetWorkEntity()
.- Specified by:
setInitialEntityRenewAutoFilterControllers
in interfaceIOptimization
- Parameters:
initialEntity
- the iEntity to be set as workEntity
-
hasEntitySetByUser
public boolean hasEntitySetByUser()Description copied from interface:IOptimization
CheckshasEntitySetByUser()
, the default value isfalse
.- Specified by:
hasEntitySetByUser
in interfaceIOptimization
- Returns:
- the boolean hasUserEntity
-
setInitialEntity
Description copied from interface:IOptimization
Sets the givenIEntity
as the initial Entity.- Specified by:
setInitialEntity
in interfaceIOptimization
- Parameters:
initialEntity
- the entity to be setreassignUnassignedNode
- the reassign unassigned node
-
setWorkEntity
Description copied from interface:IOptimization
Sets theworkEntity
.- Specified by:
setWorkEntity
in interfaceIOptimization
- Parameters:
workEntity
- the workEntity to be set
-
setUserEntityCoreBuildOptions
Description copied from interface:IOptimization
SetsuserEntityCoreBuildOptionsOpt
as anOptional
with the parameter values if notnull
. Will set it as an emptyOptional
ifnull
.- Specified by:
setUserEntityCoreBuildOptions
in interfaceIOptimization
- Parameters:
userEntityCoreBuildOptions
- the optional with the given parameters
-
getUserEntityCoreBuildOptions
Description copied from interface:IOptimization
Gets theuserEntityCoreBuildOptionsOpt
. The default value is an emptyOptional
.- Specified by:
getUserEntityCoreBuildOptions
in interfaceIOptimization
- Returns:
- the optional userEntityCoreBuildOptionsOpt
-
getWorkEntity
Description copied from interface:IOptimization
Gets theworkEntity
.- Specified by:
getWorkEntity
in interfaceIOptimization
- Returns:
- the iEntity workEntity
-
getOptimizationElement
Description copied from interface:IOptimization
Gets the optimization element. Extracts an element (Resource or Node) that is member of any route of the current optimization run. Unassigned elements are not found.- Specified by:
getOptimizationElement
in interfaceIOptimization
- Parameters:
id
- the id- Returns:
- the optimization element
-
getOptimizationElement
public Optional<IOptimizationElement> getOptimizationElement(String id, boolean includeUnassignedElements) Description copied from interface:IOptimization
Gets the optimization element. Extracts an element (Resource or Node) that is member of any route of the current optimization run. Unassigned elements can be found if includeUnassignedElements is true.- Specified by:
getOptimizationElement
in interfaceIOptimization
- Parameters:
id
- the idincludeUnassignedElements
- the include unassigned elements- Returns:
- the optimization element
-
getUnassignedElement
Description copied from interface:IOptimization
Gets an unassigned element if present.- Specified by:
getUnassignedElement
in interfaceIOptimization
- Parameters:
id
- the id- Returns:
- the unassigned element
-
getAllElements
Description copied from interface:IOptimization
CallsIEntity.getAllEntityElements()
andINodeUnassigner.getUnassignedNodes()
, then returns all of these elements. Returns a newArraylist
if these arenull
.- Specified by:
getAllElements
in interfaceIOptimization
- Returns:
- the
List<IOptimizationElement>
with all the elements
-
getNoneOptimizableElements
Description copied from interface:IOptimization
CallsIEntity.getNoneOptimizableElements()
ifgetWorkEntity()
is notnull
. Otherwise returns a newArraylist
.- Specified by:
getNoneOptimizableElements
in interfaceIOptimization
- Returns:
- a
List<IOptimizationElement>
-
getOptimizableElements
Description copied from interface:IOptimization
CallsIEntity.getNoneOptimizableElements()
if theIOptimization.getWorkEntity()
is notnull
. Otherwise returns a newArraylist
.- Specified by:
getOptimizableElements
in interfaceIOptimization
- Returns:
- the
List<IOptimizationElement>
-
getAllRoutesElements
Description copied from interface:IOptimization
CallsIEntity.getAllRoutesElements(String)
, ifIOptimization.getWorkEntity()
is notnull
.If the route of the given resource does not have any elements returns a new
ArrayList<>
.- Specified by:
getAllRoutesElements
in interfaceIOptimization
- Parameters:
resourceId
- the string resourceId- Returns:
- the
ArrayList<>
of the route elements
-
getFirstMatchingRoute
Description copied from interface:IOptimization
- Specified by:
getFirstMatchingRoute
in interfaceIOptimization
- Parameters:
nodeId
- the string of the nodeId that is supposed to match- Returns:
- an optional with the matching route or an empty optional
-
getFirstMatchingRoute
Description copied from interface:IOptimization
- Specified by:
getFirstMatchingRoute
in interfaceIOptimization
- Parameters:
node
- the iNode that is supposed to match- Returns:
- an optional with the matching route or an empty optional
-
getAnchoredRoutes
Description copied from interface:IOptimization
- Specified by:
getAnchoredRoutes
in interfaceIOptimization
- Returns:
- the anchored routes
-
setThreadPrefix
Description copied from interface:IOptimization
Sets thegetThreadPrefix()
, the default value is"JOPT-"
. This helps to identify the running optimization thread on the user system.- Specified by:
setThreadPrefix
in interfaceIOptimization
- Parameters:
threadPrefix
- the prefix to be set
-
getThreadPrefix
Description copied from interface:IOptimization
Gets thethreadPrefix
, the standard value is"JOPT-"
.- Specified by:
getThreadPrefix
in interfaceIOptimization
- Returns:
- the string threadPrefix
-
getOptimizationStage
public int getOptimizationStage()Description copied from interface:IOptimization
CallsOptimizationSubController.getCurrentOptimizationAlgo()
. For example, in case three optimization algorithms and currently the second algorithm is running the stage identifier is one. The first algorithm would have the stage identifier zero.- Specified by:
getOptimizationStage
in interfaceIOptimization
- Returns:
- returns the optimizationAlgo
-
getCurrentOptimizationAlgo
public com.dna.jopt.revision.algorithm.IOptimizationAlgorithm getCurrentOptimizationAlgo()Description copied from interface:IOptimization
CallsOptimizationSubController.getCurrentOptimizationAlgo()
. Returns the currently running optimization algorithm.- Specified by:
getCurrentOptimizationAlgo
in interfaceIOptimization
- Returns:
- the current optimizationalgorithm
-
settleOptimization
public void settleOptimization()Description copied from interface:IOptimization
Internally called to settle the optimization, e.g. finishing all running postStepManagers.- Specified by:
settleOptimization
in interfaceIOptimization
-
requestResult
public void requestResult()Description copied from interface:IOptimization
Requesting an intermediateIOptimizationResult result
which will be provided in an async. manner.Checks that
getCurrentOptimizationAlgo()
is notnull
, then callsIOptimizationAlgorithm.requestResult()
.- Specified by:
requestResult
in interfaceIOptimization
-
requestProgress
public void requestProgress()Description copied from interface:IOptimization
Requesting aIOptimizationProgress progress
which will be provided in an async. manner.Checks that
getCurrentOptimizationAlgo()
is notnull
, then callsIOptimizationAlgorithm.requestProgress()
.- Specified by:
requestProgress
in interfaceIOptimization
-
requestExportState
Description copied from interface:IOptimization
Request export state with 100 Days of internal timeOut. The optimization will be saved as JSON to the provided outputStream. Further, when the saving is done, to returned CompletableFuture is completed with the provided executionId.- Specified by:
requestExportState
in interfaceIOptimization
- Parameters:
output
- the outputexecutionId
- the execution id
-
requestExportState
public void requestExportState(OutputStream output, String executionId, Duration timeOut) throws TimeoutException Description copied from interface:IOptimization
Request export state with time out. The optimization will be saved as JSON to the provided outputStream. Further, when the saving is done, to returned CompletableFuture is completed with the provided executionId.- Specified by:
requestExportState
in interfaceIOptimization
- Parameters:
output
- the outputexecutionId
- the execution idtimeOut
- the time out- Throws:
TimeoutException
- the timeout exception
-
jumpToNextStage
public void jumpToNextStage()Description copied from interface:IOptimization
Checks thatgetCurrentOptimizationAlgo()
is notnull
, then callsIOptimizationAlgorithm.jumpToEnd()
.- Specified by:
jumpToNextStage
in interfaceIOptimization
-
stopOptimization
public void stopOptimization()Description copied from interface:IOptimization
Checks thatgetCurrentOptimizationAlgo()
is notnull
, then setsisStopOptimization()
totrue
and callsIOptimizationAlgorithm.jumpToEnd()
. This call will trigger a graceful optimization stop triggering the optimization result.- Specified by:
stopOptimization
in interfaceIOptimization
-
isStopOptimization
public boolean isStopOptimization()Description copied from interface:IOptimization
Used internally to keep track if the optimization is stopped.- Specified by:
isStopOptimization
in interfaceIOptimization
- Returns:
- the boolean optimizationWasStopped
-
proceed
public void proceed()Description copied from interface:IOptimization
Checks thatgetCurrentOptimizationAlgo()
is notnull
, then callsIOptimizationAlgorithm.proceed()
which wakes up all threads that are waiting on this object's monitor.- Specified by:
proceed
in interfaceIOptimization
- See Also:
-
pause
public void pause()Description copied from interface:IOptimization
- Specified by:
pause
in interfaceIOptimization
- See Also:
-
getVersion
Deprecated.Description copied from interface:IOptimization
Gets information about the build of the library.- Specified by:
getVersion
in interfaceIOptimization
- Returns:
- the string myVersion
-
getCoreVersionProperties
Description copied from interface:IOptimization
- Specified by:
getCoreVersionProperties
in interfaceIOptimization
- Returns:
- the
versionCoreProperties
-
getCoreVersion
Description copied from interface:IOptimization
- Specified by:
getCoreVersion
in interfaceIOptimization
- Returns:
- the
versionCoreProperties
-
cleanUpOptimization
public boolean cleanUpOptimization()Description copied from interface:IOptimization
Clean up optimization boolean. Returnstrue
.- Specified by:
cleanUpOptimization
in interfaceIOptimization
- Returns:
- true
-
addDistanceMatrix
Deprecated.Adds the distance matrix.- Specified by:
addDistanceMatrix
in interfaceIOptimization
- Parameters:
distanceMatrix
- the distance matrix- Category:
- Legacy
Adds the distance matrix.
-
addTimeMatrix
Deprecated.Adds the time matrix.- Specified by:
addTimeMatrix
in interfaceIOptimization
- Parameters:
timeMatrix
- the time matrix- Category:
- Legacy
Adds the time matrix.
-
onProgress
Deprecated.Description copied from interface:IOptimizationEventListener
On progress. UseIOptimizationEventListener.onProgress(IOptimizationProgress)
instead- Specified by:
onProgress
in interfaceIOptimizationEventListener
- Parameters:
progressString
- the winner progress string
-
onProgress
Description copied from interface:IOptimizationEventListener
On progress.- Specified by:
onProgress
in interfaceIOptimizationEventListener
- Parameters:
progress
- the cur best entity
-
onAsynchronousOptimizationResult
Description copied from interface:IOptimizationEventListener
On asynchronous optimization result.- Specified by:
onAsynchronousOptimizationResult
in interfaceIOptimizationEventListener
- Parameters:
rapoptResult
- the winner
-
onError
Description copied from interface:IOptimizationEventListener
On error.- Specified by:
onError
in interfaceIOptimizationEventListener
- Parameters:
code
- the codemessage
- the message
-
onError
Description copied from interface:IOptimizationEventListener
On error.- Specified by:
onError
in interfaceIOptimizationEventListener
- Parameters:
errorEvent
- the error event
-
onWarning
Description copied from interface:IOptimizationEventListener
On warning.- Specified by:
onWarning
in interfaceIOptimizationEventListener
- Parameters:
code
- the codemessage
- the message
-
onWarning
Description copied from interface:IOptimizationEventListener
On warning.- Specified by:
onWarning
in interfaceIOptimizationEventListener
- Parameters:
warningEvent
- the i warning event
-
onStatus
Description copied from interface:IOptimizationEventListener
On status.- Specified by:
onStatus
in interfaceIOptimizationEventListener
- Parameters:
code
- the codemessage
- the message
-
onStatus
Description copied from interface:IOptimizationEventListener
On status.- Specified by:
onStatus
in interfaceIOptimizationEventListener
- Parameters:
statusEvent
- the status event
-
onNodeFiltering
Description copied from interface:IOptimizationEventListener
On node filtering.- Specified by:
onNodeFiltering
in interfaceIOptimizationEventListener
- Parameters:
code
- the codemessage
- the messagefilterReasons
- the filter reasons
-
onNodeFiltering
Description copied from interface:IOptimizationEventListener
On node filtering.- Specified by:
onNodeFiltering
in interfaceIOptimizationEventListener
- Parameters:
nodeFilteringEvent
- the node filtering event
-
onRequestCodeExecutionDone
Description copied from interface:IOptimizationEventListener
On asynch execution done.- Specified by:
onRequestCodeExecutionDone
in interfaceIOptimizationEventListener
- Parameters:
executionId
- the execution id
-
onBeforeNodeFilteringOptimizationResult
- Specified by:
onBeforeNodeFilteringOptimizationResult
in interfaceIOptimizationEventListener
-
onAfterNodeFilteringOptimizationResult
- Specified by:
onAfterNodeFilteringOptimizationResult
in interfaceIOptimizationEventListener
-