FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious example

Python I/O driver example

Description
Python I/O driver example for the initialization of data to and from Python.

Further explanation of this example: see Chapter 'Python' in the 'Mosel Language Reference Manual'

python3_io_example.zip[download all files]

Source Files

Data Files





io_example.mos

(!******************************************************
   Mosel Python Example Problems
   =============================

   file io_example.mos
   ```````````````````
   Python I/O driver example for the initialization of
   data to and from Python.

  (c) 2018 Fair Isaac Corporation
      author: J.Müller
*******************************************************!)
model "Python I/O example"
  options noimplicit

  uses "python3"

  declarations
    I = 1..4
    A: dynamic array(I) of integer
  end-declarations

  A(1) := 1*2; A(3) := 3*2

  initializations to "python:"
    I as 'MyRange'
    A
  end-initializations

  pyrun("io_example.py")
  delcell(A) ! Delete existing elements from array A.

  initializations from "python:"
    A
  end-initializations

  writeln("Values initialized from Python:")
  writeln("  A   = ", A)
end-model

Back to examples browserPrevious example