Hello, I am new in AMPL but, I am using the command read.ampl() from matlab, it works fine, in most cases. But when AMPL code calls using include codigo.mod, for example, Matlab will not recognize it and sends me an error, I will leave an example below.
If you include other files from a mod or run file, AMPL will search for them in the current directory. Could you please try the following:
ampl.cd(directoryPath2)
ampl.read('PASO_PROXIMAL.mod')
Hello Filipe, another question, sorry and thank you.
Ampl correctly solves the problem and if I give the display command from Matlab it works. The problem is that I canβt save the results of the problem in matlab.
I am using pd = ampl.getVariable(βPiβ); , but it gives me the declaration of the variable but not the results after solving the problem. Pi is not the name of the function to be minimized, it is the values that it found to minimize the objective function.
You can retrieve the values of a scalar variable with:
value = ampl.getVariable(βPiβ).value();
This is illustrated for instance in Example 1 of the MATLAB API: MATLAB API Examples β AMPL API 2.1.0 documentation
You can retrieve the values of an indexed variable as follows:
ampl = AMPL;
ampl.eval("var x{1..100};")
pd = ampl.getVariable('x');
df = pd.getValues();
% Convert the DataFrame to a MATLAB table
df.toTable()
% Get values to MATLAB vector
values = df.getColumnAsDoubles('x.val')
This is illustrated for instance in Example 4 of the MATLAB API: MATLAB API Examples β AMPL API 2.1.0 documentation