| |||||||||||||||||||||||||
Burglar - Data source access from Mosel models Description
Source Files By clicking on a file name, a preview is opened at the bottom of this page. Data Files
burglar2dd.mos (!****************************************************** Mosel Example Problems ====================== file burglar2dd.mos ``````````````````` Use of "diskdata" driver for data handling. (c) 2008 Fair Isaac Corporation author: S. Heipcke, 2004 *******************************************************!) model Burglar2dd uses "mmxprs", "mmetc" declarations WTMAX = 102 ! Maximum weight allowed ITEMS: set of string ! Index set for items VALUE: array(ITEMS) of real ! Value of items WEIGHT: array(ITEMS) of real ! Weight of items SOLTAKE: array(ITEMS) of real ! Solution values end-declarations initializations from "mmetc.diskdata:sparse;noq" [VALUE,WEIGHT] as "burglardd.dat" end-initializations ! Alternatively: ! diskdata(ETC_SPARSE+ETC_NOQ, "burglardd.dat", [VALUE,WEIGHT]) declarations take: array(ITEMS) of mpvar ! 1 if we take item i; 0 otherwise end-declarations ! Objective: maximize total value MaxVal:= sum(i in ITEMS) VALUE(i)*take(i) ! Weight restriction sum(i in ITEMS) WEIGHT(i)*take(i) <= WTMAX ! All variables are 0/1 forall(i in ITEMS) take(i) is_binary maximize(MaxVal) ! Solve the problem ! Solution output forall(i in ITEMS) SOLTAKE(i):= getsol(take(i)) initializations to "mmetc.diskdata:append,sparse" SOLTAKE as "burglarout.txt" end-initializations ! Alternatively: ! diskdata(ETC_OUT+ETC_APPEND+ETC_SPARSE, "burglarout.txt", SOLTAKE) end-model | |||||||||||||||||||||||||
© Copyright 2024 Fair Isaac Corporation. |