Home

ILOG Concert Technology 1.1 Migration Guide

image

Contents

1. Planner 3 3 Concert 1 1 and CPLEX 7 1 lcPrimal loCplex Primal lcDual IloCplex Dual lcNetworkPrimal IloCplex NetworkPrimal lcNetworkDual IloCplex NetworkDual lcBarrierPrimal IloCplex BarrierPrimal lcBarrierDual IloCplex BarrierDual The member function void IlcLinOpt setSearchMethod IlcOptMethod method const 15 nOW void IloLinConstraint setNodeAlgorithm IloCplex Algorithm algo Precision Handling Precision is handled the same way in IloLinConstraint as in IlcLinOpt However the name for accessing the tolerance value for integrality checking and for the rounding procedure has changed The member function IlcFloat IlcLinOpt getFuzzValue const is converted to IloNum IloLinConstraint getFeasTolerance const and the member function void IlcLinOpt setFuzzvalue IlcFloat p 15 converted to void IloLinConstraint setFeasTolerance IloNum tol const Variable Instantiation The Planner 3 3 member function void IlcLinOpt trySolution used to instantiate all variables appearing in the invoking object to their current value is now void IloLinConstraint fixAllVarsToValue Note that Concert also supports member functions that enable you to fix variables and arrays of variables independently 92 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING A PLANNER APPLICATION IN SEARCH MODE Exceptions The call to the Planner 3 3 member fu
2. I 17 How to Translate a Program from Solver 4 4 to Solver 5 1 L 17 Wrapping Existing Solver eee 18 Translating the Pheasant Example 18 Wrapping User Defined Constraints 20 Wrapping User Defined GoalS 0 0 0 21 Translating Search sssinenennenabia ssec uses ac m eee eee eet 23 Basic Search Techniques ee 29 One Solution ita ee sae Gas ean A 23 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE V TABLE OF CONTENTS Chapter 3 Chapter 4 vi To Find the Optimal Solution 0 24 Testing a List of Constraints liess 26 Multi Phase Search with Restart 000 27 Multi Phase Search with Continue 28 Separation of Goals from Demons and 29 Obsolete Functions and Classes ococccccccccnc nne 35 Migrating from Scheduler to Concert Technology esee 37 How to Translate a Program from Scheduler 4 4 to Scheduler 5 1 38 A Translation Example ooooocccocnc e hn n hh hn 40 Rationale
3. setNumAttrMin const chart name IloNum min setNumAttrValue const chart name IloNUm value Obsolete Obsolete setPortCardinality const chart name IloInt value setPortCardinality const chart name const char subType IloInt value setPortCardinalityMax const char name IloInt max setPortCardinalityMax const char name const char subType IloInt max setPortCardinalityMin const char name IloInt min setPortCardinalityMin const char name const char subType IloInt min IloConfigStrategy setGoal IloComponentType t IloGoal g ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 71 2 Q o e c o Configurator 1 0 API Configurator 2 1 API ILC CONFIG STRATEGYn Obsolete IlcConfigStrategy Obsolete IlcConfigStrategyI Obsolete classifyInstances IlcPort p IloGoal IloInstantiate IloEnv IloPort IlcBool recursive IlcTrue IloGoal IloDeepInstantiate IloEnv IloPort IloConfigStrategy generateCards IlcPort p IloGoal IloGenerateCards IloEnv IloPort generateCards IlcPort p IloGoal IloGenerateCards IloEnv IloPort IlcCardSelect selectVar IloCardSelect selectVar IlcIntSelect selectValue IlcIntSelect selectValue getComponent Obsolete instantiate IlcIntAttr x loGoal IloInstantiate IloEnv IloNumAttr x instantiate IlcIntAttr x loGoal IloInstantiate IloEnv IloNumAttr x lcIntSelect selector lcIntSelect select
4. ILOG Concert Technology 1 1 Migration Guide April 2001 O Copyright 2001 by ILOG This document and the software described in this document are the property of ILOG and are protected as ILOG trade secrets They are furnished under a license or non disclosure agreement and may be used or copied only within the terms of such license or non disclosure agreement No part of this work may be reproduced or disseminated in any form or by any means without the prior written permission of ILOG S A Printed in France Preface Chapter 1 Chapter 2 Table of Contents About This Manual a IPAE ix About Concert nn n nnn ix How this Manual is Organized ooooococcocnnn re x What you Need tOKNO0W ooococcccc he hn hh nm nnn x Notation and Naming Conventions eee n nnn x Related nh n hn nnn xi The Benefits of Migrating to Concert Technology Lese 13 Migrating from Solver to Concert Technology lesse 15 A Brief Introduction to Concert Technology oooococccnncco 16 Clear Distinction Between Model and Algorithm eee 16 New Data Types iurc y Sie Ser UI Rer eco PP E Re iei ee 16 The Life Cycle of an Algorithm
5. 0 virtual void post 0 virtual void metaPost IlcGoalI ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 29 SEPARATION OF GOALS FROM DEMONS AND CONSTRAINTS Solver 5 1 code part of the synopsis of IlcGoall IlcDemonI and IlcConstrainti class IlcGoall IlcGoalI IlcManagerI IlcGoalI IlcManager virtual IlcGoal execute 0 virtual void propagate virtual void metaPostDemon IlcDemonI y class IlcDemonI public IlcDemonlI IlcManagerI manager IlcConstraintI ct 0 IlcDemonlI IlcManager manager IlcConstraintI ct 0 virtual void propagate 0 previously executeDemon virtual void metaPostDemon IlcDemonI y class IlcConstraintI public IlcDemonI public IlcConstraintI IlcManagerI IlcConstrainti IlcManager virtual IlcGoal execute for compatibility only virtual void propagate 0 virtual void post 0 virtual void metaPostDemon IlcDemonI virtual void metaPost IlcGoalI for compatibility only y There are four main changes in Solver 5 1 1 The function executeDemon has been renamed as propagate Therefore if you decide to subclass IlcDemoni yourself and not use the macro you should overload the member function propagate instead of the member function executeDemon For compatibility with Solver 4 4 the ILCDEMON macros have been changed with regard to this modification In Solver 5 1 these macros return an instance of 11cDemon instead of an instance of 11c
6. IloPort p IloMinSizeFirst IloConfigStrategy st IloGoal IloInstantiate IloEnv env IloPort p IloMinSizeFirst IloConnectionSelect sel IloDeepInstantiate IloEnv env IloPort p IloMinSizeFirst IloConfigStrategy st IloConnectionSelect sel Obsolete Obsolete ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 73 e o E e 9 e le Configurator 1 0 API Configurator 2 1 API IlcConfigurator IlcConfigurator IlcManager m IlcInt cardMax 10000 addType const chart name IlcComponentI proto 0 IlcInt estimatedSize 256 addType const char name const char superName addTypeTable IlcComponentTvpe tl IlcComponentType t2 IlcCompatibility compat const char name 0 close error const char message existType const char name getCardMax getHeap getManager getPhase getType const char name getTypeTable const char name isLinked link link ostream amp os newPhase IloConfigurator IloConfigurator IloSolver solver IloCatalog IloCatalog IloCatalog IloCatalog setCardMax IloInt cardMax addType const char name IloInt estimatedSize 256 addType const char name const char superName addTypeTable IloComponentType tl IloComponentType t2 IloCompatibility compat const char name 0 loConfigurator close IloComponentType t loConfigError loCatalog existType const char name loCatalog getCardMax Ob
7. endl Solver 5 1 code IloEnv env IloModel model env load problem IloSolver solver model We find a first solution solver solve myIl0oGoall We update the model model add obj lt solver getValue obj model add IloMinimize obj we find the optimal solution solver solve myIloGoal2 solver out lt lt Found an optimal solution lt lt endl ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 27 TRANSLATING SEARCH CODE Multi Phase Search with Continue Here we illustrate how to rewrite code that searches for one partial solution by means of a given goal commits its preliminary results adds a constraint and searches for a complete solution by means of another goal Solver 4 4 code IlcManager m IlcEdit load problem m add myIlcGoall nextSolution commit add myIlcConstraint setObjMin obj remove myIlcGoall add myIl1cGoal2 333333 while m nextSolution result IlcTrue m restart m nextSolution m out Found an optimal solution endl Solver 5 1 code using a solve in the first search IloEnv env IloModel model env load problem IloSolver solver model We find a first solution solver solve mylloGoall We update the model model add myIloConstraint model add TloMinimize obj we find the optimal solution Solver solve mylloGoal2 IloSynchronizeAndContinue Solver out Found
8. getNumberOfInstances IloComponentType t getPort const char name Obsolete getTypeAttr Obsolete IloConfiguration isClosed IloComponentType t IloConfigurator isClosed IloComponentType t isLeaf isRoot isSubTvpeOf IloComponentType aType isSuperTvpeOf IloComponentType aType 70 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE Configurator 1 0 API Configurator 2 1 API makeInstance const chart name 0 makeInstances IlcInt number printProperties setIntAttrMax const chart name IlcInt max setIntAttrMin const char name Ilcint min SetIntAttrValue const chart name Ilcint value setInterchangeability IlcInterchangeability it setLabel const char label setPortCardinality const char name IlcInt value setPortCardinality const char name const char subType IlcInt value setPortCardinalityMax const chart name IlcInt max setPortCardinalityMax const chart name const char subType lcInt max setPortCardinalityMin const char name IlcInt min setPortCardinalityMin const chart name const char subType IlcInt min setStrategv IlcConfigStrategv aStrategy IloConfiguration makelInstance IloComponentTvpe t const chart name 0 IloConfiguration makelInstances IloComponentTvpe t IloInt number IloConfigurator makelInstances IloComponentTvpe t IloInt number Obsolete setNumAttrMax const chart name IloNum max
9. i if solver solve move cout lt lt Cost lt lt solver getMax cost lt lt endl else cout lt lt lt lt endl if dgls complete break IloDecouple nhood dgls IloGoal restoreSolution IloRestoreSolution env best amp amp instantiateCost solver solve restoreSolution rsol end best end gt z 2 O 2 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 55 TRANSLATING CODE FOR ILCROUTINGPLAN Dispatcher 2 1 Dispatcher 3 1 gts IloDispatcherGLS IloDispatcherTabuSearch void ImproveWithGTS IloDispatcher dispatcher IloRoutingSolution solution IloNHood nhood nhood reset IloNumVar cost dispatcher getCostVar IloEnv env dispatcher getEnv IloGoal instantiateCost IloDichotomize env cost IloFalse TloRoutingSolution rsol solution makeClone env IloRoutingSolution best solution makeClone env IloDispatcherGLS dgls env 0 2 IloDispatcherTabuSearch dt env 5 IloMetaHeuristic meta dgls dt IloSearchSelector sel IloMinimizeVar env dgls getPenalizedCostVar IloGoal move IloSingleMove env rsol nhood meta sel instantiateCost move move amp amp IloStoreBestSolution env best IloSolver solver dispatcher getSolver IloCouple nhood meta for IloInt i 0 i lt 150 i if solver solve move cout lt lt Cost lt lt solver
10. 64 Translating Code for Solutions 0 0 0 a 65 Translating Code for Neighborhoods eee eee 65 Translating Code for Breaks esee nnn 66 Miscellaneous Translations sssesesennennennannnnnennnnn mnn 66 Migrating from Configurator to Concert Technology Lese 67 Migrating from Planner to Concert Technology 77 Translating a Planner Application 78 Creating the Working L 78 Adding Constraints ia a e A A qe 78 Setting the Objective Function 0 79 Optimizing 2 22 Dat eee attest eas XE ELE Leia A UL wed 79 Getting the Results csse bean Re RR x RERO RE RR dee 80 Exceptions scientists viet 82 Bound Clianges ree eer Cog eee we RR RT Odd RR PER aera eb Rud 82 Constraint Removal iu a a 82 Parameter Handling LL 82 Basis Handling dat da 84 Handling Problem Types eee 84 ep CL eee ISA a ee ae ee ded ede 85 Priority Orders ede eet ke tai deed Re eid EM 85 Callbacks 5 x rot Anes et a ed ota Reale 85 Translating a Planner Application in Search Mode 88 Creating the Working Object cette m 88 Adding Constraints decidir nae A da wale Re A bed Cc 88 Setting the Objective Function L 89 Getting Results
11. an instance of 11cGoa1 in an existing Solver 4 4 application needs to be wrapped You must define the virtual member function IloGoal extract so that it accepts an instance of IloSolver and returns and instance of 11cGoal The following steps show how the goal 11cInstantiate IlcIntVar is wrapped in a Concert model object 1 Create a subclass of the class 110Goa1I class IloIntInstantiatel public IloGoall IloNumVarI var public IloIntInstantiateI IloEnvI IloNumVarI virtual IlcGoal extract const IloSolver const virtual IloGoalI makeClone IloEnvI env const virtual void display ILOSTD ostream amp const y 2 Write the constructor IloIntInstantiateI IloIntInstantiateI IloEnvI e IloNumVarI v IloGoall e _var v l 3 Write the member functions makeClone and display IloGoalI IloIntInstantiateI makeClone IloEnvI env const return new env IloIntInstantiatel env IloNumVarI var makeClone env void IloIntInstantiateI display ostream amp str const str IloIntInstantiateI var ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 21 J9AJOS Z WRAPPING EXISTING SOLVER CODE 22 4 5 Write the critical member function extract IlcGoal IloIntInstantiateI extract const IloSolver solver const IlcGoal goal Check if the variable is integer if solver isInteger var Get the corresponding algorithmic objects IlcIntVar svar solver g
12. edit mode At installation you must include the header file ilcplex ilocplex h Creating the Working Object The class that handles linear constraints in edit mode is now 11oCplex It replaces the class IlcLinOpt The declarations IlcManager m IlcEdit IlcLinOpt lo m are converted to IloEnv env IloCplex cplex env Adding Constraints The member function void IlcLinearSolver add IlcConstraint ct IlcBool postAll does not have a direct equivalent in 11o0Cplex In Concert Technology constraints are added to a model via the memberfunction IloExtractable IloModel add const IloExtractable x const See Chapter 2 Migrating from Solver to Concert Technology to find out more about how linear constraints of the type 11cConstraint are now created and added to an instance of IloModel All the linear constraints and the objective function of a model are extracted by the extract member function of the class IloCplex void IloCplex extract const IloModel model 78 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING A PLANNER APPLICATION IN EDIT MODE Setting the Objective Function Setting and changing the objective function is done in the model in Concert Consequently the following lines IlcFloatVar IlcLinearSolver setObjMin IlcFloatExp exp IlcBool postAll IlcFalse const IlcIntVar IlcLinearSolver setObjMin IlcIntExp exp IlcBool postAll IlcFalse const Jouueld 9 are now r
13. from ILOG Solver 15 migrating from Planner 77 migrating from Scheduler 37 Configurator migration steps 67 translation table 68 conventions in this document names X typography X D Dispatcher search 51 translation tables 52 documentation xi ILCCTDEMON macro 30 ILCCTPUSHDEMON macro 30 macro ILCCTDEMON 30 ILCCTPUSHDEMON 30 ILOCPCONSTRAINTWRAPPER 20 migration paths ix N naming conventions in this document X P Planner translating from edit mode 78 translating search mode 88 S Scheduler migration steps 38 parameters 43 translating an example 40 Solver goals 29 migration steps 17 translating search 23 ILOCPCONSTRAINTWRAPPER macro 20 wrapping code 18 wrapping goals 21 ILOG CONCERT TECHNOLOGY 1 2 MIGRATION GUIDE Index 95 INDEX T tvpographic conventions X version numbers ix 96 ILOG CONCERT TECHNOLOGY 1 2 MIGRATION GUIDE
14. getMax 1 void IlcLessThanCtI metaPost IlcGoalI ct x whenRange ct y whenRange ct 32 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE SEPARATION OF GOALS FROM DEMONS AND CONSTRAINTS In Solver 5 1 this code is translated as follows class IlcLessThanCtI public IlcConstraintI Xx y IlcIntVar xXx IlcIntVar y public IlcLessThanCtI IlcIntVar x IlcIntVar y IlcConstraintI x getManager _x x _y y IlcBool isViolated const IlcConstraintI makeOpposite const void post void propagate void metaPostDemon IlcDemonI WARNING NEW FUNCTION lcBool IlcLessThanCtI isViolated const return x getMin y getMax J9AJOS Z lcConstraintI IlcLessThanCtI makeOpposite const return new getManager IlcGreaterThanOrEqualToCt getManager x y void IlcLessThanCtI xPropag y setMin x getMin 1 ILCCTDEMONO xDemon IlcLessThanCtI xPropag void IlcLessThanCtI yPropag x setMax y getMax 1 ILCCTDEMONO yDemon IlcLessThanCtI yPropag void IlcLessThanCtI post x whenRange xDemon getManager this y whenRange yDemon getManager this void IlcLessThanCtI propagate y setMin x getMin 41 x setMax y getMax 1 void IlcLessThanCtI metaPost IlcDemonI ct x whenRange ct y whenRange ct ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 33 SEPARATION OF GOALS FROM DEMONS AN
15. ilsolver ilohvbrid h Creating the Working Object The class that handles linear constraints in search mode is now I1oLinConstraint It replaces IlcLinopt The declarations IlcManager m IlcEdit IlcLinOpt lo m are replaced in Concert 1 1 and Solver 5 1 by IloEnv env IloSolver solver env IloLinConstraint lc solver Adding Constraints The member function void IlcLinearSolver add IlcConstraint ct IlcBool postAll does not have a direct equivalent in IloLinConstraint Constraints are added to a model using the associated instance of 110Solver We distinguish two cases the call of this function in edit mode and the call in search mode In the first case the function call is part of the model definition and is equivalent to the addition of a constraint to a model via the member function IloExtractable IloModel add const IloExtractable x const See Chapter 2 Migrating from Solver to Concert Technology to learn more about how linear constraints of type IlcConstraint are now created and added to an instance of IloModel All linear constraints of a model are extracted to each instance of IloLinConstraint created with a solver when the following member function is called void IloSolver extract const IloModel model const In the second case the constraint is created in search mode and it must be of type IlcConstraint A linear constraint of a model is added to each instance of IloLinConstraint crea
16. instantiate IlcTypeVar tvar loGoal IloInstantiate IloEnv IloTypeAttr x instantiate IlcTypeVar tvar loGoal IloInstantiate IloEnv IloTypeAttr x lcTypeSelect selector loTypeSelect select instantiate IlcPort p loGoal IloConnectOne IloEnv IloPort p IlcBool recursive IlcTrue loGoal IloDeepConnectOne IloEnv IloPort p IloConfigStrategy instantiate IlcPort p loGoal IloConnectOne IloEnv IloPort p IlcConnectionSelect selector IloConnectionSelect select IlcBool recursive IlcTrue loGoal IloDeepConnectOne IloEnv IloPort p IloConfigStrategy IloConnectionSelect maxInstantiate IlcPort p IloGoal IloInstantiate IloEnv env IloPort p IlcBool recursive IlcTrue IloMaxSetFirst IloGoal IloDeepInstantiate IloEnv env IloPort p IloMaxSetFirst IloConfigStrategy st 72 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE Configurator 1 0 API Configurator 2 1 API maxInstantiate IlcPort p IlcConnectionSelect selector IlcBool recursive IlcTrue minInstantiate IlcPort p IlcBool recursive IlcTrue minInstantiate IlcPort p IlcConnectionSelect selector IlcBool recursive IlcTrue apply getManager IloGoal IloInstantiate IloEnv env IloPort p IloMaxSetFirst IloConnectionSelect sel IloGoal IloDeepInstantiate IloEnv env IloPort p IloMaxSetFirst IloConfigStrategy st IloConnectionSelect sel IloGoal IloInstantiate IloEnv env IloPort p IloMinSizeFirst IloGoal IloDeepInstantiate IloEnv env
17. mgl ee a eee ined 90 Optimization Algorithms 21 25 bik be a eed ba bees 91 Precision Handling eed A Ve ee pede OE eee ee EE 92 Variable Instantiation s eie en a a Sak a Sop ele es ee ees 92 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE vii TABLE OF CONTENTS EXCeptiOns d 93 Goals eed e P atus EE iei eoe ER pri le DRE le RR 93 Miscellaneous Functions o RR RR RA n 93 Variable Selectioni Ca t ba Lond ios do 94 Index IE LUI a a 95 viii ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE About This Manual This manual is intended to help customers translate their existing ILOG Optimization applications into Concert Technologv Each chapter is dedicated to a product and includes mappings between class names functions macros and tvpe definitions in the current versions and their equivalents in Concert versions About Concert Technology ILOG Concert Technology provides a means of modeling and solving optimization problems enabling you to formulate optimization problems independently of the algorithms that solve the problem It provides an extendable modeling layer adapted to a variety of ready to use algorithms The migration paths to Concert Technology are the following Before Concert Concert Technology ILOG Solver 4 4 to ILOG Solver 5 1 ILOG Concert Technology 1 1 ILOG Scheduler 4 4 to ILOG Scheduler 5 1 ILOG Dispatc
18. on the number of heads model add nbRabbits nbPheasants 20 set up the constraint on the number of legs model add 4 nbRabbits 4 2 nbPheasants 56 J9AJOS Z create the solver and extract the model IloSolver solver model solve the problem solver solve print solution solver out Rabbits lt lt solver getValue nbRabbits lt lt endl solver out lt lt Pheasants lt lt solver getValue nbPheasants lt lt endl catch IloException amp ex cerr Error ex endl release the resources of the env and on the solver env end return 0 Code Sample 2 2 Translation of the Pheasant Example in Solver 5 1 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 19 WRAPPING EXISTING SOLVER CODE Wrapping User Defined Constraints Use the ILOCPCONSTRAINTWRAPPER macro to wrap the existing IlcConstraint in Concert model objects An IlcConstraint is wrapped in an IloConstraint then extracted by Solver from the model and then put back in the 11cConst raint The following code ILOCPCONSTRAINTWRAPPERI IloFreqConstraint solver IloNumVarArray vars use solver vars return IlcFreqConstraint solver solver getIntVarArray vars is expanded into class IloFreqConstraintI public IloCPConstraintI ILOCPCONSTRAINTWRAPPERDECL private IloNumVarArray _vars public IloFreqConstraintI IloEnvI const IloNumVarArray amp const char vi
19. solution and add vehicles only IlcGenerate IloDispatcherGenerate IlcInsertionGenerat IloInsertionGenerat IlcInstantiateTransits IloInstantiateTransits IlcInstantiateVehicleBreak IloInstantiateVehicleBreak IlcInstantiateVehicleBreaks IloInstantiateVehicleBreaks IlcInstantiateVehicleBreakDuration IloInstantiateVehicleBreakDuration IlcInstantiateVehicleBreakPosition IloInstantiateVehicleBreakPosition IlcInstantiateVehicleBreakStart IloInstantiateVehicleBreakStart IlcNearestAdditionGenerate IloNearestAdditionGenerate IlcNearestDepotGenerat IloNearestDepotGenerat IlcSavingsGenerate IloSavingsGenerate IlcSweepGenerate IloSweepGenerate 64 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING CODE FOR SOLUTIONS Translating Code for Solutions Dispatcher 2 1 Dispatcher 3 1 IlcRoutingSolution IloRoutingSolution solution getCost solution getSolution getObjectiveValue read Not applicable Translating Code for Neighborhoods Dispatcher 2 1 Dispatcher 3 1 IlcCross IloCross IlcExchange IloExchange IloSwapPerform forunperformed visits IlcExchangePair IloExchange IloSwapPerform for unperformed visits IlcMove Equivalent of 11oNHood IlcOrOpt IloOrOpt IlcRelocate IloRelocate IloMakePerformed and IloMakeUnperformed for unperformed visits B IlcRelocatePair IloRelocate I
20. you call the resolution function like this IloSolver solver model IloGoal goal IloRankForward env makespan if solver solve goal PrintSolution solver else ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 41 A TRANSLATION EXAMPLE solver out No solution endl If you want to improve the resolution heuristics you will define a goal yourself using the macro ILOCPGOALWRAPPERX Which allows you to return a search goal ILOCPGOALWRAPPERI MvRank solver IloNumVar makespan IloIntVar obj solver getIntVar makespan IlcScheduler schedule solver return IlcRank schedule obj The constructor IlcScheduler IloSolver solver gives you the instance of IlcScheduler of the solver 11cScheduler is a subclass of IlcSchedule that enables you to write the scheduling goal just as in Scheduler 4 4 Accessing the Solution After resolution you can either directly read the data in the problem data structures or use instances of the IloSchedulerSolution to store the data You can use such stored solutions as the basis of your next attempt to search for a solution if you like Before attempting another search you can also make changes in a model For example you can add or remove constraints from the model extract it again and resolve That is the changes in a model may be monotonic or non monotonic Creating Activities The creation of the activities in a model is similar to the
21. 3 3 it is possible to specify a priority order for branching on variables with the member function void setPriOrder IlcIntVarArray vars IlcIntArray priorities IlcIntArray directions const where priorities contains the priorities for the variables in the array vars and directions contains the branching directions for the variables in vars In Concert and CPLEX priorities for an array of variables are specified with the member function void IloCplex setPriorities const IloNumVarArray var const IloNumArray pri and the branching directions are specified with the member function void IloCplex setDirections const IloNumVarArray var const BranchDirectionArray dir The branching directions are translated in the following way IlcBranchGlobal becomes IloCplex BranchGlobal IlcBranchUp becomes IloCplex BranchUp IlcBranchDown becomes IloCplex BranchDown Callbacks In Planner 3 3 callbacks are defined with the macro ILCCALLBACK its body is the main code to execute Then callback is set to the TloLinOpt instance as an LP callback with a call to the member function void IloLinOpt setLPCallback IlcCallBack or as a MIP callback with a call to the member function void IloLinOpt setMIPCallback IlcCallBack ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 85 TRANSLATING A PLANNER APPLICATION IN EDIT MODE In Concert 1 1 and CPLEX 7 1 callbacks are defined in a similar way However there are several types of callb
22. D CONSTRAINTS Note that in Solver 4 4 the macro ILCDEMON2 xDemon IlcIntVar x IlcIntVar y y setMin x getMin 1 generates a code similar to the following lines class xDemonI public IlcDemonI IlcIntVar x IlcIntVar y public xDemonI IlcManagerI manager IlcIntVar xx IlcIntVar yy IlcDemonI manager x xx y yy void executeDemon y void xDemonI executeDemon y setMin x getMin 1 lcGoal xDemon IlcManager m IlcIntVar x IlcIntVar y return new m getHeap xDemonI m getImpl x y whereas in Solver 5 1 the macro LCDEMONO xDemon IlcLessThanCtI xPropag generates a code similar to the following lines class xDemonI public IlcDemonI public xDemonI IlcManagerI manager IlcLessThanCtI ctI lcDemonI manager ct void propagate void xDemonI propagate IlcLessThanCtI getConstraintI xPropag lcDemon xDemon IlcManager m IlcLessThanCtI ct return new m getHeap xDemonI m getImpl ct Now we can find out whether or not a demon is a constraint by using the isAConstraint member function IlcBool IlcDemonI isAConstraint 34 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE OBSOLETE FUNCTIONS AND CLASSES Moreover we can also find out whether or not a constraint has been created at the top level or in a goal or added by another constraint or a demon by using the getParentI member function IlcDemonI IlcConstraintI getPa
23. Goa1 and should no longer be used see point 3 2 In Solver 5 1 a demon should always be associated with a constraint and this constraint must be passed as an argument of the constructor of 11cDemon1I Moreover instead of writing code in the executeDemon function of an IlcDemonIi you should just call a member function of the associated constraint 3 New macros ILCCTDEMON and ILCCTPUSHDEMON have been introduced in order to facilitate the creation of 11cDemon They replace the ILCDEMON macros ILCCTDEMONO name IlcCtClass IlcFnName will define a demon named name associated with a constraint which is an instance of the class I1cCtClass The propagate member function of this demon will contain only the call to function IlcFnName ofthe constraint ct gt I1cFnName 30 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE SEPARATION OF GOALS FROM DEMONS AND CONSTRAINTS This is a possible definition ILCCTDEMON MyDemon MyConstraint fnOfCt The demon will be defined bv MyDemon ct where ct must be an instance of MyConstraint ILCCTPUSHDEMONO name IlcCtClass will define a demon named name associated with a constraint which is an instance of the class I1cCtClass The propagate member function of the demon will contain only the call to the push member function of the constraint 4 New whenValue whenRange whenDomain functions have been introduced IlcIntExp whenValue const IlcDemon demon IlcIntExp wh
24. ILOG Concert Technology Reference Manual then you add its constraints to a model then you extract the model for an algorithm In Scheduler 4 4 the following lines void MakeResource IlcSchedule schedule const char name IlcInt numberOfActivities IlcActivity activities IlcManager m schedule getManager IlcUnaryResource resource schedule resource setName name for IlcInt i 0 i numberOfActivities 111 m add activities i l requires resource resource close are equivalent in Scheduler 5 1 to these lines void MakeResource IloModel model const char name IloInt numberOfActivities IloActivityArray activities IloEnv env model getEnv IloUnaryResource resource env name for IloInt i 0 i lt numberOfActivities 111 model add activities i requires resource ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 45 A TRANSLATION EXAMPLE 46 Global Constraints of Scheduler 4 4 Become Parameters in Scheduler 5 1 There is also parameter management in the resources of ILOG Scheduler 5 1 Basicallv the parameters are annotations of the resource The parameters declare the exact behavior and content of a resource In practice these annotations allow you to enforce and precisely define constraints to apply on sets of activities requiring the resource Those constraints on a resource might include for example the capacity levels of a discrete resource the break list of a
25. Local search This is now a part of ILOG Solver Users of ILOG Planner and ILOG CPLEX will see the following benefits The time and memory required to instantiate a mathematical program is significantly reduced when using ILOG Concert Technology with ILOG CPLEX 7 1 in comparison with using ILOG Planner 3 3 A complete C API for problem modifications is provided including adding and deleting variables and constraints as well as modifications of individual coefficients This allows for example column generation techniques to be easily implemented For hybrid optimization it is now much easier to extract the linear part of a model and treat the linear part as a single global constraint Therefore the benefits listed for users of ILOG Solver apply to users who combine ILOG CPLEX and ILOG Solver 14 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE Migrating from Solver to Concert Technologv Details of the new features and major changes in ILOG Solver 5 1 appear in the ILOG Solver 5 1 Release Notes This chapter aims to show the impact of these changes by comparing Solver 4 4 code and Solver 5 1 code Concert Technology provides the following features for Solver users clean separation of model and algorithm new data types change in the life cycle of an algorithm wrapping of Solver 4 4 code re implementation of search techniques separation of goals from demons and constraints We recommend that y
26. Reference Manual 2 Create the model an instance of 11oMode1 also documented in the ILOG Concert Technology Reference Manual 3 Translate problem data into appropriate ILOG Concert Technology types For example values of 11cF1oat become r1oNum values of I1cInt become IloInt and so forth Likewise arrays of IlcFloatArray become arrays of IloNumArrav 4 Translate constrained variables from your old application to ILOG Concert Technology variables or to ILOG Scheduler 5 1 variables For example 11c1ntvar becomes IloIntVar and IlcFloatVar becomes IloNumVar documented in the ILOG Concert Technology Reference Manual 5 Wrap the old Solver 4 4 constraints instances of I1cConstraint or its subclasses 6 Add the wrapped constraints to the model 7 Ifthere are search goals in your old application wrap the old Solver 4 4 goals instances of IlcGoal or its subclasses as shown in the section Translating Search Code on page 23 8 Create the solver an instance of 110So1ver and its goal The solve function will automatically extract the model and solve it with the goal given as argument 9 Translate the search code from your old application according to the steps outlined in the section Translating Search Code on page 23 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 17 WRAPPING EXISTING SOLVER CODE Wrapping Existing Solver Code In this section examples are provided to show how Solver 4 4 code is wrapped in Concer
27. Var var const loNum IloCplex getReducedCost const IloNumVar x const lcFloat IlcLinOpt getDualValue IlcConstraint c const translated to the member functions Similarly the member function loNum IloCplex getObjValue Jouueld 9 loNum IloCplex getDual const IloRange range lcFloat IlcLinOpt getSlackValue IlcConstraint c const translated to the member function loNum IloCplex getSlack const IloRange range To obtain the objective value the member function lcFloat IlcLinOpt getObjValue const const The correspondence between Planner 3 3 and Concert CPLEX functions for obtaining statistics is given in the following table Planner 3 3 Functions Concert 1 1 and CPLEX 7 1 Functions IlcInt IlcLinOpt getNbOfConstraints const IloInt IloCplex getNrows const IlcInt IlcLinOpt getNbOfVars const IloInt IloCplex getNcols const IlcInt IlcLinOpt getNbOfNonZeros const IloInt IloCplex getNnz const IlcInt IlcLinOpt getNbOfIterations const IloInt IloCplex getNiterations const ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 81 TRANSLATING A PLANNER APPLICATION IN EDIT MODE 82 Exceptions The call to the member function void IlcLinOpt useExceptions IlcBool useIt IlcTrue const has no equivalent in 110LinConstraint since exceptions are now always used in Concert and CPLEX The class 11cLinOptException of exceptions thrown in Planner 3 3 i
28. ack getInfeasibility const IlcCallbackInfoDualInfMeas IloNum IloCplex LPCallback getInfeasibility const IlcCallbackInfoPrimalFeas IloBool IloCplex LPCallback isFeasible const IlcCallbackInfoDualFeas IloBool IloCplex LPCallback isFeasible const IlcCallbackInfoIltCount IloInt IloCplex LPCallback getNiterations const 86 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING A PLANNER APPLICATION IN EDIT MODE Crossover information is accessible onlv in crossover callbacks defined with the macro ILOCROSSOVERCALLBACK The mapping is Planner 3 3 Concert 1 1 and CPLEX 7 1 IlcCallbackInfoCrossoverPPush IloInt IloCplex CrossoverCallback getNprimalPushes const IlcCallbackInfoCrossoverPExch loInt IloCplex CrossoverCallback getNprimalExchanges const IlcCallbackInfoCrossoverDPush IloIn IloCplex CrossoverCallback getNdualPushes const Jouueld 9 IlcCallbackInfoCrossoverDExch IloInt IloCplex CrossoverCallback getNdualExchanges const IlcCallbackInfoCrossoverSbCnt IloInt IloCplex CrossoverCallback getNsuperbasics const For information available in MIP callbacks the mapping is Planner 3 3 Concert 1 1 and CPLEX 7 1 lcCallbackInfoNodeCount oInt IloCplex MIPCallback getNnodes const lcCallbackInfoNodesLeft oInt IloCplex MIPCallback getNremainingNodes const lcCallbackInfoMIPIteration
29. acks AnLP callback is defined with the macro ILOLPCALLBACK AMIP callback is defined with the macro ILOMIPCALLBACK More specific callbacks can be defined with other macros For instance e ILOPRESOLVECALLBACK defines a callback called from the IloCplex presolve routine e ILOCROSSOVERCALLBACK defines a callback called from the 110Cp1ex crossover routine Callbacks are then set to the 110Cp1ex instance with a call to the member function IloCplex Callback use IloCplex Callback Planner 3 3 provides the following member functions to read information from the code of a callback IlcFloat IlcLinOpt getCallbackInfo IlcFloatCallbackInfo whichInfo const IlcInt IlcLinOpt getCallbackInfo IlcIntCallbackInfo whichInfo const where IlcFloatCallbackInfo and IlcIntCallbackinfo are enumerated types of information that can be read In Concert and CPLEX each piece of information is obtained with a specific member function of I1oCplex LPCallback and IloCplex MIPCallback With regard to information available in LP callbacks the following table maps the Planner 3 3 enumerated type and the Concert and CPLEX member function Planner 3 3 Concert 1 1 and CPLEX 7 1 IlcCallbackInfoPrimalObj IloNum IloCplex LPCallback getObjValue IlcCallbackInfoDualObj IloNum IloCplex LPCallback getObjValue IlcCallbackInfoPrimallInfMeas IloNum IloCplex LPCallb
30. added to Solver to equalize the objective function and the variable returned by the setObjMax or setObjMin function If postAll IlcTrue this constraint is also added to Solver For this constraint to be added to Solver in Concert Technology it is now necessary to call the function void IloLinConstraint setSynchronization IloLinConstraint Synchronization s with s LinConstraintAndSolver before extracting the model Note that IloLinConstraint allows you to change the objective function in a reversible way with the member functions void IloLinConstraint setObjMin const IlcFloatExp e IloBool propagate IloTrue void IloLinConstraint setObjMin const IlcIntExp e IloBool propagate IloTrue The translation is similar for the member functions IlcFloatVar IlcLinearSolver setObjMax IlcFloatExp exp IlcBool postAll IlcFalse const IlcIntVar IlcLinearSolver setObjMax IlcIntExp exp IlcBool postAll IlcFalse const ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 89 TRANSLATING A PLANNER APPLICATION IN SEARCH 90 Getting Results The member functions IlcFloat IlcLinearSolver getCurrentValue IlcFloatExp var const IlcFloat IlcLinearSolver getCurrentValue IlcIntExp var const are converted to IloNum IloLinConstraint getValue const IloExpr e const Since the classes IloExpr and IloNumVar are unrelated we also have IloNum IloLinConstraint getValue const IloNumVar x const Observe that
31. al solver out Found one solution endl else solver out No Solutions endl ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 23 TRANSLATING SEARCH CODE 24 Find the Optimal Solution Solver 4 4 code IlcManager m IlcEdit load problem m add myIlcGoal IlcBool result IlcFalse while m nextSolution result IlcTrue if result m restart m nextSolution m out Found an optimal solution endl else m out lt lt No Solutions lt lt endl Solver 5 1 code with an Objective To find the optimal solution we use an instance of the class IloObjective to specify an objective to minimize or to maximize The function 110Minimi ze returns an instance of the class IloObjective In the following code sample we assume mvIloGoal is a wrapper around mvIlcGoal Given an objective variable obj we write the following code loEnv env loModel model env load problem model add IloMinimize obj loSolver solver model if solver solve myIloGoal solver out Found one solution endl else solver out No Solutions endl ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING SEARCH CODE Solver 5 1 code with Search You can do additional things e g print the objective value at intermediate solutions IloEnv env IloModel model env load problem model add IloMinimize obj IloS
32. also that the functions in ILOG Dispatcher 2 1 which take as argument an instance of IlcRoutingPlan now take in Dispatcher 3 1 an instance of IloEnv To summarize here is the beginning of a Dispatcher 2 1 program lcManager m IlcEdit lcRoutingPlan plan m lcDimension2 time plan IlcEuclidean Time lcDimension2 length plan IlcEuclidean Length lcDimensionl weight plan Weight and the corresponding beginning of a Dispatcher 3 1 program loEnv env loModel mdl env loDimension2 time env IloEuclidean Time mdl add time loDimension2 length env IloEuclidean Length mdl add length loDimensionl weight env Weight mdl add weight loNode depot env depotX depotY loVisit first depot Depot mdl add first getCumulVar time gt openTime loVehicle vehicle first last name vehicle setCost length 1 0 vehicle setCapacitv weight capacity mdl add vehicle Once the model is stated it can be extracted and solved using the specific algorithms provided by Dispatcher IloSolver solver mdl IloDispatcher dispatcher solver IloRoutingSolution solution mdl 50 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE SEARCH FEATURES Search Features The search has been modified in two ways in ILOG Dispatcher 3 1 As said previously any object or function taking an I1cRoutingP lan in ILOG Dispatcher 2 1 now takes an instance of IloEnv This of course applies to the s
33. am newDefaultParam In consequence from now on the activities we create are non breakable IloActivity AB1 MakeActivity model ABl 1 The constructor of a schedule an instance of 11cSchedule in Schedule 4 4 required an origin and a horizon that is two integer values used as defaults to define the range of the date variable of an activity Here is an example of that old convention IlcInt origin 0 IlcInt horizon 365 IlcManager m IlcNoEdit IlcSchedule schedule m origin horizon This information is no longer required in Scheduler 5 1 If you still need to make this information explicit in your application you use the scheduler environment like this IloNum origin 0 IloNum horizon 365 IloEnv env IloSchedulerEnv schedEnv env SchedEnv setOrigin origin schedEnv setHorizon horizon These values will be used bv the model and the extractor as default values when needed Adding Constraints In Scheduler 4 4 activities were defined in terms of constrained variables that were instances of ILOG Solver classes such as IlcIntVar or IlcFloatVar During a search for a solution ILOG Solver 4 4 attempted to assign values to those decision variables Furthermore it was possible to add constraints to a manager an instance of IlcManager while it was in edit mode In other words there was not an entirely clear distinction between the modeling variables of an activity and the search for a solution For e
34. an optimal solution endl 28 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE SEPARATION OF GOALS FROM DEMONS AND CONSTRAINTS Separation of Goals from Demons and Constraints In Solver 4 4 I1cDemonI derives from 11cGoalI and IlcConstrainti derives from IlcGoall The advantage is that you can always pass an instance of IlcConstraintI when an instance of IlcGoall is expected However this may also lead to some confusion In Solver 5 1 11cConstraintI derives from I1cDemonI and I1cGoa1I is separated The advantage of this method is that it is now possible to have a clear separation between the notion of goal and the notion of constraint A goal is used to define and control the search procedure and a constraint is used to perform some domain reductions of variables For compatibility with Solver 4 4 it remains possible to pass a goal when a constraint is expected The converse operation is also possible Solver 4 4 code part of the synopsis of I1cGoalI IlcDemonI and IlcConstrainti class IlcGoall IlcGoalI IlcManagerI IlcGoalI IlcManager virtual IlcGoal execute 0 J9AJOS Z virtual void executeDemon y class IlcDemonI public IlcGoall public IlcDemonI IlcManagerI manager IlcDemonI IlcManager manager virtual IlcGoal execute virtual void executeDemon 0 y class IlcConstrainti public IlcGoall IlcConstraintI IlcManagerI IlcConstraintI IlcManager virtual void propagate
35. aram IlcStringParam const char const ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING A PLANNER APPLICATION IN EDIT MODE In Concert and CPLEX this is done with the member functions void IloCplex setParam BoolParam parameter IloBool value void IloCplex setParam IntParam parameter IloInt value void IloCplex setParam NumParam parameter IloNum value void IloCplex setParam StringParam parameter const char value Oo The Planner 3 3 member function to reset all parameters to their default values U Q void IlcLinOpt setParamsDefault const O is now in Concert and CPLEX D void IloCplex setDefaults The member functions that read parameters IlcBool IlcLinOpt getParam IlcBoolParam const IlcInt IlcLinOpt getParam IlcIntParam const IlcFloat IlcLinOpt getParam IlcFloatParam const char IlcLinOpt getParam IlcStringParam char buffer const are now called IloBool IloCplex getParam BoolParam parameter const IloInt IloCplex getParam IntParam parameter const IloNum IloCplex getParam NumParam parameter const const char IloCplex getParam StringParam parameter const To read default values and the range of values of parameters the member functions ILOG CONCERT TECHNOLOGY 1 1 lcBool IlcLinOpt getParamDefault IlcBoolParam const lcInt IlcLinOpt getParamDefault IlcIntParam const lcFloat IlcLinOpt getParamDefault IlcFloatPa
36. ble in ILOG Solver see the functions I1oInstantiate IloGenerate IloBestInstantiate IloBestGenerate documented in the LOG Solver Reference Manual ILOG Scheduler see the functions IloSet TimesForward IloSetTimesBackward IloRankForward IloRankBackward IloSequenceForward IloSequenceBackward IloAssignAlternative documented in the ILOG Scheduler Reference Manual At other times you may want to write a goal yourself To do this you must use the facilities for extending ILOG Solver or ILOG Scheduler namely the classes such as 11cGoa1 or the functions IlcInstantiate IlcGenerate and so forth If your problem requires the dynamic creation of objects in your model that is if you need elements in the model that you can learn only on the fly during the solution search then again you can use the facilities for extending ILOG Solver and ILOG Scheduler Let s return to our example to see those alternatives In Scheduler 4 4 you used the member function I1cManager nextSolution with a basic ranking goal like this m add IlcRank schedule makespan while m nextSolution m out lt lt current value of makespan lt lt makespan lt lt endl m restart if m nextSolution PrintSolution schedule else m out No solution endl In such a case ILOG Scheduler 5 1 offers a predefined goal IloRankForward equivalent to IlcRank After creating the solver and extracting the model
37. bt Gh hee no a Pepe 40 Creating the Model 5 A l gt Bi REGGIO ER ele NERA UE 40 Extracting arid Solvirig 333 ez ki A a MARE RC AU RR Rd 41 Accessing the Solution llis 42 Creating scie coke A 42 Translating Global Constraints into Scheduling 49 Adding Constraints si a a e 44 Creating RESOURCES 65 cuidat ada 45 Global Constraints of Scheduler 4 4 Become Parameters in Scheduler 5 1 46 Using Parameters to Close Resources seen 46 Using Parameters to Invoke Disjunctive Constraint or Edge Finder 46 Using Parameters on Time Intervals 0 0 e 46 Migrating from Dispatcher to Concert Technology Lesser 49 Modeling is Based on Concert Technology eese 49 Search Features iii i uu er aus te rx erre eee eae 51 Correspondence Tables 0c cece ee eee eee e ee n n nnn 52 Translating Code for IlcRoutingPlan Lee 53 Translating Code for llcVisit llle 60 Translating Code for IlcVehicle esee 62 Translating Code for Dimensions eee nnn 62 Translating Code for Distances eee ee 63 ILOG CONCERT TECHNOLOGV 1 1 MIGRATION GUIDE Chapter 5 Chapter 6 TABLE OF CONTENTS Translating Code for GOalS oooocococoncn nee eee
38. cale problem and makes it easy to experiment with different algorithmic strategies for the same problem Concert Technology sets the foundation for the current and future versions of the ILOG Optimization Suite by providing a unifying C API for all ILOG optimization products ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 13 Users of ILOG Solver and the other ILOG optimization products that depend on ILOG Solver will see the following benefits Solution Decomposition Because models are separate from the search algorithms that solve the models it is easy to try different algorithms applied to the same model in order to find the best algorithm for a particular problem Model algorithm separation also allows e changing a problem so that a domain of a variable expands e relaxing part of an infeasible problem in order to find a solution Multiphase Search It is now easier to split a problem into smaller parts write separate algorithms for each part and store solutions for the individual parts Cooperation The Concert framework facilitates e Automatic model extraction A constraint programming CP or linear programming LP model can be automatically extracted and passed to the corresponding solver e Solver cooperation Other algorithms can cooperate with constraint programming techniques e Nonlinear problem solving The Numerica domain reduction algorithms can be applied to a nonlinear problem over real variables e
39. cher getNbOfSuccesses rplan getNbOfUnperformedVisits dispatcher getNbOfUnperformedVisits rplan getNbOfVehicles dispatcher getNbOfVehicles rplan getNbOfVehiclesUsed dispatcher getNbOfVehiclesUsed rplan getNbOfVisits dispatcher getNbOfVisits rplan getNowhere IloNode IloEnv env IloBool everywhere const chart name 0 rplan getPenFactor IloDispatcherGLS getPenaltyFactor rplan getTotalCost dispatcher getTotalCost rplan getVehicle IlcInt dispatcher getVehicle IloInt rplan getVisit IlcInt dispatcher getVisit IloInt 54 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING CODE FOR ILCROUTINGPLAN Dispatcher 2 1 Dispatcher 3 1 rplan gls IloDispatcherGLS with IloMinimizeVar selector void ImproveWithGLS IloDispatcher dispatcher IloRoutingSolution solution IloNHood nhood nhood reset IloNumVar cost dispatcher getCostVar IloEnv env dispatcher getEnv IloGoal instantiateCost IloDichotomize env cost IloFalse IloRoutingSolution rsol solution makeClone env IloRoutingSolution best solution makeClone env IloDispatcherGLS dgls env 0 2 IloSearchSelector sel IloMinimizeVar env dgls getPenalizedCostVar IloGoal move IloSingleMove env rsol nhood dgls sel instantiateCost move move amp amp IloStoreBestSolution env best IloSolver solver dispatcher getSolver loCouple nhood dgls for IloInt i 0 i lt 150
40. constraints e g IlcResourceConstraint IlcPrecedenceConstraint in the corresponding constraints in ILOG Concert Technology e g IloResourceConstraint IloPrecedenceConstraint The IlcAltResSet and IlcAltResConstraint instances are replaced by IloAltResSet and IloAltResConstraint instances The Concert model does not define index variables on the alternative resource constraint You can change the Solver constraints and the meta constraint terms using the index variable by adding to the Concert model constraints and meta constraints built from the following two members of IloAltResConstraint IloConstraint IloAltResConstraint select IloResource resource const IloConstraint IloAltResConstraint selectSameResource IloAltResConstraint ct const Add the wrapped constraints to the model If you want to use the same global constraints as you used in your old problem e g disjunctive constraint edge finder these can be managed by setting parameters in ILOG Scheduler 5 1 Translate those global constraints to Scheduler parameters If there are search goals in your old application wrap the old Solver 4 4 goals instances of 11cGoal or its subclasses according to the steps outlined in Chapter 2 Migrating 38 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE How TRANSLATE A PROGRAM FROM SCHEDULER 4 4 TO SCHEDULER 5 1 from Solver to Concert Technology of this Migration Guide 10 Create the solver an instance of 11oSolver a
41. creation of activities in ILOG Scheduler 4 4 applications except for the types of argument In rough terms I1o replaces Ilc in the declaration of most arguments Furthermore an instance of 11cSchedule in an ILOG Scheduler 4 4 application becomes the Concert Technology environment an instance of I1oEnv in an ILOG Scheduler 5 1 application Likewise a value of type I1cInt from a Scheduler 4 4 application becomes a value of type 11oNum in ILOG Scheduler 5 1 Scheduler 4 4 Here for example are lines creating activities in a Scheduler 4 4 application IlcActivity MakeActivity IlcSchedule schedule const char name IlcInt duration IlcActivity activity schedule duration activity setName name return activity 42 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE A TRANSLATION EXAMPLE Scheduler 5 1 Here are the equivalent lines creating an activitv in ILOG Scheduler 5 1 IloActivitv MakeActivitv IloEnv env const chart name IloNum duration IloActivity activity env duration name return activity We now consider the fact that some activities are breakable Scheduler 4 4 IlcActivity MakeBreakableActivity IlcSchedule schedule const char name IlcInt duration IlcBreakableActivity activity schedule duration activity setName name return activity Scheduler 5 1 The member function 11o0Activity setBreakable allows you to declare the fact that an activity is breakable IloActivity activ
42. de for Dimensions 62 Dispatcher 2 1 Dispatcher 3 1 IlcDimension getRoutingPlan Not applicable IlcDimensionIterator IloIterator IloDimension TloIterator lt IloDimensionl gt IloIterator IloDimension2 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING CODE FOR DISTANCES Translating Code for Distances Distance functions consider three parameters in ILOG Dispatcher 3 1 two nodes and a vehicle compared to two in previous versions of ILOG Dispatcher two nodes These simpler distance functions can still be implemented using IloSimpleDistanceFunction and IloSimpleDistanceEvallI Dispatcher 2 1 Dispatcher 3 1 IlcDistance IloDistance IlcDistanceEvall IloDistanceEvall IloSimpleDistanceEvall IlcDistanceFunction IloDistanceFunction IloSimpleDistanceFunction IlcDistancel IloDistancel IlcDistMax IloDistMax IlcEuclidean IloEuclidean IlcExplicitDistance Removed IlcExplicitDistancel IlcGeographical IloGeographical IlcManhattan IloManhattan Mn G 1 2 o mi ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 63 TRANSLATING CODE FOR GOALS Translating Code for Goals Dispatcher 2 1 Dispatcher 3 1 IlcAllUnperformedGenerat When added to an instance of I1oRoutingSolution the saved state of an instance of 11ovisit is unperformed IlcEmptyPlanGenerate Create an empty
43. e loTypeTable lcTypeVar K loTypeAttr in the model lcTypeAttr in the solver lcTypeVarDeltaIterator lcTypeAttrDeltaIterator lcTypeVarlterator lcTypeAttriterator lcWildCard lcWildCard 76 ILOG CoNcERT TECHNOLOGY 1 1 MIGRATION GUIDE Jouueld 9 Migrating from Planner to Concert Technologv In ILOG Planner 3 3 the functionalities of 11cLinopt fall roughly into two categories those that can be used in edit mode only and correspond to CPLEX basic functionalities those that can be used in search mode only and program the search and perform linear relaxation with or without constraint propagation In Concert Technology these categories are reflected by two classes for category 1 the class 110Cp1ex handles all previous 11cLinopt functionalities for category 2 there is now the class IloLinConstraint This chapter contains two sections the first one describing the changes devoted to category 1 use the second describing the changes devoted to category 2 use ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 77 TRANSLATING A PLANNER APPLICATION IN EDIT MODE Translating a Planner Application in Edit Mode With Planner 3 3 an application in edit mode uses only CPLEX features and not Solver search With Concert Technology an application in edit mode requires the installation of Concert 1 1 and CPLEX 7 1 Solver is no longer needed for
44. e IloDispatcher 66 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE Migrating from Configurator to s Concert Technology To translate the code of a Configurator 1 0 application into Configurator 2 1 code you need to do the following Replace the IlcConfigurator objects with an IloCatalog an IloConfiguration and an IloConfigurator object Declare type hierarchies type tables ports attributes and constraints to the catalog Build the catalog instead of linking the configurator Create the initial components in the IloConfiguration object 9 46 Declare the requirement constraints to the IloConfiguration object instead of adding them to the IlcManager Extract the IloConfiguration model and solve it with an IloSolver algorithm Replace the IlcConfigStrategy declarations with an instance of IloConfigStrategy to which the corresponding generic goals and their attached component types are declared Replace the 11c selectors with the corresponding 110 selectors Replace the interchangeability classes with substitutability classes and pass them as arguments of the goals instead of directly attaching them to component types Add the minimization object to the IloConfiguration object instead of adding it to the IlcManager with setObjMin 2 o gt e c bad E c ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 67 The following table gives the correspondence b
45. e over this list and store accepted constraints in a second model named store to be used later IloEnv env IloModel model env create variables and basic objects ListOfConstraints myList ListOfConstraintIterator iter myList IloModel store env IloSolver solver model while iter ok IloConstraint c iter if solver propagate c IloSynchronizeAndContinue store add c iter At this point store contains a list of constraints that do not fail upon simple propagation of the constraints We can use a second solver to find a feasible solution IloSolver solver2 store if solver2 solve solver2 out lt lt Found one optimal solution lt lt endl else solver2 out lt lt No Solutions lt lt endl env end ILOG CONCERT TECHNOLOGV 1 1 MIGRATION GUIDE TRANSLATING SEARCH CODE Multi Phase Search with Restart Here we illustrate how a first search will help restrict the problem before launching a full search We assume we have an objective variable obj and a model model Solver 4 4 code IlcManager m IlcEdit load problem m add myIlcGoall m nextSolution IlcInt objValue obj getValue restart add obj objValue setObjMin obj remove myIlcGoall add myIl1cGoal2 33333 J9AJOS Z while m nextSolution result IlcTrue m restart m nextSolution m out Found an optimal solution
46. el are not made to the Solver objects rather changes are made to the model objects The instance of IloSolver that has extracted the model is then informed of these changes New Data Types We see that there are now two objects attached to each notion that was present in Solver 4 4 For instance there is an I1oIntVar and an I1cIntVar IloIntVar is the model object IlcIntVar is the Solver object Both represent an integer variable 16 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE How TO TRANSLATE A PROGRAM FROM SOLVER 4 4 TO SOLVER 56 1 The Life Cycle of an Algorithm The life cycle of the IloSolver class is slightly different from the life cycle of the IlcManager class In fact 11 cManager has been split into two classes IloEnv to create model objects IloSolver to solve a model Thus in a simple case we create an instance of 11oEnv and state the problem with it Then we create an IloSolver extract the model and solve it This process is illustrated in the section Wrapping Existing Solver Code on page 18 How to Translate a Program from Solver 4 4 to Solver 5 1 J9AJOS Z This section of the guide outlines the major steps in migrating from ILOG Solver 4 4 to ILOG Solver 5 1 with ILOG Concert Technology 1 1 The following sections provide examples that follow the steps of this outline in greater detail 1 Create the environment an instance of 11o0Env documented in the ILOG Concert Technology
47. ember functions for obtaining statistics Jouueld 9 Planner 3 3 Concert 1 1 and CPLEX 7 1 lcInt IlcLinOpt getNbOfConstraints const loInt IloLinConstraint getNrows const lcInt IlcLinOpt getNbOfVars const loInt IloLinConstraint getNcols const lcInt IlcLinOpt getNbOfNonZeros const loInt IloLinConstraint getNnz const lcInt IlcLinOpt getNbOfIterations const loInt IloLinConstraint getNiterations const lcInt IlcLinOpt getMemoryUsed const loInt IloLinConstraint getMemoryUsage const ILOG CoNcERT TECHNOLOGY 1 1 Optimization Algorithms In Planner 3 3 the member function for setting the root node algorithm is void IlcLinOpt setFirstMethod IlcOptMethod method IlcInt level 1 const where method is one of the enumerated values enum IlcOptMethod IlcPrimal IlcDual IlcNetworkPrimal IlcNetworkDual IlcBarrierPrimal IlcBarrierDual y In Concert 1 1 and Solver 5 1 it is void IloLinConstraint setRootAlgorithm IloCplex Algorithm algo IloInt level 1 where algo is one of the enumerated values enum IloCplex Algorithm IloCplex Primal IloCplex Dual IloCplex Barrier IloCplex NetworkPrimal IloCplex NetworkDual IloCplex DualBarrier MIGRATION GUIDE 91 TRANSLATING A PLANNER APPLICATION IN SEARCH The correspondence between new and old names is the following
48. enRange const IlcDemon demon IlcIntExp whenDomain const IlcDemon demon IlcFloatExp whenValue const IlcDemon demon IlcFloatExp whenRange const IlcDemon demon IlcIntSetVar whenDomain const IlcDemon demon J9AJOS Z IlcIntSetVar whenValue const IlcDemon demon Except for co routining these functions should be used instead of the equivalent ones that take an instance of 11cGoal as a parameter ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 31 SEPARATION OF GOALS FROM DEMONS AND CONSTRAINTS For instance consider the following Solver 4 4 code class IlcLessThanCtI public IlcConstraintI x y IlcIntVar x IlcIntVar y public IlcLessThancCtI IlcIntVar x IlcIntVar y IlcConstraintI x getManager _x x _y y IlcBool isViolated const IlcConstraintI makeOpposite const void post void propagate void metaPost IlcGoalI void xPropag void yPropag lcBool IlcLessThanCtI isViolated const return x getMin y getMax lcConstraintI IlcLessThanCtI makeOpposite const return new getManager IlcGreaterThanOrEqualToCt getManager x y LCDEMON2 xDemon IlcIntVar x IlcIntVar y y setMin x getMin 1 LCDEMON2 yDemon IlcIntVar x IlcIntVar y x setMax y getMax 1 void IlcLessThanCtI post x whenRange xDemon x y y whenRange yDemon x y void IlcLessThanCtI propagate y setMin x getMin 41 x setMax y
49. end cost solution makeClone env cost endl rsol amp amp 58 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING CODE FOR ILCROUTINGPLAN Dispatcher 2 1 Dispatcher 3 1 rplan tabu IloDispatcherTabuSearch void ImproveWithTabu IloDispatcher dispatcher IloRoutingSolution solution IloNHood nhood nhood reset IloNumVar cost dispatcher getCostVar IloEnv env dispatcher getEnv IloGoal instantiateCost IloDichotomize env cost IloFalse IloRoutingSolution rsol solution makeClone env IloRoutingSolution best solution makeClone env IloDispatcherTabuSearch dts env 12 IloGoal move IloSingleMove env rsol nhood dts IloMinimizeVar env cost instantiateCost move move amp amp IloStoreBestSolution env best IloSolver solver dispatcher getSolver cout lt lt Tenure 12 lt lt endl for IloInt i 0 i lt 150 i if i 70 cout lt lt Tenure 20 lt lt endl dts setTenure 20 if i 85 cout Tenure 5 endl dts setTenure 5 if i 105 dts setTenure 12 cout lt lt Tenure 12 lt lt endl p if solver solve move iw cout lt lt Cost lt lt solver getMax cost lt lt endl else o if dts complete break z ek IloGoal restoreSolution IloRestoreSolution env best amp amp instantiateCost solver sol
50. eplaced by model add IloMinimize concert linear expression where concert linear expression is the conversion of expression exp to a Concert expression Optimizing To optimize a problem 11cLinopt identifies the various LP solvers and the MIP solver by means of the following functions lcSolutionStatus Il lcSolutionStatus Il lcSolutionStatus Il lcSolutionStatus Il lcSolutionStatus Il lcSolutionStatus Il lcSolutionStatus Il lcSolutionStatus Il lcSolutionStatus Il lcSolutionStatus Il LinOpt primalOpt const LinOpt dualOpt const LinOpt networkPrimalOpt const LinOpt networkDualOpt const LinOpt networkPrimalOpt IlcInt level const LinOpt networkDualOpt IlcInt level const LinOpt barrierOpt const LinOpt barrierPrimalOpt const LinOpt barrierDualOpt const LinOpt mipOpt const QAO OGIO OFA Oa In r1oCplex a call to the member function IloBool IloCplex solve const solves the problem by taking into account its type That is if the problem is an LP one the default LP solver is used If it is a MIP problem the MIP solver is used The optimization status can be obtained with the member function IloAlgorithm Status IloCplex getStatus ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 79 TRANSLATING A PLANNER APPLICATION IN EDIT MODE To force an LP optimization of a MIP problem the user must specify the LP solver with the function
51. ergy relaxation or a list of breaks In Scheduler 4 4 the list of breaks was a specific object that you filled and attached to a resource like this IlcManager m IlcNoEdit IlcInt horizon 365 IlcSchedule schedule m 0 horizon IlcBreakList blist schedule IlcInt i 7 while i lt horizon blist addBreak i 2 i i 147 IlcUnarvResource resource schedule resource setBreaks blist ILOG CONCERT TECHNOLOGV 1 1 MIGRATION GUIDE A TRANSLATION In Scheduler 5 1 a generic class the IloIntervalList allows you to declare a list of time intervals that can be assigned as a list of breaks on resources For example the list of breaks can be shared by default thanks to the schedule environment properties IloIntervalList breakParam schedEnv getBreakListParam IloInt i 7 while i horizon breakParam addInterval i 2 i i i47 You can directly declare the breaks on a resource by using the addBreak member function void IloResource addBreak IloNum start IloNum end IloNum type 0L Moreover as for any parameter you can build a list of breaks and put it on a resource like this IloIntervalList breakParam IloIntervalList env 0 horizon IloInt i 7 while i horizon breakParam addInterval i 2 i i 147 resource setBreaksParam breakParam Notice that by default the instance of IloIntervalList extracted by a resolution algorithm is closed As for a resource
52. espan IlcSchedule schedule DefineProblem m makespan m setObjMin makespan Now in ILOG Scheduler 5 1 we will create an environment an instance of IloEnv documented in the LOG Concert Technology Reference Manual Within the environment we create a model an instance of I1oMode1 documented in the ILOG Concert Technology Reference Manual We create a makespan as a numeric variable an instance of IloNumVar documented in the ILOG Concert Technology Reference Manual Then we add our makespan as an objective to the model like this IloEnv env IloNumVar makespan IloModel model DefineModel env makespan model add IloMinimize env makespan In other words the objective is now part of the model not part of the manager as it used to be When we create an algorithm an instance of IloSolver for example documented in the ILOG Solver Reference Manual it will extract the objective from the model for use in its search 40 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE A TRANSLATION Extracting and Solving In some problems an instance of IloSolver will be able to extract the model and solve with no other intervention See the ILOG Concert Technology User s Manual for examples In other problems you will need a goal to guide the search for a solution There are predefined goals subclasses of the class 110Goa1 suitable for use off the shelf in a model These predefined goals are availa
53. etIntVar var Return the IlcGoal goal IlcInstantiate solver svar else chart msg char The variable given to IloInstantiate should be typed integer throw IloSolver VariableShouldBeInteger msg return goal Write the function that builds the instance of IloGoal IloGoal IloInstantiate const IloEnv env const IloNumVar v return new env IloIntInstantiateIl env getImpl v getimpl ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING SEARCH CODE Translating Search Code In this section we illustrate how simple search techniques are re implemented using the model algorithm paradigm introduced in Solver 5 1 with Concert Technology Basic Search Techniques We suppose we have a common program that creates an instance of the class IloEnv creates with it an instance of the class IloModel named model and fills it with variables and constraints We can now write small code samples that implement basic search techniques To Find One solution N Create a solver with the model and ask it to solve the problem Here we ask for the first o solution 2 Solver 4 4 code IlcManager m IlcEdit load problem m add myIlcGoal if m nextSolution solver out Found one solution endl else solver out No Solutions endl Solver 5 1 code loEnv env loModel model env load problem loSolver solver model if solver solve myIloGo
54. etween the Configurator 1 0 API and the new Configurator 2 1 API Configurator 1 0 API Configurator 2 1 API lcAllConnect Obsolete lcCard component type Obsolete lcCardIterator lcCardPortIterator lcCardSelect selectCard IlcPort p loCardSelect select IloConfigurator cfg IloPort p lcCardSelectI selectCard IlcPort p loCardSelectI select IloConfigurator cfg IloPort p lcCloseType loClose lcCompatibility loCompatibility IlcCompatible IloCompatible IlcIncompatible IloIncompatible lcCompatibilityIterator loCompatibilityIterator lcComponent loComponent configure IloGoal IloConfigure IloComponent IloConfigStrategy getConfigurator obsolete getBaseTvpe getBaseTvpe getintAttr const chart name getNumAttr const chart name getManager obsolete getName getName getPort const char name getPort const char name getType getType getTypeVar getTypeAttr hasProperty const chart name hasAttribute const char name isConfigured obsolete isWildCard isWildCard IlcComponentI IloComponentI 68 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE Configurator 1 0 API Configurator 2 1 API IlcComponentType add IlcConstraint ct addCardPort IlcPropertyRole role lcComponentType aType const char name addCardPort IlcPropertyRole role lcComponentType aType const char name lcInt ca
55. for 11c expressions created during search we also have IloNum IloLinConstraint getValue const IlcIntExp e const IloNum IloLinConstraint getValue const IlcFloatExp e const Similarly the member functions IlcFloat IlcLinearSolver getReducedCost IlcFloatVar var const IlcFloat IlcLinearSolver getReducedCost IlcIntVar var const can be converted using one of these member functions IloNum IloLinConstraint getReducedCost const IlcIntVar x const IloNum IloLinConstraint getReducedCost const IlcFloatVar x const IloNum IloLinConstraint getReducedCost const IloNumVar x const Also the member function lcFloat IlcLinOpt getDualValue IlcConstraint c const n translated using the member functions loNum IloLinConstraint getDual const IlcConstraint ct loNum IloLinConstraint getDual const IloRange range Similarly the member function lcFloat IlcLinOpt getSlackValue IlcConstraint c const n translated using the member functions loNum IloLinConstraint getSlack const IlcConstraint ct loNum IloLinConstraint getSlack const IloRange range To get the objective value the member function lcFloat IlcLinOpt getObjValue const translated to n loNum IloLinConstraint getObjValue const ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING A PLANNER APPLICATION IN SEARCH The following table gives the mappings between new and previous m
56. getMax cost lt lt endl else cout lt lt lt lt endl if meta complete break IloDecouple nhood meta IloGoal restoreSolution IloRestoreSolution env best amp amp instantiateCost solver solve restoreSolution rsol end best end 56 ILOG CONCERT TECHNOLOGV 1 1 MIGRATION GUIDE TRANSLATING CODE FOR ILCROUTINGPLAN Dispatcher 2 1 Dispatcher 3 1 improve IloSingleMove With IloFirstSolution selector void FirstAccept IloDispatcher dispatcher IloRoutingSolution solution IloNHood nhood nhood reset IloNumVar cost dispatcher getCostVar IloEnv env dispatcher getEnv IloGoal instantiateCost IloDichotomize env cost IloFalse IloRoutingSolution rsol solution makeClone env IloGoal move IloSingleMove env rsol nhood IloImprove env instantiateCost IloSolver solver dispatcher getSolver while solver solve move cout lt lt Cost lt lt solver getMax cost lt lt endl IloGoal restoreSolution IloRestoreSolution env rsol amp amp instantiateCost solver solve restoreSolution rsol end rplan insertVisits IloInsertVisit for all visits rplan printInformation dispatcher printInformation rplan refresh IloDistance refresh rplan removeGoal Not applicable rplan restoreSolution No internal solution Not applicable rplan restoreSolution sol
57. her 2 1 to ILOG Dispatcher 3 1 ILOG Configurator 1 0 to ILOG Configurator 2 1 ILOG Planner 3 3 to ILOG CPLEX 7 1 ILOG Concert Technology 1 1 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE ix How THIS MANUAL IS ORGANIZED How this Manual is Organized Chapter 1 The Benefits of Migrating to Concert Technology provides a brief overview of ILOG Concert Technology Chapter 2 Migrating from Solver to Concert Technology explains how to translate Solver 4 4 code into Solver 5 1 and Concert code Chapter 3 Migrating from Scheduler to Concert Technology explains how to translate Scheduler 4 4 code into Scheduler 5 1 code that uses Concert Technology Chapter 4 Migrating from Dispatcher to Concert Technology explains how to translate Dispatcher 2 1 code into Dispatcher 3 1 code that uses Concert Technology Chapter 5 Migrating from Configurator to Concert Technology explains how to translate Configurator 1 0 code into Configurator 2 1 code that uses Concert Technology Chapter 6 Migrating from Planner to Concert Technology explains how to translate Planner 3 3 code into Concert Technology that uses ILOG CPLEX 7 1 What you Need to Know We recommend that you first read the ILOG Concert Technology User s Manual as that manual introduces many of the concepts discussed in this Migration Guide Notation and Naming Conventions Throughout this manual the following typographic conventions apply e Samples of code a
58. ity MakeActivity env name duration activity setBreakable IloTrue Notice that the classes IleBreakableActivitv and IlcIntervalActivity have disappeared By default in Scheduler 5 1 an instance of 110Activity or IlcActivity is a non breakable activity The member functions IloActivitv setBreakable and IlcActivity setBreakable allow you to control whether or not an activity is breakable Translating Global Constraints into Scheduling Parameters Activities naturally fall into two groups the breakable and the non breakable ones In Concert Technology we take advantage of this idea in order to save memory in the definition of the model The characteristics of activities are managed by means of shared parameters We start by declaring the repository of the scheduler parameters namely an instance of IloSchedulerEnv like this IloSchedulerEnv schedEnv env We change the default behavior of the parameter dealing with the breakability of the resources like this ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 43 A TRANSLATION EXAMPLE schedEnv getActivityBasicParam setBreakable Then by default all the activities created from now on will be breakable IloActivity Al MakeActivity model Al 4 After declaring the set of breakable activities we will create a parameter for non breakable activities and use it as the default like this IloActivityBasicParam newDefaultParam env schedEnv setActivityBasicPar
59. lVar dim 1 dispatcher getTravelVar visit dim 2 visit getTravelVar dim visit getVehicle dispatcher getVehicle dispatcher getVehicleVar visit getValue 0 60 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING CODE FOR ILCVISIT Dispatcher 2 1 Dispatcher 3 1 visit getVehicleVar 1 dispatcher getVehicleVar visit 2 visit getVehicleVar visit getWaitVar 1 dispatcher getWaitVar visit 2 visit getWaitVar visit insert solver solve IloInsertVisit env visit visit insert vehicle solver solve IloInsertVisit env visit vehicle visitl insert visit2 solver solve IlolInsertVisit env visitl visit2 isDisabled Not applicable visitl isJustAfter visit2 visitl getPrevVar visit2 visitl isJustBefore visit2 visitl getNextVar visit2 visit makeIncompatibleWith vehicle visit getVehicleVar l vehicle visitl makeIncompatibleWith visit2 visitl getVehicleVar l visit2 getVehicleVar visitl sameVehicle visit2 visitl getVehicleVar visit2 getVehicleVar visit setDelay dim value model add visit getDelayVar dim value visit setDelav dim2 dim value model add visit getDelayVar dim2 value IloAbs visit getTransitVar dim visit setDelayVar dim exp model add visit getDelayVar dim exp visitl setNext visit2 dispatcher setNext visitl visit2 visitl se
60. loMakePerformed and IloMakeUnperformed for unperformed visits 2 Lo IlcThreeOpt Removed 9 S IlcTwoOpt IloTwoOpt ILOG CONCERT TECHNOLOGV 1 1 MIGRATION GUIDE 65 TRANSLATING CODE FOR BREAKS Translating Code for Breaks In the right hand column of the table case 1 returns an I1c instance case 2 returns an Ilo instance Dispatcher 2 1 Dispatcher 3 1 IlcVehicleBreakConstraint IloVehicleBreakCon break getDurationVar 1 dispatcher getDurationVar break 2 break getDurationVar break getPosition dispatcher getPosition break break getPositionVar 1 dispatcher getPositionVar break 2 To constrain the position of break you can use break justAfter break getStartVar break getStartVar 1 dispatcher getStartVar break 2 break getStartVar break isPerformed dispatcher isPerformed break break isUnperformed dispatcher isUnperformed break IlcVehicleBreakConstraintIterator IloIterator IloVehicleBreakCon Miscellaneous Translations Dispatcher 2 1 Dispatcher 3 1 IlcNode IloNode IlcNodeIterator TloIterator lt IloNode gt IlcOutputManip IloOutputManip IlcRPHook Removed ILCSETWINDOW visit getCumulVar dim begin lt var amp amp var lt end model add begin lt visit getCumulVar dim lt end IlcTerse IlcRoutingPlan IloTerse IloDispatcher IlcVerbosei IlcRoutingPlan IloVerbos
61. loor IloNum a const lcFloat IlcLinearSolver ceil IlcFloat x const loNum IloLinConstraint ceil IloNum a const ILOG CoNcERT TECHNOLOGY 1 1 MIGRATION GUIDE 93 TRANSLATING A PLANNER APPLICATION IN SEARCH MODE 94 The member functions for print information on a stream void IlcLinearSolver printInformation const void IlcLinearSolver printInformation ostream amp str const are translated to void IloLinConstraint printInformation ostream amp stream const void IloLinConstraint printInformation const Variable Selection The selection functions over an array of integer variables that were defined by the macro IlcChooseMixedIndexi name criterion type can be defined by the more general macro ILOSELECTVARn For example the macro IlcChooseMixedIndexi MostNotInteger linsolver distToInt val IlcIntVar defines the function MostNotInteger IlcIntVarArray x IloLinOpt lo This function selects the variable that has the least integer value The same function can be defined with the macro ILOSELECTVARn ILOSELECTVAR2 MostNotInteger IloNumVar x IloLinConstraint lc IloNum dist lc distToInt lc getValue x return dist lc getFeasTolerance dist IlcInfinity ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE Concert Technologv benefits 14 definition 13 migrating from Configurator 67 migrating from Dispatcher 49 migrating
62. migration from ILOG Scheduler 4 4 to ILOG Scheduler 5 1 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 37 How TRANSLATE A PROGRAM FROM SCHEDULER 4 4 TO SCHEDULER 5 1 How to Translate a Program from Scheduler 4 4 to Scheduler 5 1 This section of the guide outlines the major steps in migrating from ILOG Scheduler 4 4 to ILOG Scheduler 5 1 with ILOG Concert Technology 1 1 The following section walks you through an application following the steps of this outline in greater detail 1 Create the environment an instance of IloEnv documented in the ILOG Concert Technology Reference Manual Create the model an instance of 11oMode1 also documented in the ILOG Concert Technology Reference Manual Translate problem data into appropriate ILOG Concert Technology types For example values of IlcFloat become IloNun values of I1cInt become IloInt or 11oNum and so forth Likewise arrays of 11cFloatArray become arrays of 11oNumArray Translate the constrained elements variables activities resources from your old application to the corresponding elements in ILOG Concert Technology or ILOG Scheduler 5 1 For example IlcActivity becomes IloActivity documented in the ILOG Scheduler Reference Manual Wrap the old Solver 4 4 constraints instances of IlcConstraint or its subclasses according to the steps outlined in Chapter 2 Migrating from Solver to Concert Technology of this Migration Guide Wrap the old Scheduler 4 4
63. nction void IlcLinOpt useExceptions IlcBool uselt has no equivalent in IloLinConstraint since exceptions are always used in Concert 1 1 and Solver 5 1 The exceptions thrown from the Planner 3 3 class IlcLinOptException are now replaced by IloException IlcTrue const Jeuueld 9 Goals The member function lcGoal loGoal lcGoal IlcLinOpt getPiecewise IloGoalPiecewiseLinear that creates a Concert goal and by IloGoalPiecewiseLinear is now replaced by the member function LinearGenerateGoal loEnv env loSolver const IloLinConstraint 1c IloLinConstraint 10 that creates a Solver goal for enumerating on segments of a piecewise linear expression which has been extracted from the model Miscellaneous Functions The following rounding functions from Planner 3 3 have a direct translation in Concert 1 1 and Solver 5 1 Planner 3 3 Concert 1 1 and CPLEX 7 1 lcInt IlcLinearSolver nearest IlcFloat x const loNum IloLinConstraint nearest IloNum a const lcInt IlcLinearSolver trunc IlcFloat x const loNum IloLinConstraint trunc IloNum a const lcFloat IlcLinearSolver frac IlcFloat x const loNum IloLinConstraint frac IloNum a const lcFloat IlcLinearSolver distToInt IlcFloat x const loNum IloLinConstraint distToInt IloNum a const lcFloat IlcLinearSolver floor IlcFloat x const IloNum IloLinConstraint f
64. nd its goal The solve function will automatically extract the model and solve it with the goal given as argument 11 Translate the search code from your old application according to the steps outlined in Chapter 2 Migrating from Solver to Concert Technology of this Migration Guide ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 39 A TRANSLATION EXAMPLE A Translation Example With that outline of steps in mind we will show now how to applv some of those steps We will use the bridgebr cpp example from the standard distribution of ILOG Scheduler 4 4 and 5 1 This example is based on the well known bridge building problem extended bv the fact that the resources have breaks Some activities in this example are breakable others are not With this example we will demonstrate scheduling parameters in ILOG Scheduler 5 1 showing vou how to translate global constraints in vour Scheduler 4 4 application into the scheduling parameters of ILOG Scheduler 5 1 Rationale Roughly our aim is to separate the problem data from the model expressed in classes of ILOG Concert Technology and to separate the model from the search expressed in classes of ILOG Solver Creating the Model In previous versions of ILOG Scheduler an application created a manager in edit mode declared a makespan variable and added the makespan as an objective to the manager like this IlcManager m IlcEdit m openLogFile bridgebr log IlcIntVar mak
65. nslate each member function of the Dispatcher 2 1 classes into Dispatcher 3 1 In the examples of code given dispatcher represents an instance of visit represents an instance of rplan represents an instance of vehicle represents an instance of solver represents an instance of solution represents an instance of model represents an instance of Il Il LL Il Il EL Il Il oDispatcher cVisit in Dispatcher 2 1 oVisit in Dispatcher 3 1 cRoutingPlan cVehicle in Dispatcher 2 1 oVehicle in Dispatcher 3 1 oSolver oRoutingSolution oModel The class 11oSolver is from ILOG Solver 5 1 The classes IloSolution and IloModel are from ILOG Concert Technology 1 1 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING CODE FOR ILCROUTINGPLAN Translating Code for llcRoutingPlan An instance of IlcRoutingPlan passed to a function translates to an instance of the class IloEnv Dispatcher 2 1 Dispatcher 3 1 IlcRoutingPlan IloModel IloDispatcher IloRoutingSolution addGoal Some of the predefined goals take a subgoal otherwise you can add the subgoal by combining the other goals of the search with an rplan fastGLS IloDispatcherGLS with IloFirstSolution selector void ImproveWithFastGLS IloDispatcher dispatcher TloRoutingSolution solution IloNHood nhood nhood reset IloNumVar cost dispatcher getCostVar IloEnv env dispatcher getEnv IloGoal instantiateCo
66. oAttrRole role loComponentType aType const char name loInt cardValue loAttrMode mode IloComputed addPort IloAttrRole role loComponentType aType const char name loInt cardMin Ilolnt cardMax loAttrMode mode IloComputed IloConfiguration close IloComponentType IloConfigurator close IloComponentType ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 69 o E e c 9 Configurator 1 0 API Configurator 2 1 API configure configure IlcInstanceSelect selector getConfigurator getDepth getInstance const chart name getIntAttr const char name getInterchangeability getLabel getName getNumberOfInstances getPort const chart name getStrategy getTypeVar hasProperty const char name isClosed isLeaf isRoot isSubTvpeOf IlcComponentTvpe aType isSuperTvpeOf IlcComponentTvpe aTvpe IloGoal IloConfigueAll IloComponentType t loConfigurator cfg loConfigStrategy st IloGoal IloConfigueAll IloComponentType t loConfigurator cfg loConfigStrategy st loInstanceSelect sel Obsolete getDepth IloConfiguration getInstance IloComponentType t const char name IloConfigurator getInstance const char name IloComponentType t getNumAttr const char name Obsolete Obsolete Obsolete IloConfiguration getNumberOfInstances IloComponentType t IloConfigurator
67. olution generation goals The following code demonstrates this IloSolver solver mdl IloDispatcher dispatcher solver IloRoutingSolution solution mdl IloGoal instantiateCost IloDichotomize env dispatcher getCostVar IloFalse IloGoal goal IloSavingsGenerate env amp amp instantiateCost if solver solve goal solver out lt lt Not enough vehicles to generate first solution lt lt endl return 0 solution store solver ILOG Dispatcher 3 1 now uses a new generic open local search API which is available in Solver 5 1 The 11cMove class of ILOG Dispatcher 2 1 now corresponds to the IloNHood class found in ILOG Solver 5 1 Also the member functions of the class I1cRoutingPlan dealing with local search improve gls gts fastGls are now replaced by the new search strategies based on the framework offered by ILOG Solver The following code exemplifies this IloGoal restoreSolution IloRestoreSolution env solution IloNHood nhood IloTwoOpt env IloOrOpt env IloRelocate env IloExchange env IloCross env IloGoal improve IloSingleMove env solution nhood IloImprove env IloFirstSolution env instantiateCost while solver solve improve solver solve restoreSolution ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 51 gt 2 2 O 2 D CORRESPONDENCE TABLES Correspondence Tables 52 The following tables explain how to tra
68. olver solver model IloBool result IloFalse Solver startNewSearch myIloGoal while solver next env out lt lt Objective value lt lt solver getValue obj lt lt endl result IloTrue if result solver restartSearch solver next solver out Found an optimal solution endl else solver out lt lt No Solutions lt lt endl J9AJOS Z Solver endSearch To Iterate Over Solutions We can also use I1oSolver startNewSearch and IloSolver next to replace code that contains the call to IlcManager nextSolution Solver 4 4 code IlcManager m IlcEdit load problem m add myIlcGoal while m nextSolution solver out Found one solution endl Solver 5 1 code Given an I1oGoal named myilogoal that wraps the 11cGoa1 used in the program we can write IloEnv env IloModel model env load problem IloSolver solver model startNewSearch solver newSearch myIloGoal while solver next solver out lt lt Found one solution lt lt endl ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 25 TRANSLATING SEARCH CODE 26 solve endSearch Testing a List of Constraints Here is a search technique that is useful in an over constrained problem In this case you have a list of constraints and you want to find a sublist where simple propagation does not fail The following code sample will iterat
69. ou read the ILOG Concert Technology User s Manual as it introduces many of the concepts discussed in this chapter ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 15 A BRIEF INTRODUCTION CONCERT TECHNOLOGV A Brief Introduction to Concert Technologv This section outlines the following major features in Solver 5 1 and Concert Technologv clean separation of model and algorithm new data types change in the life cycle of an algorithm It also summarizes the steps involved in migrating from ILOG Solver 4 4 to ILOG Solver 5 1 with ILOG Concert Technology 1 1 Clear Distinction Between Model and Algorithm In Solver 4 4 the model stating the problem to solve and the algorithm solving the problem were part of the same structure The objects variables constraints goals were common to both Concert Technology introduces a model which is separate from the Solver algorithm that will solve it This model is filled with objects whose names are prefixed with 110 The model is then extracted by the Solver algorithm which translates it into Solver objects that are solved by the Solver algorithm The class 110Solver in Solver 5 1 is derived from the Concert class IloAlgorithm Solver objects are prefixed with Ilc This new structure has two consequences The algorithm has a simple solving API but not a model stating one For instance Solver will not be used to create a variable in the modeling layer Changes to the mod
70. r to Concert Technology before reading the present chapter Modeling is Based on Concert Technology ILOG Dispatcher 3 1 uses ILOG Concert Technology This means that the statement of a problem is clearly separated from the way it is solved For this purpose Concert Technology provides the concept of the model through the class 110Mode1 The problem is then defined by adding modeling objects prefixed by 110 to an 11oModel Mn o 1 2 o mi When the problem is to be solved the information from the model is extracted by an algorithm In Dispatcher terms this translates into the following the functionality provided by the IlcRoutingPlan class in version 2 1 is now provided by three 110 prefixed classes e 11oModel IloDispatcher TIloRoutingSolution ILOG CONCERT TECHNOLOGV 1 1 MIGRATION GUIDE 49 MODELING IS BASED ON CONCERT TECHNOLOGV This means that The description of the model is handled by the class 11oModel as with all the other optimization libraries in the ILOG Optimization Suite which are now Concert enabled The solving of the problem and the constraints related to it are algorithmically managed by the class 110Dispatcher The storage and manipulation of a solution to a routing problem are handled by the class IloRoutingSolution There is no equivalent to an internal solution in IlcRoutingPlan now 50 an IloRoutingSolution has to be created before solving any problem Note
71. ram const char IlcLinOpt getParamDefault IlcStringParam char buffer const lcInt IlcLinOpt getParamMin IlcIntParam const lcFloat IlcLinOpt getParamMin IlcFloatParam const lcInt IlcLinOpt getParamMax IlcIntParam const lcFloat IlcLinOpt getParamMax IlcFloatParam const are now called loBool loCplex getDefault BoolParam parameter const loInt loCplex getDefault IntParam parameter const loNum loCplex getDefault NumParam parameter const const char IloCplex getDefault StringParam parameter const loInt loCplex getMin IntParam parameter const loNum loCplex getMin NumParam parameter const loInt loCplex getMax IntParam parameter const loNum loCplex getMax NumParam parameter const MIGRATION GUIDE 83 TRANSLATING A PLANNER APPLICATION IN EDIT MODE Basis Handling In Planner 3 3 a basis is a mapping between variables and constraints in the IlcLinOpt object on one hand and a status on the other hand In Concert 1 1 and CPLEX 7 1 a basis is represented by two arrays of status values in instances of IloCplex BasisStatusArray one for the variables and one for the constraints To get or to fill a basis from an instance of I1cLinOpt these member functions are called IlcBasis IlcLinOpt getBasis const void IlcLinOpt fillBasis IlcBasis const To get a basis from an instance of 11oCplex create two arrays of basis status values cstat for the variables and rstats for the ranges and fill them b
72. rdValue addCardPort IlcPropertyRole role lcComponentType aType const char name lcInt cardMin IlcInt cardMax addIntAttr const char name lcInt min IlcInt max addIntAttr const char name lcIntArray values addPort IlcPropertyRole role lcComponentType aType const char name addPort IlcPropertyRole role lcComponentType aType const char name lcInt cardValue addPort IlcPropertyRole role lcComponentType aType const char name lcInt cardMin IlcInt cardMax close lcPropertyMode mode IlcComputed lcPropertyMode mode IlcComputed lcPropertyMode mode IlcComputed lcPropertyMode mode IlcComputed lcPropertyMode mode IlcComputed lcPropertyMode mode IlcComputed lcPropertyMode mode IlcComputed lcPropertyMode mode IlcComputed IloComponentType add IloConstraint ct addCardPort IloAttrRole role loComponentTvpe aTvpe const chart name loAttrMode mode IloComputed addCardPort IloAttrRole role loComponentTvpe aType const char name loInt cardValue loAttrMode mode IloComputed addCardPort IloAttrRole role loComponentTvpe aType const char name loInt cardMin IloInt cardMax loAttrMode mode IloComputed addIntAttr const chart name loInt min IloInt max addIntAttr const chart name IloNumArrav values addPort IloAttrRole role loComponentType aType const char name loAttrMode mode IloComputed addPort Il
73. re written in this tvpeface e Important ideas are emphasized like this Throughout this manual the following naming conventions apply The names of types classes and functions defined in the Concert Technology library begin with Ilo X ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE RELATED DOCUMENTATION Related Documentation ILOG Concert Technology User s Manual explains how to use Concert Technology by walking through examples ILOG Concert Technology Reference Manual documents C classes for representing models as well as the base classes for implementing algorithms Each of the products mentioned in this guide ILOG Solver Scheduler Dispatcher Configurator and CPLEX is accompanied by its own reference and user s manuals ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE xi RELATED DOCUMENTATION xii ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE siijoueg The Benefits of Migrating to Concert Technologv ILOG Concert Technology provides a set of lightweight C objects for representing optimization problems It is included as part of ILOG Solver and ILOG CPLEX ILOG Scheduler ILOG Dispatcher and ILOG Configurator as extensions of ILOG Solver are also based on Concert Technology Optimization models are separated from the algorithms that are used to find solutions This allows problems to be decomposed into subproblems so that different algorithms can be applied to separate parts of a large s
74. rentI This member function returns the constraint itself if the constraint has been added at the top level or in a goal Otherwise it references the demon constraint that has added the constraint Obsolete Functions and Classes A list of obsolete functions and classes with their replacements is given in the ILOG Solver 5 1 Reference Manual J9AJOS Z ILOG CONCERT TECHNOLOGV 1 1 MIGRATION GUIDE 35 OBSOLETE FUNCTIONS AND CLASSES 36 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE Migrating from Scheduler to Concert Technologv ILOG Scheduler 5 1 is designed to work with ILOG Concert Technology to model and to solve scheduling and resource allocation problems The core model in such a problem is based upon a set of activities a set of resources and the set of scheduling constraints involving activities and resources That set of scheduling constraints consists of the temporal constraints and the resource constraints Before you begin translating an existing ILOG Scheduler 4 4 application to ILOG Scheduler 5 1 please study Chapter 2 Migrating from Solver to Concert Technology for details about migrating to Solver 5 1 See also the ILOG Concert Technology 1 1 Reference Manual which contains the C classes for representing models as well as the base classes for implementing algorithms A basic familiarity with ILOG Concert Technology and with the new features of ILOG Solver 5 1 are prerequisites to a successful
75. resource or the transition time function of a resource You have a choice between using parameters on a set of resources or annotating a single resource locally Using Parameters to Close Resources In the previous code sample in Scheduler 4 4 the resource was closed by the function IlcResource close In ILOG Scheduler 5 1 the resource is considered closed by default by the algorithm that extracts the model If you want to declare a resource not closed at resolution time you have two alternatives use the member function I1oResource keepOpen IloTrue use the resource parameter shared by a set of resources For example using the default resource parameter of the Scheduler environment write schedenv getResourceParam keepOpen IloTrue Using Parameters to Invoke Disjunctive Constraint or Edge Finder Another kind of parameter allows you to set the enforcement level on certain characteristics of the resource For example you can invoke the disjunctive constraint and the edge finder constraint in a model like this IloUnaryResource resource resource setCapacityEnforcement IloMediumHigh You can also use the resource parameter like this schedenv getResourceParam setCapacityEnforcement IloMediumHigh Using Parameters on Time Intervals Another kind of parameter defines functions on an interval of time for example such functions as the maximum capacity of a resource the time interval of an en
76. rt in the IlcPort aPort model lcNotConnect IloComponent c IlcPort aPort in the solver lcNotSpecialize IlcTypeVar var loNotSpecialize IloTypeAttr IloComponentType t IlcComponentType t lcNotSpecialize IlcTypeAttr IloComponentType t lcPort loPort in the model lcPort in the solver lcPortDeltalIterator lcConnectionDeltaIterator lcPortIterator loConnectionIterator in the model lcConnectionIterator inthe solver lcPropertyRole loAttrRole IlcHasPart IloHasPart IlcPartOf IloPartOf IlcUses IloUses IlcIntAttribute IloNumAttribute lcSpecialize IlcTypeVar var loSpecialize IloTypeAttr IloComponentType t IlcComponentType t lcSpecialize IlcTypeAttr IloComponentType t lcSubTypelterator loSubTypelterator lcSuperTypeIterator loSuperTypeIterator lcTypeCompatiblity IlcTypeVar var loTypeCompatiblity IloTypeAttr var IlcPort aPort IloPort aPort IlcTypeTable aTable IloTypeTable aTable fe lcTypeCompatiblity IlcTypeVar varl loTypeCompatiblity IloTypeAttr varl 3 IlcTypeVar var2 IloTypeAttr var2 Q IlcTypeTable aTable IloTypeTable aTable 2 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 75 Configurator 1 0 API Configurator 2 1 API lcTypelterator loTypelterator lcTypeSelect selectType IlcTypeVar var loTypeSelect select IloConfigurator cfg IloTypeAttr var lcTypeSelectI selectType IlcTypeVar var loTypeSelectI select IloConfigurator cfg IloTypeAttr var lcTypeTabl
77. rtual IloExtractableI makeClone IloEnvI const virtual void display ostream out const IlcConstraint extract const IloSolver amp const y ILOCPCONSTRAINTWRAPPERIMPL IloFreqConstraintI IloFreqConstraintI IloFreqConstraintI IloEnvI env const IloNumVarArray amp T vars const char name IloCPConstraintI env name vars IloNumVarArray amp T vars IloExtractableI IloFreqConstraintI makeClone IloEnvI env const IloNumVarArray targl IloGetClone env vars return new env IloFregConstraintl env const IloNumVarArray amp targl const char 0 void IloFreqConstraintI display ostream amp out const out IloFreqConstraintI if getName out getName else out getId out endl out lt lt lt lt yargi lt lt lt lt vars lt lt endl 20 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE WRAPPING EXISTING SOLVER CODE IloConstraint IloFreqConstraint IloEnv env IloNumVarArray _vars const char name 0 return new env IloFreqConstraintI env getImpl _vars name IlcConstraint IloFreqConstraintI extract const IloSolver amp solver const use solver vars return IlcFreqConstraint solver solver getIntVarArray vars Wrapping User Defined Goals In Solver 5 1 given an instance of the class 110Goa1 the member function IloSolver extract will create an instance of 11cGoa1 for use internally by Solver In that context
78. s loInt IloCplex MIPCallback getNiterations const lcCallbackInfoCliqueCount oInt IloCplex MIPCallback getNcliques const lcCallbackInfoCoverCount oInt IloCplex MIPCallback getNcovers const lcCallbackInfoBestInteger loNum IloCplex MIPCallback getIncumbentObjValue const lcCallbackInfoBestRemaining loNum IloCplex MIPCallback getBestObjValue const lcCallbackInfoCutoff loNum IloCplex MIPCallback getCutoff const Presolve information is available only in the presolve callback defined with the macro ILOPRESOLVECAI BACK The mapping is Planner 3 3 Concert 1 1 and CPLEX 7 1 IlcCallbackInfoPresolveRowsGone IloInt IloCplex PresolveCallback getNremovedRows const IlcCallbackInfoPresolveColsGone IloInt IloCplex PresolveCallback getNremovedCols const IlcCallbackInfoPresolveAggSubst IloInt IloCplex PresolveCallback getNaggregations const IlcCallbackInfoPresolveCoeffs IloInt IloCplex PresolveCallback getNmodifiedCoeffs const ILOG CoNcERT TECHNOLOGY 1 1 MIGRATION GUIDE 87 TRANSLATING A PLANNER APPLICATION IN SEARCH Translating a Planner Application in Search Mode In Planner 3 3 an application in search mode uses CPLEX features and Solver search With Concert Technologv the same application requires the installation of Concert 1 1 CPLEX 7 1 and Solver 5 1 At installation vou must include the header file
79. s now replaced by IloException documented in the ILOG Concert Technology Reference Manual Bound Changes In Planner 3 3 bounds are changed by means of the member functions void IlcLinOpt chgBounds IlcIntVar x IlcInt min IlcInt max const void IlcLinOpt chgBounds IlcFloatVar x IlcFloat min IlcFloat max const void IlcLinOpt chgLowerBound IlcIntVar x IlcInt min const void IlcLinOpt chgLowerBound IlcFloatVar x IlcFloat min const void IlcLinOpt chgUpperBound IlcIntVar x IlcInt max const void IlcLinOpt chgUpperBound IlcFloatVar x IlcFloat max const In Concert and CPLEX bounds are changed directly on the variables of the model by means of the member functions void IloNumVar setLb IloNum 1b const void IloNumVar setUb IloNum ub const Constraint Removal You can remove a constraint from a problem in an instance of 11cLinopt with the member function void IlcLinOpt remove const IlcConstraint amp ct const In Concert and CPLEX this operation is performed directly on the model by the member function void IloModel remove const IloExtractable x const Parameter Handling To change a parameter on an instance of IlcLinopt the following member functions that depend on the parameter type are used void IlcLinOpt setParam IlcBoolParam IlcBool const void IlcLinOpt setParam IlcIntParam IlcInt const void IlcLinOpt setParam IlcFloatParam IlcFloat const void IlcLinOpt setP
80. solete getSolver Obsolete loCatalog getType const char name loCatalog getTypeTable const char name loCatalog isBuilt loCatalog build loCatalog build ostream amp os Obsolete lcConnect IlcComponent c IlcPort aPort loConnect IloComponent c lcConnect IloComponent c IloPort aPort inthe model IlcPort aPort in the solver lcConnectionSelect loConnectionSelect selectComponent IlcPort p select IloConfigurator cfg IloPort p lcConnectionSelectI loConnectionSelectI selectComponent IlcPort p select IloConfigurator cfg IloPort p lcDomainIteration lcDomainIteration lcEvallnstance loEvalComponent lcEvalType loEvalType lcInstanceIterator loInstanceIterator lcInstances Obsolete 74 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE Configurator 1 0 API Configurator 2 1 API IlcInstanceSelect IloInstanceSelect select IlcComponentType aType select IloConfigurator cfg IloInstanceIterator amp it IlcInstanceSelectI IloInstanceSelectI select IlcComponentType aTvpe select IloConfigurator cfg IloInstanceIterator amp it IlcIntAttr loNumAttr in the model lcIntAttr in the solver IlcInterchangeability loSubstituability IlcInterchangeabilityI loSubstituabilityI IlcNotConnect IlcComponent c loNotConnect IloComponent c IloPort aPo
81. st IloDichotomize env cost IloFalse IloRoutingSolution rsol solution makeClone env IloRoutingSolution best solution makeClone env IloDispatcherGLS dgls env 0 2 IloGoal move IloSingleMove env rsol nhood dgls instantiateCost move move amp amp IloStoreBestSolution env best IloSolver solver dispatcher getSolver IloCouple nhood dgls for IloInt i 0 i lt 300 1 if solver solve move cout lt lt Cost lt lt solver getMax cost lt lt endl else cout lt lt lt lt endl if dgls complete break gt z 2 O 2 D IloDecouple nhood dgls IloGoal restoreSolution IloRestoreSolution env best amp amp instantiateCost solver solve restoreSolution rsol end best end ILOG CONCERT TECHNOLOGV 1 1 MIGRATION GUIDE 53 TRANSLATING CODE FOR ILCROUTINGPLAN Dispatcher 2 1 Dispatcher 3 1 rplan getBestiteration To be done directiv bv the user in the local search code rplan getCostPrecision To be done directiv bv the user in the local search code rplan getCostVar dispatcher getCostVar rplan getGoal Not applicable rplan getNbOfDimensions dispatcher getNbOfDimensions rplan getNbOfMoves dispatcher getNbOfMoves rplan getNbOfNodes dispatcher getNbOfNodes rplan getNbOfSuccesses dispat
82. t code The simple Pheasant example is translated from Solver 4 4 to Solver 5 1 User defined constraints are wrapped User defined goals are wrapped Translating the Pheasant Example This section uses the simple Pheasant example to show how Solver 4 4 code is translated into Solver 5 1 code The code of the Pheasant example from Solver 4 4 include lt ilsolver ilcint h gt int main IlcManager m IlcEdit define two constrained variables ranging from 0 to 100 IlcIntVar nbRabbits m 0 100 nbPheasants m 0 100 set up the constraint on the number of heads m add 20 nbRabbits nbPheasants set up the constraint on the number of legs m add 56 4 nbRabbits 2 nbPheasants post and propagate constraints m nextSolution print solution m out Rabbits nbRabbits lt lt endl m out lt lt Pheasants lt lt nbPheasants lt lt endl release the resources of the manager m end return 0 Code Sample 2 1 The Pheasant Example from Solver 4 4 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE WRAPPING EXISTING SOLVER CODE The code of the Pheasant example as it is in Solver 5 1 include lt ilsolver ilosolver h gt int main int argc char argv IloEnv env try IloModel model env define two constrained variables ranging from 0 to 100 IloIntVar nbRabbits env 0 100 IloIntVar nbPheasants env 0 100 set up the constraint
83. tPrev visit2 dispatcher setPrev visitl visit2 visit setQuantity dim value model add visit getTransitVar dim value visit setQuantityVar dim var Not applicable visitl setSavedNext visit2 solution setNext visitl visit2 visitl setSavedPrev visit2 solution setPrev visitl visit2 visit setVehicle vehicle dispatcher setVehicle visit vehicle IlcVisitlterator IloIterator IloVisit IloRoutingSolution VisitIterator IlcUnperformedVisitlterator IloDispatcher UnperformedVisitlterator IloRoutingSolution UnperformedVisitlterator ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 61 z 0 o o 2 O mi TRANSLATING GODE FOR ILCVEHICLE Translating Code for llcVehicle Dispatcher 2 1 Dispatcher 3 1 IlcVehicle IloVehicle vehicle disable solution remove vehicle model remove vehicle enable solution add vehicle model add vehicle generateRoute Not applicable vehicle getIndex dispatcher getIndex veh getNbOfVehicleBreakConstraints Not applicable getRouteCompleteVar Not applicable isDisabled Not applicable isRouteComplete Not applicable IlcVehicleIterator IloIterator IloVehicle IloRoutingSolution VehicleIterator IlcRouteIterator IloDispatcher RouteIterator IloRoutingSolution Routelterator Translating Co
84. ted with a solver when the following member function is called void IloSolver add IlcConstraint ct 88 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING A PLANNER APPLICATION IN SEARCH The postA11 argument determines whether the constraint was added to Solver and Planner postAll IlcTrue orto Planner only postAll IlcFalse With IloLinConstraint constraints are by default added to 110Solver and to IloLinConstraint To force a constraint to be added to I1oLinConstraint only use the member function void IloLinConstraint setSynchronization IloLinConstraint Synchronization s Whens IloLinConstraint LinConstraintOnly constraints are extracted and added to the instance of IloLinConstraint but not to the instance of T10Solver When s LinConstraintAndSolver constraints are added to both instances Jeuueld 9 Setting the Objective Function In ILOG Concert Technology setting and changing the objective function is done in the model So the function equivalent to IlcFloatVar IlcLinearSolver setObjMin IlcFloatExp exp IlcBool postAll IlcFalse const IlcIntVar IlcLinearSolver setObjMin IlcIntExp exp IlcBool postAll IlcFalse const is now replaced by model add IloMinimize concert linear expression gt where concert linear expression is the translation of expression exp as a Concert expression When you set an objective function in Planner 3 3 a constraint is
85. ution solver solve IloRestoreSolution env solution rplan saveSolution No internal solution Not applicable rplan saveSolution solution solution store solver rplan setCostPrecision To be done directly by the user in the local search code rplan setHook To be done directly by the user in the local search code or in a goal rplan setMoveLimit To be done directly by the user in the local search code add code rplan setPenFactor IloDispatcherGLS setPenaltyFactor rplan setTimeLimt Same as setMoveLimit ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 57 gt Q 2 O 2 D TRANSLATING CODE FOR ILCROUTINGPLAN Dispatcher 2 1 Dispatcher 3 1 steepest IloSingleMove with I1oMinimizeVar selector void BestAccept IloDispatcher dispatcher IloRoutingSolution solution IloNHood nhood nhood reset IloNumVar cost dispatcher getCostVar IloEnv env dispatcher getEnv IloGoal instantiateCost IloFalse IloRoutingSolution rsol IloDichotomize env IloGoal move IloSingleMove env rsol nhood IloImprove env IloMinimizeVar env instantiateCost IloSolver solver dispatcher getSolver solver solve move Cost while cout solver getMax cost IloGoal restoreSolution IloRestoreSolution env instantiateCost solver solve restoreSolution rsol
86. ve restoreSolution rsol end best end rplan unsetLimit Not applicable ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 59 TRANSLATING GODE FOR ILCVISIT Translating Code for IleVisit In the right hand column of the table case 1 returns an I1c instance case 2 returns an Ilo instance Dispatcher 2 1 Dispatcher 3 1 IlcVisit IloVisit visit disable solution remove visit model remove visit visit enable solution add visit model add visit visitl getCostTo visit2 vehicle dispatcher getCost visitl visit2 vehicle visit getIndex dispatcher getIndex visit getManager Not applicable visit getNext dispatcher getVisit dispatcher getNextVar visit getValue visit getNextVar 1 dispatcher getNextVar visit 2 visit getNextVar visit getPrev dispatcher getVisit dispatcher getPrevVar visit getValue visit getPrevVar 1 dispatcher getPrevVar visit 2 visit getPrevVar visit getRankVar 1 dispatcher getRankVar visit 2 visit getRankVar visit getQuantity dim dispatcher getTransitVar dim getValue visit getQuantityVar dim 1 dispatcher getTransitVar visit dim 2 visit getTransitVar dim visit getSavedNext solution getNext visit visit getSavedPrev solution getPrev visit visit getTransitVar dim 1 dispatcher getTransitVar visit dim 2 visit getTransitVar dim visit getTrave
87. void IloCplex setRootAlgorithm IloCplex Algorithm alg where a1g can be one of the values in the following enumeration enum IloCplex Algorithm IloCplex Primal IloCplex Dual IloCplex Barrier IloCplex NetworkPrimal IloCplex NetworkDual IloCplex DualBarrier Then the relaxed problem is solved with the function loBool IloCplex solveRelaxed For example the code lcManager m IlcEdit lcLinOpt lo m lcSolutionStatus status lo primalOpt translated into Uu loEnv env loCplex cplex env cplex setRootAlgorithm IloCplex Primal cplex solveRelaxed IloAlgorithm Status status cplex getStatus Getting the Results The Planner 3 3 member functions to obtain the value of an expression lcFloat IlcLinearSolver getCurrentValue IlcFloatExp var const lcFloat IlcLinearSolver getCurrentValue IlcIntExp var const are converted in Concert Technology to loNum IloCplex getValue const IloExpr e const Since the classes I1oExpr and IloNumVar are unrelated we also have loNum IloCplex getValue const IloNumVar x const 80 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING A PLANNER APPLICATION IN EDIT MODE Similarly the memberfunctions are converted to Also the member function m n pas n converted to un lcFloat IlcLinearSolver getReducedCost IlcFloatVar var const lcFloat IlcLinearSolver getReducedCost IlcInt
88. xample in ILOG Scheduler 4 4 you added temporal constraints on activities to the manager like this manager add activitvi startsAfterEnd activity2 In contrast in ILOG Scheduler 5 1 and ILOG Concert Technology there is a clear distinction between the model made up of decision variables and the search for an assignment of values to the decision variables This distinction is highlighted bv the fact that an algorithm an instance of IloSolver for example extracts information from a model 44 ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE A TRANSLATION EXAMPLE for its own use You must add the temporal constraints and time bound constraints of your problem to your model in order for them to be extracted by an algorithm an instance of IloSolver for example and taken into account during the search For example you add a temporal constraint on an activity like this model add activitvi startsAfterEnd activity2 In ILOG Concert Technology when you add a constraint to a model all the variables belonging to that constraint are implicitly added the model for you automatically Then when your algorithm an instance of IloSolver for example extracts the model with that added constraint it will also extract those variables in the constraint Creating Resources The creation of a resource resembles the creation of an activity that is you create the resource in an environment an instance of IloEnv documented in the
89. y means of the member function void IloCplex getStatuses BasisStatusArray cstat const IloNumVarArray var BasisStatusArray rstat const IloRangeArray con const To set a basis for an instance of 11cLinOpt this member function is called void IlcLinOpt setBasis IlcBasis const To set a basis for an instance of IloCplex the two arrays of basis status values cstat for the variables and rstats for the ranges must be given to the following member function void IloCplex setStatuses const BasisStatusArray cstat const IloNumVarArray var const BasisStatusArray rstat const IloRangeArray con Handling Problem Types There is no problem type handling in 11oCplex as there was in IlcLinopt The following member function lets you know whether the problem extracted is a MIP IloBool IloCplex isMIP const You can solve the relaxed problem with the member function IloBool IloCplex solveRelaxed You can solve the problem where all the integer variables are fixed to their current values with the member function IloBool IloCplex solveFixed 84 ILOG CoNcERT TECHNOLOGY 1 1 MIGRATION GUIDE TRANSLATING A PLANNER APPLICATION IN EDIT MODE Output To output a file in a CPLEX format such as 1p mps or sav the member function void IlcLinOpt writeProblem const char filename const is converted to void IloCplex exportModel const char filename const Jeuueld Priority Orders In Planner
90. you can ask for the instance not to be considered closed during the search for a solution This will allow new breaks on the resource to be added during the search There are alternative ways of making a set of breaks not closed 4 You can call this member function on the instance of IloIntervallList void IloIntervalList keepOpen IloBool val IloTrue const Or you can work directly on the resource that the set applies to For example in the case of keeping open the list of breaks you can call the keepBreakLi stOpen member function void IloResource keepBreakListOpen IloBool keepOpen IloTrue const This section has simply outlined the way to translate global constraints of an application written for ILOG Scheduler 4 4 into an application of ILOG Scheduler 5 1 For more details about using the scheduling parameters of ILOG Scheduler 5 1 see the following documents ILOG Scheduler 5 1 Extensions Reference Manual This manual contains tables of mappings between Solver and Concert classes plus the means the extractor uses to create the global constraints and resources from the model ILOG Scheduler 5 1 User s Manual ILOG CONCERT TECHNOLOGY 1 1 MIGRATION GUIDE 47 A TRANSLATION EXAMPLE 48 ILOG CONCERT TECHNOLOGV 1 1 MIGRATION GUIDE Migrating from Dispatcher to Concert Technologv We recommend that vou read the ILOG Concert Technologv User s Manual and in this Migration Guide Chapter 2 Migrating from Solve

Download Pdf Manuals

image

Related Search

Related Contents

KM 85/50 WB Comfort KM 85/50 WB Classic  Gembird MHS-402  User Manual Internet Phone  Operating Instructions - Panasonic Service Network Europe  4 Zone Mixer Amplifier series  Betty Crocker BC-1934C Use and Care Manual  CSRレポート2009 詳細版  JVC GR-AX838EG Camcorder User Manual  

Copyright © All rights reserved.
Failed to retrieve file