AMPL and C++ API

  ampl, c++, markov, optimization

Good day,

I am implementing a sequential decision model in C++ and the decision policy to be executed at each epoch is an optimization model. I have implemented the model in AMPL and am attempting to use the AMPL C++ API. While I think I understand how to use data frames to set the values of parameters that are indexed by sets, I am having trouble figuring out how to specify the elements of a set. The sets, parameters, and number of decisions variables are set programmatically (rather than through a data file) because these change randomly at each epoch.

As an example, the section of the AMPL model file that defines the sets is as follows,

set P;
set Tp;
set Tb;

param startYear {p in P};
param v {p in P};

set DECISIONS within {P, Tp};
set PROJECT_SPENDING within {P, Tp, Tb};

var x {DECISIONS};

and I would like to define the elements of the set P, Tp, Tb, DECISIONS, and PROJECT_SPENDING. Specifically, DECISIONS is not used to index a parameter, only the decisions variable x—how do I set the elements of the set (which should be tuples)?

Any guidance would be greatly appreciated.

Regards,
Mark

Source: Windows Questions C++

LEAVE A COMMENT