| |||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
|
Retrieving data from a Mosel model Description mmexset.c: Using sets in Mosel (requires burglari.bim)
Further explanation of this example: 'Mosel Library Reference Manual', Section 1.2 Post processing interface
Source Files By clicking on a file name, a preview is opened at the bottom of this page.
Data Files
burglar_rec.mos
(!******************************************************
Mosel User Guide Example Problems
=================================
file burglar_rec.mos
````````````````````
Use of records.
(c) 2008 Fair Isaac Corporation
author: S. Heipcke, July 2006
*******************************************************!)
model "Burglar (records)"
uses "mmxprs"
public declarations
WTMAX = 102 ! Maximum weight allowed
ITEMS = {"camera", "necklace", "vase", "picture", "tv", "video",
"chest", "brick"} ! Index set for items
I: array(ITEMS) of public record
VALUE: real ! Value of items
WEIGHT: real ! Weight of items
end-record
take: array(ITEMS) of mpvar ! 1 if we take item i; 0 otherwise
end-declarations
initializations from 'Models/burglar_rec.dat'
I
end-initializations
! Objective: maximize total value
MaxVal:= sum(i in ITEMS) I(i).VALUE*take(i)
! Weight restriction
sum(i in ITEMS) I(i).WEIGHT*take(i) <= WTMAX
! All variables are 0/1
forall(i in ITEMS) take(i) is_binary
maximize(MaxVal) ! Solve the MIP-problem
! Print out the solution
writeln("Solution:\n Objective: ", getobjval)
forall(i in ITEMS) writeln(" take(", i, "): ", getsol(take(i)))
end-model
| |||||||||||||||||||||||||||||||||||||
| © Copyright 2025 Fair Isaac Corporation. |