ibm maximo optimization framework guide
TRANSCRIPT
IBM Maximo Optimization Framework Guide
Release 7.6.8
4 MOF use cases
1. MOF configuration (required to use optimization in GA/GS/GS-LP)2. MOF used from Maximo (transparent for planners)3. MOF administration and debuging (when needed)4. MOF used to deploy a new or extended model (advanced usage)
MOF configuration
• Configuring MOF at the start is necessary to use optimization in Maximo.
• MOF will be the optimization server where optimiztion runs will be executed on containers. It accepts jobs execution in parallel and manages a queue.
• The default maximum number of simultaneous optimization jobs that the execution service processes on a single container is 3 (MOFEXEC_QUEUEWORKERS)
• You must create an API key to use with each instance of Maximo® Asset Management that you are running . You can also generate a new API key (good practice at start if a key is provided by script)
• A project should be created. The API Key is to be configure in Maximo “System Properties”application (for optimization.mofapi.apikey)
• The Optimization framework REST URL is also displayed there and should also be configured in Maximo “System Properties” (for optimization.mofapi.baseurl)
MOF Maximo
MOF Models• 3 out-of-the-box optimization models are available by default : GA, GS, GSLP• They have to be configured in the Model page (if not created by script)• The model ID and version is referenced in the Maximo Run Optimization window
(Ensure that the Model Name, Version, and Type are the same as in your Maximo Optimization Framework environment, or the models will be unable to connect to the optimization service)
• The 3 OOTB models should be defined as below:
Running Optimization from Maximo
• When MOF is configured you can create a scenario and run optimization from Maximo.• During a run you can see status information (Solutions, Turn-around time in days)• You can refresh the status (or use auto refresh)• You can terminate a job (and get the current best solution). Otherwise the job will finish
when an optimimun solution is found or when the time limit is reached.• During a run you can see alerts (errors, warnings)• If business constraints make the plan infeasible, conficts are reported• At end you will get also optimization sumary and unassigned requirements• These features are provided by MOF but no need to use or connect to the MOF console
when using Maximo. • Transparent to Maximo users, MOF Rest API is used by Maximo to execute optimization
runs
• When running optimization in Maximo, you need to specify the model name and version you want to use (The model should have been defined in MOF, see product documention)
• The default value should not be changed except in case of model customization/extension
• Optimization run in progress. During optimization there is a regular communication between Maximo Scheduler and MOF using the REST API.
• Optimization run finished:
Maximo Optimization Framework Service
IBM Watson IoT / © 2020 IBM Corporation
Browser Ingress Controller
Zone 1Node 1
Multizone Kubernetes Cluster
External Authentication
System if needed (Open ID / SAML)
POD O1
Zone 1Node 2 POD O2
Optimization Engine (running in a Container)
Job Database
Log system
Monitoring system
User Analytics
Availability Monitor
Optimization Engine (running in a Container)
• Container solution
• Can be deploy on any Cloud provider
• Can run with Docker for development purpouse
• Job Database can be inside of the Cluster
• Linux based container
Maximo Optimization Framework Stack
• MOF is the optimization server where optimization runs will be executed on containers. It accepts jobs execution in parallel and manages a queue
IBM Watson IoT / © 2020 IBM Corporation
Browser Ingress Controller
Kubernetes Cluster
Rest Service Pod
MOS Admin Console Pod
Jobs DatabaseMongo DB
(StatefulSet)
Execution Service Pods
Multiple Execution Service Pods(Scaled in response to demand)
Multiple Kubernetes Nodes (if required)
• The default maximum number of simultaneous optimization jobs that the execution service processes on a single container is 3 (MOFEXEC_QUEUEWORKERS)
IBM AI Applications / © 2020 IBM Corporation
MOF Capabilities & protocol
13
On any optimization model– Trigger an asynchronous solve– During solve, see :
– status information– Log– Alerts (errors, wrnings…)– current best solution information : KPI, schedule
– Terminate a job.– When solve finished, get :
– Solution/schedule– KPI– Conflicts (when plan in infeasible)– Status– Solution summary/reports
Jobs DatabaseMongoDB
Job Execution Service:
Multithreaded and Interruptible
Rest API
Look for jobs awaiting processing – Based on priority
Save Optimization Results
67
Save Job and Scenario Data
Web application running on WebSphere Liberty(Running in a containers)
9
Optimization Server
Console
ModelsExecute
Optimization for the scenario(Call to CPO
Libraries)
8
Mathematical Models
SolutionKPIsStatusAlertsConflicts
Independently scalable and provides Job execution for different customers
InputMaximo/File
OutputMaximo/File
MOF console for debugging/administrate jobs
• The MOF console is not useful for a planner in a normal optimization usage.
• It is however useful to:• Debug a run in case of problem (and share information with IBM support)• Administrate models and job history
Jobs
• When connected to the MOF console, you can see the current optimization job and also an history of executed jobs
• When finished the status will evolve from NOT_STARTED to RUNNING and then PROCESSED or INTERRUPTED
• A running job started from Maximo
• A finished job with a feasible solution found
• You can expand a job to see more information
• When a job is selected you can stop it (if running. The current best solution will be available in Maximo) or delete it (to clear history)
• From a job you can get several files:• the Scenario data (GA/GS model have .dat file as input scenario file, while GSLP has .json file as input scenario file).
This dataset can be sent to IBM support to reproduce a problem. It can also be used to test a model extension or be used (after a possible edition) to run an optimization job from MOF
• The Solution data (json file) included the solution schedule, alerts, KPIs, status and optionaly conflicts.• The Zipped solution artifacts contains the solution file, the log and any other custom attachments (for extended
models)• The Log files can be used for debugging
• From MOF you can test a run optimization on a scenario file (downloaded from a past job and possibly edited)
• You need to select the Project and the Model/Version
Model extension
• This is an advance usage of MOF when the OOTB optimization models are not meeting all requirements
• Extension can be used to :• Preprocess/cleanup the input data• Add new constraints• Add new optimization objectives/KPI• Postprocess the results/add extra reports
Sample extension use case
• For example what if we want to:• Force each task of a workorder to be done by the same resource• Avoid gap between tasks of the same workorder, so minimize duration of
parent workorders
• Tasks of 761A1210 are not done by the same worker
• 761A1211 has long gaps between operations
Model Extension Overview
Maximo SchedulerMaintenance Optimization Framework(MOF)
• Configure whichmodel to use inGA/GS/GSLP
• Send scenario datato MOF
• Get the optimizationresult from MOF
• Deploy customizedmodel
• Run and test an OOTB/customizedmodel from the MOF console
• Develop your owncustomized model injava/OPL, writeextension code injava/JavaScript
• Package yourcustomized model intojar/zip
Development environment (eg CPLEX Studio)
Uploadcustomized package
Supported customized model type in MOF• A custom new OPL model (package into a zip)• A custom new Java model (package into a jar)• An existing model (GA, GS, GSLP, MO…) with an extension
• In Java (package into a jar)• In Javascript (package into a js file)
MOF REST API
• Any model deployed in MOF can be run using the REST api• This is documented from the MOF server, e.g.
http://mof7680rc.rtp.raleigh.ibm.com:9080/openapi/ui/
REST API optimization run
• A typical asynchronous run includes these requests :• POST/jobs Creates a job.• PUT/jobs/{id}/attachments/{attid}/blob Adds scenario data to an
optimization job.• POST/jobs/{id}/execute Submits a job for execution.• GET/jobs/{id} Returns job information job.(finished when jobSolutionDetails.
executionStatus = PROCESSED or INTERRUPTED• GET/jobs/{id}/attachments/{attid}/blob Returns a specific job attachment
(could be : job.log, output.json …)
• You can add a brand new model in Java or OPL.• In java you should adhere to the SolveTask interface• Some of the main methods are:
• addData()• createModel()• solve()/solveAsynch()• abortSearch()• isSolveDone() / isSolveOk()• getSolutionJson()
OPL model deployed in MOSIt accepts Input data as a .dat file or as json. Json is possible only if input data are tupple set. The solution output is always a json file (with solution elements based on the OPL model output tuple sets, KPIs based on the dexpr defined in the model and statuses)
When you create your model, select Model Type as OPL, the class name will be automatically populated. The version should be defined (not 0).
Then you need to attach the model as an artifact to have it deployed in MOS. In the Manage Model Artifact panel, you can upload an artifact of type “Model”.
The model artifact can be :
• a .mod file (if the model is included in a single file)
• a .zip or .tar.gz if the model is defined by multiple files. The archive can contain multiple mod file and a .properties file.
•
A properties file can be included to define :
• SolutionElements. Optional to filter out elements to be put in the json solution
• SolutionKPIs. Optional to filter out dexpr in the model to be put in the json solution KPIs
• CPLEX or CPO parameters (e.g. TiLim = 10 for a CPLEX time limit of 10)
CPLEX parameters are defined here : https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/homepages/refparameterscplex.html
CPO parameters are defined here : https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.10.0/ilog.odms.cpo.help/CP_Optimizer/Parameters/topics/paramcpoptimizer.html
MOF has cplex version 12.10.0 installed, so you can refer to https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/OPL_Studio/maps/groupings/opl_Language.html foryour OPL model.
• To be run from Maximo, an OPL model, you should adhere to the input .dat file Maximocreated for GA and GS, refer toMaximo_GA_odm.mod/ Maximo_GS_odm.mod file as asample(OPL_GA_Sample.zip andOPL_GS_Sample.zip file).
• You could write your own opl codeconsuming the input data to customize yourown pre-process, post-process, constraintsand objectives.
You can also extend an existing Java model2 types of extensions1. Modeler extension to add new constraints or objectives2. Business model extension to modify/extend the data model used to
build the optimization model
The extension will be packed in a jar including 2 filesFile 1 to declare base model and extension
How to develop java customized model
Business model extension
Should be a subclass of ibm.maximo.optimization.model.BusinessModelExtension.
Main methods to override :• protected void beforePostProcess()• protected void afterPostProcess()
Optimization model extensionShould be a subclass of ibm.maximo.optimization.modeler.ModelerExtension.
Main methods to override:
• public void addConstraints()• protected Collection<String> getObjectiveNames()• protected IloNumExpr getObjectiveCostExpr(String name)• public void onSolution(Integer solutionIndex)• public void onSolveDone(SolveTask task)
The extensions can access methods on the BusinessModel and Modeler.
File 2 for Constraints and objectives extensions
How to develop java customized model
• CPLEX/CPO code with the Java API
How to develop java customized model
New objective and KPI
• CPLEX/CPO code with the Java API
How to develop java customized model
New constraint
How to develop customized model
To Develop and test, use a java IDE for java model, cplex studio for OPL model.• For java model, you need
• Maximo Scheduler optimization jar• COS/CPLEX/CPO jars and COS installed
• You can export a jar with the 2 java files to be used as model extension artifact in MOF
Eclipse gradle project
Unit Test
How to deploy customization model in MOF
How to deploy customization model in MOF
7. Click “add new model”
(java/OPL)
add new model
How to deploy customization model in MOF
Sample for add new java model
How to deploy customization model in MOF
Sample for add new OPL model
How to deploy customization model in MOF
Upload your customization model package
How to deploy customization model in MOF
3. Add model package file from local file system
4. Click Save after uploading
• A custom new OPL model (artifact is a zip) – Type is Model
• A custom new Java model (artifact is a jar) – Type is model
• An existing model (GA, GS, GSLP, MO…) with an extension
• In Java (artifact is a jar). Type is Extension
• In Javascript (artifact is a jsfile). Type is Extension
Upload your customization model package
How to deploy customization model in MOF
You can see your customized extension artifact after uploading. You can download or delete if from the console.
How to deploy customization model in MOF
OPL model sample(Package your OPL .mod file into a zip and upload)
How to configure your customized model as default forGA/GS/GSLP
1. Go to Maximo SchedulerGraphical Assignment/Graphical Scheduling/Graphical Scheduling - Large Projects page
2. Click “Configure OptimizationModel” in the left panel.
Change the default GA model intoyour deployed customization one
Note: The configured modelname/version/type should matchthe one you added in MOF.
How to configure your customized model as default forGA/GS/GSLP
• Use “Labor and Crew Tempates” to define a new model parameter that can be used in the extension
• Define the weight, i.e. importance of mimizing the duration of parent work orders (Type=MODEL)
Run optimization with customized GA model
• The optimization model can also be selected at scenario level : “GA Sample extension Version1” if you don’t want to setit as default.
• The additional parameter defined in the template is available for value edit
Run optimization with customized GA model
Submit job
Check optimization job status in MOF
How to get the input scenario file from MOF
GA/GS model have .dat file as input scenario file, while GSLP has .json file as input scenario file
How to get the optimization result from MOF
New KPI in optimization result output Json file
How to check newly added KPI for customized model
• Now operations of a parent work order are performed in sequence by the same worker and gap between operation is minimized (at the cost of time window constraint which is not enforced)