Skip to content

Iterative Pricing Exercise #66

Answered by fumitoh
mhumpher asked this question in Q&A
Discussion options

You must be logged in to vote

You can assign input values to cells by [] =

For example,

import modelx as mx
from modelx import defcells

@defcells
def pv_premiums():
    return 0 # dummy

@defcells
def pv_claims():
    return 3

@defcells
def net_pv():
    return pv_premiums() - pv_claims()

and

>>> pv_premiums[()] = 4

>>> net_pv()
1

>>> pv_premiums[()] = 3

>>> net_pv()
0

You can write a loop in Python to iterate the assignment operation above. but it's more recommended to refer to a Reference instead of directly assigning values to pv_premiums:

@defcells
def pv_premiums():
    return pv_prem_input
>>> mx.Model1.Space1.pv_prem_input = 4

>>> net_pv()
1

>>> mx.Model1.Space1.pv_prem_input = 3

>>> net_pv()
0

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fumitoh
Comment options

Answer selected by mhumpher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants