Write GAMS results in text file - gams-math

Why is it that GAMS stores results in file with .put extension though i made new project in working directory and specified file mse /D:\RS Results\mse_goal(0.5).txt/;
put mse;?

This should work:
parameter x /1/;
file mse /D:\mse_goal(0.5).txt/;
put mse;
put
'The value of x ='x
Note that GAMS may not like spaces in filepathnames ("D:\RS Results")

Related

how to set the width of output in lst file in GAMS

I use display to output results of some variables. As shown below, variable values are list in one line. With more months included, results go to right and do not come back. It's inconvenient to check. I set the value of page width, but it seems the parameter is not for this. So my question is which is the right parameter I should use to set. Thanks.
Actually I set page width as 72 in GAMS IDE (options -> output) before I post it here. But it does not work. Now I tried to set pagewidth in command line from GAMS terminal (GAMS studio -> tool -> terminal). This is my command: gams myfile PW=80. I cannot see the setting after "-- GAMS parameter defined". I'm not sure if I set it in the wrong way.
I didn't find this page width issue in an old GAMS version. I'm using GAMS 32, and it becomes a problem.
You can use something like "-pw 80" as argument in the command line.

importing training data to CloudML with images that do not have a file-extension

i created some training data and put the CSV in the google-storage, but it looks like the import won't work when the files do not have a proper .jpg extension:
Error: INVALID_ROW: Invalid input found at row 1 of gs://weg-li-production/training/test.csv: "Unsupported file extension."
values look like this:
TRAIN,gs://weg-li-production/d7nwcheo8774rvbcgj4lyta3athj,Opel
is there a way to work around this issue?
It seems you put the whole "TRAIN,gs://weg-li-production/d7nwcheo8774rvbcgj4lyta3athj,Opel" into a single unit in your csv file. The comma should represent another unit in the csv file. You can open it in Excel to check your csv file, and the correct format should include three columns in Excel.
Assuming gs://weg-li-production/d7nwcheo8774rvbcgj4lyta3athj is the image file & Opel is the label. It all looks fine, just that the image file name does not have a valid extension.
Check https://cloud.google.com/vision/automl/docs/prepare for valid file types (extension), during training & predictions

Ansys multiphysics: blank output file

I have a model of a heating process on Ansys Multiphysics, V11.
After running the simulation, I have a script to plot a temperature profile:
!---------------- POST PROCESSING -----------------------
/post1 ! tdatabase postprocessor
!---define profile temperature
path,s_temp1,2,,100 ! define a path
ppath,1,,dop/2,0,0 ! create a path point
ppath,2,,dop/2,1.5,0 ! create a path point
PDEF,surf_t1,TEMP, ,noav ! print a path
plpath,surf_t1 ! plot a path
What I now need, is to save the resulting path in a text file. I have already looked online for a solution, and found the following code to do it, which I appended after the lines above:
/OUTPUT,filename,extension
PRPATH,surf_t1
/OUTPUT
Ansys generates the file filename.extension but it is empty. I tried to place the OUTPUT command in a few locations in the script, but without any success.
I suspect I need to define something else, but I have no idea where to look, as Ansys documentation online is terribly chaotic, and all internet pages I've opened before writing this question are not better.
A final note: Ansys V11 is an old version of the software, but I don't want to upgrade it and fit the old model to the new software.
For the output of the simulation (which includes all calculation steps, and sub-steps description and node-by-node results) the output must be declared in the beginning of the code, and not in the postprocessing phase.
Declaring
/OUTPUT,filename,extension
in the preamble of the main script makes such that the output is stored in the right location, with the desired extension. At the end of the scripts, you must then declare
/OUTPUT
to reset the output file location for ANSYS.
The output to the PATH call made in the postprocessing script is however not printed in the file.
It is convenient to use
*CFOPEN,file,ext
*VWRITE,Vector(1,1).Vector(1,2)
(2F12.6)
*CFCLOSE
where Vector(1,1) is a two column array created by *DIM, and stores your data to output to file
As this is a special command, run it from file i.e. macro_output.mac

Display variables using CBC MPS input in NEOS

Am trying to use NEOS to solve a linear program using MPS input.
The MPS file is fine, but apparently you need a "paramaters file" as well to tell the solver what to do (min/max etc.). However I can't find any information on this online anywhere.
So far I have got NEOS to solve a maximization problem and display the objective function. However I cannot get it to display the variables.
Does anyone know what code I should add to the paramters file to tell NEOS/CBC to display the resulting variables?
The parameter file consists of a list of Cbc (standalone) commands in a file (one per line). The format of the commands is (quoting the documentation):
One command per line (and no -)
abcd? gives list of possibilities, if only one + explanation
abcd?? adds explanation, if only one fuller help(LATER)
abcd without value (where expected) gives current value
abcd value or abcd = value sets value
The commands are the following:
? dualT(olerance) primalT(olerance) inf(easibilityWeight)
integerT(olerance) inc(rement) allow(ableGap) ratio(Gap)
fix(OnDj) tighten(Factor) log(Level) slog(Level)
maxN(odes) strong(Branching) direction error(sAllowed)
gomory(Cuts) probing(Cuts) knapsack(Cuts) oddhole(Cuts)
clique(Cuts) round(ingHeuristic) cost(Strategy) keepN(ames)
scaling directory solver import
export save(Model) restore(Model) presolve
initialS(olve) branch(AndBound) sol(ution) max(imize)
min(imize) time(Limit) exit stop
quit - stdin unitTest
miplib ver(sion)
To see the solution values, you should include the line sol - after the min or max line of your parameter file.
If this doesn't work you can submit the problem to NEOS in AMPL format via this page. In addition to model and data files, it accepts a commands file where you can use statements to solve the problem and display the solution, for example:
solve;
display _varname, _var;
This post describes how to convert MPS to AMPL.

how to print f[r] and f[k] values in an output file for each value of r and k in mathematica?

How can i print the f[r] and f[k] values in an output file along with r and k values using mathematica?
Is there any way I can automate the export of this output to a .txt file without having to re-write the Print[] commands?
The simplest approach to saving Mathematica expressions is to use the Save function. You could write
Save[filename,x]
and Mathematica will save the definitions associated with variable x into the file you've named. Note
Save appends to an already existing file;
expressions are written in InputForm;
you can load the expressions back into your workspace using the << (aka Get) function, which reads and evaluates the expressions stored in a file.
How you actually use Save to store your data is up to you. You might, perhaps, assign the results of a call such as Table[{k,f[k]},{k,min,max,step}] to a variable and save that result variable, which will appear in the file as a table of k,f[k] pairs.
Since Save appends to an existing file you could, if you are using loops, save a k,f[k] pair at each iteration. But why would you be using loops in Mathematica ?