help with variables using .dll
help with variables using .dll
I have a problem with the variables to simulate because I do not collect the good of the model, gave me a weird number
-1.2980.... and presumably that means that it has not begun the simulation, but if you started.
Because I have:
result=vensim.command("SPECIAL>LOADMODEL|C:\\Documents and Settings\\miriiam\\Escritorio\\PROYECTO\\mariaje\\MODELO\\ACI118MO00\\CIMD9.vmf" );
result = vensim.command("SIMULATE>RUNNAME|base.vdf");
Someone can help me please?
[Edited on 9-17-2008 by vero]
[Edited on 9-17-2008 by vero]
-1.2980.... and presumably that means that it has not begun the simulation, but if you started.
Because I have:
result=vensim.command("SPECIAL>LOADMODEL|C:\\Documents and Settings\\miriiam\\Escritorio\\PROYECTO\\mariaje\\MODELO\\ACI118MO00\\CIMD9.vmf" );
result = vensim.command("SIMULATE>RUNNAME|base.vdf");
Someone can help me please?
[Edited on 9-17-2008 by vero]
[Edited on 9-17-2008 by vero]
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
With that work for me either.
I put: vensim.get_data result = ( "base.vdf", "initial price [producto1, competidor1]," "Time", rval, precioinicial1, 36), but not if it is correct as well.
What we had was:
Cargo model, collect the variable value to put in a box with vensim.get_val result = ( "initial price [producto1, competidor1]," precioinicial1);
but the variables are not reflected well, the only constant.
I tried to put before collecting the variable:
vensim.command result = (TEST> Shopping store [producto1, competidor1]> 0 ");
and work for me but only for some.
I do not understand.
Sorry for the English!
Please HELP
I put: vensim.get_data result = ( "base.vdf", "initial price [producto1, competidor1]," "Time", rval, precioinicial1, 36), but not if it is correct as well.
What we had was:
Cargo model, collect the variable value to put in a box with vensim.get_val result = ( "initial price [producto1, competidor1]," precioinicial1);
but the variables are not reflected well, the only constant.
I tried to put before collecting the variable:
vensim.command result = (TEST> Shopping store [producto1, competidor1]> 0 ");
and work for me but only for some.
I do not understand.
Sorry for the English!
Please HELP
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
The get_data call should work - as you have entered it there are errors in the " placement so be sure that does not happen i n your code. Also both rval and tval (precioinicial1) need to be vectors with at least 36 spaces. eg use
private int tpoints ;
float rval[], tval[];
// create arrays for time and values, hardwired array length
tval = new float[41];
rval = new float[41];
tpoints = vensim.get_data( "base.vdf", "Population", "time", rval, tval, 41 );
as in the exmaple VensimApp.java
private int tpoints ;
float rval[], tval[];
// create arrays for time and values, hardwired array length
tval = new float[41];
rval = new float[41];
tpoints = vensim.get_data( "base.vdf", "Population", "time", rval, tval, 41 );
as in the exmaple VensimApp.java
Thank you so much! already got it but now what I fault is that when I pretend to, do this:
vensimCommand = "simulates> SETVAL | initial price [producto1, competidor1] =" + PrecioInit1;
vensim.command result = ( "MENU> RUN | 0");
And then to pick the outcome of the simulation:
tpoints = vensim.get_data ( "base.vdf", "EBITDA", "time", rval, tval, 41);
but I get the bug to do:
vensimCommand = "simulates> SETVAL | initial price [producto1, competidor1] =" + PrecioInit1;
for variables alone, because for the continuing work for me either.
I could help? Thank you so much
vensimCommand = "simulates> SETVAL | initial price [producto1, competidor1] =" + PrecioInit1;
vensim.command result = ( "MENU> RUN | 0");
And then to pick the outcome of the simulation:
tpoints = vensim.get_data ( "base.vdf", "EBITDA", "time", rval, tval, 41);
but I get the bug to do:
vensimCommand = "simulates> SETVAL | initial price [producto1, competidor1] =" + PrecioInit1;
for variables alone, because for the continuing work for me either.
I could help? Thank you so much
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
private Vensim vensim = new Vensim();
final static int APPWIDTH = 800;
final static int APPHEIGHT = 600;
private Label l1, l2, l3, l4, l5, l6, l7, l8, l9, l10;
private TextField tf4,cprecio1, cprecio2, cdistribucion, cpublicidad, ccompras1, ccompras2, ccontratacion, csalarioj, csalarios;
private TextArea ta1;
private Button b1, b2, b3, b5, b7;
private Panel p1, p2, p3, p4, p5;
private int tpoints, result;
float rval[], tval[], gval[], dval[];
float EBITDA[] = new float[36];
float precioinicial1[] = new float[36];
float precioinicial2[] = new float[36];
float distribucion[] = new float[36];
float publicidad[] = new float[36];
float comprasalmacen1[] = new float[36];
float comprasalmacen2[] = new float[36];
float contratacion[] = new float[36];
float salarioj[] = new float[36];
float salarios[] = new float[36];
double distri[] = new double[36];
private String PrecioInit1,PrecioInit2, PublicidadInit, DistribucionInit, ComprasInit1, ComprasInit2, ContratacionInit, SalarioJInit, SalarioSInit, vensimCommand;
/**
* Constructor creates the application interface
*/
public VensimApp()
{
//TAMAÑO DE LA VENTANA DE APLICACION Y TITULO
setSize( APPWIDTH, APPHEIGHT );
setLayout( new BorderLayout(20,20) );
setTitle( "Java to Vensim" );
//PANEL DONDE ESTA INCLUIDOS TODOS LOS DEMAS PANELES
p1 = new Panel();
p1.setLayout( new BorderLayout(20,20) );
add( p1, BorderLayout.WEST );
//PANEL DEL TEXTO GRIS
p2 = new Panel();
p2.setLayout( new BorderLayout(20,20) );
add( p2, BorderLayout.CENTER );
//PANEL DONDE ESTAN LOS CAMPOS PARA INTRODUCIR LOS DATOS
p3 = new Panel();
p3.setLayout( new GridLayout(9,10) );
p1.add( p3, BorderLayout.NORTH );
//PANEL DE LOS BOTONES
p4 = new Panel();
p4.setLayout( new GridLayout(5,2,10,10) );
p1.add( p4, BorderLayout.CENTER );
//PANEL INFERIOR, DONDE ESTA EL CAMPO DE SALIDA
p5 = new Panel();
p5.setLayout( new FlowLayout() );
p1.add( p5, BorderLayout.SOUTH );
//AÑADE ETIQUETA Y CAMPO DE TEXTO AL PANEL 3
l1 = new Label( "Precio Producto 1" );
p3.add( l1 );
cprecio1 = new TextField( 10 );
p3.add( cprecio1 );
//AÑADE ETIQUETA Y CAMPO DE TEXTO AL PANEL 3
l2 = new Label( "Precio Producto 2" );
p3.add( l2 );
cprecio2 = new TextField( 10 );
p3.add(cprecio2);
//AÑADE ETIQUETA Y CAMPO DE TEXTO AL PANEL 3
l3 = new Label( "Gastos distribución ");
p3.add( l3 );
cdistribucion = new TextField( 10 );
p3.add(cdistribucion);
l4 = new Label ("Gastos publicidad ");
p3.add(l4);
cpublicidad = new TextField(10);
p3.add(cpublicidad);
l5 = new Label (" Compras almacen Producto 1");
p3.add(l5);
ccompras1 = new TextField (10);
p3.add(ccompras1);
l6 = new Label (" Compras almacen Producto 2");
p3.add(l6);
ccompras2 = new TextField(10);
p3.add(ccompras2);
l7 = new Label (" Plantilla Junior");
p3.add(l7);
ccontratacion = new TextField(10);
p3.add(ccontratacion);
l8 = new Label (" Salario Personal Junior");
p3.add(l8);
csalarioj = new TextField(10);
p3.add(csalarioj);
l9 = new Label (" Salario Personal Senior");
p3.add(l9);
csalarios = new TextField(10);
p3.add(csalarios);
//AÑADE BOTONES AL PANEL 4
b1 = new Button( "CARGAR MODELO" );
p4.add( b1 );
b1.addActionListener( this );
b2 = new Button( "SIMULAR" );
p4.add( b2 );
b2.addActionListener( this );
b3 = new Button( "SETUP GAME" );
p4.add( b3 );
b3.addActionListener( this );
b5 = new Button( "CONTINUAR EL JUEGO" );
p4.add( b5 );
b5.addActionListener( this );
b7 = new Button( "EMPEZAR EL JUEGO" );
p4.add( b7 );
b7.addActionListener( this );
//AÑADE ETIQUETA Y CAMPO DE SALIDA AL PANEL 5 (el de abajo del todo)
l10 = new Label( "EBITDA = " );
p5.add( l10 );
tf4 = new TextField( 15 );
tf4.setEditable(false);
p5.add( tf4 );
//AÑADE AREA DE SALIDA DE DATOS AL PANEL 2 (el campo de la derecha grande)
ta1 = new TextArea("CUADRO DE TEXTO: A QUE VOY A SALIR BIEN?....", 10,50);
ta1.setEditable( false );
p2.add( ta1, BorderLayout.NORTH );
//HACE LA APLICACIÓN VISIBLE
setVisible( true );
// CREAMOS ARRAY DE TIEMO Y VALORES, hardwired array length
tval = new float[41];
rval = new float[41];
result = vensim.be_quiet(2);
if (result == 0)
System.out.println( "Vensim be quiet failed" );
}
public void actionPerformed ( ActionEvent e )
{
//CARGAR MODELO
if (e.getSource() == b1)
{
result = vensim.command( "SPECIAL>LOADMODEL|C:\\Documents and Settings\\miriiam\\Escritorio\\PROYECTO\\mariaje\\MODELO\\ACI118MO00\\CIMD9.vmf" );
ta1.setText("MODELO VENSIM......OK");
}
//get the value for precio inicial and put it in the text field
result=vensim.get_data("base.vdf","precio inicial[producto1,competidor1]","TIME",precioinicial1,tval,41);
cprecio1.setText(Float.toString(precioinicial1[0]));
//get the value for precio inicial and put it in the text field
result=vensim.get_data("base.vdf","precio inicial[producto2,competidor2]","TIME",precioinicial2,tval,41);
cprecio2.setText(Float.toString(precioinicial2[0]));
result=vensim.get_data("base.vdf","Gastos distribucion[competidor1]","TIME",distribucion,tval,41);
cdistribucion.setText(Float.toString(distribucion[0]));
result=vensim.get_data("base.vdf","Gastos publicidad[competidor1]","TIME",publicidad,tval,41);
cpublicidad.setText(Float.toString(publicidad[0]));
result=vensim.get_data("base.vdf","Compras almacen[producto1,competidor1]","TIME",comprasalmacen1,tval,41); ccompras1.setText(Float.toString(comprasalmacen1[0]));
result=vensim.get_data("base.vdf","Compras almacen[producto2,competidor1]","TIME",comprasalmacen2,tval,41); ccompras2.setText(Float.toString(comprasalmacen2[0]));
result=vensim.get_data("base.vdf","contratacion junior[competidor1]","TIME",contratacion,tval,41); ccontratacion.setText(Float.toString(contratacion[0]));
result=vensim.get_data("base.vdf","Salario medio[junior,competidor1]","TIME",salarioj,tval,41);
csalarioj.setText(Float.toString(salarioj[0]));
//SALARIO SENIOR
result=vensim.get_data("base.vdf","Salario medio[senior,competidor1]","TIME",salarios,tval,41);
csalarios.setText(Float.toString(salarios[0]));
}
//SIMULAR
else if (e.getSource() == b2)
{
//set run name
result = vensim.command( "SIMULATE>RUNNAME|base" );
//COGE EL VALOR DEL CAMPO cprecio1
PrecioInit1 = cprecio1.getText();
vensimCommand = "SIMULATE>DATA|precio inicial[producto1,competidor1] = " + PrecioInit1;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO cprecio2
PrecioInit2 = cprecio2.getText;
vensimCommand = "SIMULATE>DATA|precio inicial[producto2,competidor1] = " + PrecioInit2;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO cdistribucion
DistribucionInit=cdistribucion.getText();
vensimCommand = "SIMULATE>DATA|Gastos distribucion[competidor1] = " + DistribucionInit;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO cpublicidad
PublicidadInit = cpublicidad.getText();
vensimCommand = "SIMULATE>DATA|Gastos publicidad[competidor1] = " + PublicidadInit;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO ccompras1
ComprasInit1 = ccompras1.getText();
vensimCommand = "SIMULATE>DATA|Compras almacen[producto1,competidor1] = " + ComprasInit1;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO ccompras2
ComprasInit2 = ccompras2.getText();
vensimCommand = "SIMULATE>DATA|Compras almacen[producto2,competidor1] = " + ComprasInit2;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO csalarios
SalarioSInit = csalarios.getText(); vensimCommand = "SIMULATE>DATA|Salario medio[senior,competidor1] = " + SalarioSInit;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO csalarioj (salario junior)
SalarioJInit = csalarioj.getText();
vensimCommand = "SIMULATE>DATA|Salario medio[junior,competidor1] = " + SalarioJInit;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPOS ccontratacion
ContratacionInit = ccontratacion.getText();
vensimCommand = "SIMULATE>DATA|Contratacion junior[competidor1] = " + ContratacionInit;
result = vensim.command( vensimCommand );
//SIMULAMOS.....
result = vensim.command( "MENU>RUN|0" );
MY PROBLEM STARTS FROM HERE!!!!!!!
//OUTPUT
tpoints = vensim.get_data( "base.vdf", "EBITDA", "TIME", EBITDA, tval, 41 );
StringBuffer buf = new StringBuffer("EBITDA \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf.append(Float.toString(tval));
buf.append("\t");
}
buf.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf.append(Float.toString(EBITDA));
buf.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf.toString());
//coge el valor de ebitda y lo pone en el campo de texto
result=vensim.get_data("base.vdf","EBITDA","TIME",EBITDA,tval,41);
//se añade el valor actual?? en el campo de salida de abajo
tf4.setText(Float.toString(EBITDA[0]));
}
//SET UP
else if (e.getSource() == b3)
{
result = vensim.command("GAME>GAMEINTERVAL|1");
result = vensim.command("MENU>GAME");
if (result == 0)
ta1.setText("Start game fails");
else
ta1.setText("Start game succeeds");
/**
* Check the status of vensim
**/
result = vensim.start_simulation(1,1,1);
if (result != 5)
System.out.println( "Start a gaming simulation -- failed" );
else
ta1.setText("Vensim started a game");
}
else if (e.getSource() == b5)
{
//CONTINUE A GAME
//set the capital investment rate to the input field value
EBITDA = tf3.getText();
//continue the simulation game
result = vensim.command("GAME>GAMEON") ;
if (result == 1)
{
System.out.println( "game in progress" );
ta1.setText("game in progress");
}
else
{
System.out.println( "Vensim failed to continue game" );
ta1.setText("Vensim failed to continue game");
}
//get the value for EBITDA and put it in the text field
result=vensim.get_data("base.vdf","EBITDA","TIME",EBITDA,tval,41);
if (result == 0)
{
System.out.println( "get_val -- failed" );
ta1.setText("Failed to get EBITDA Values");
}
tf4.setText(Float.toString(EBITDA[0]));
}
Thank you very muchTextMY PROBLEM STARTS FROM HERE
:(:(:(:(:(:(
final static int APPWIDTH = 800;
final static int APPHEIGHT = 600;
private Label l1, l2, l3, l4, l5, l6, l7, l8, l9, l10;
private TextField tf4,cprecio1, cprecio2, cdistribucion, cpublicidad, ccompras1, ccompras2, ccontratacion, csalarioj, csalarios;
private TextArea ta1;
private Button b1, b2, b3, b5, b7;
private Panel p1, p2, p3, p4, p5;
private int tpoints, result;
float rval[], tval[], gval[], dval[];
float EBITDA[] = new float[36];
float precioinicial1[] = new float[36];
float precioinicial2[] = new float[36];
float distribucion[] = new float[36];
float publicidad[] = new float[36];
float comprasalmacen1[] = new float[36];
float comprasalmacen2[] = new float[36];
float contratacion[] = new float[36];
float salarioj[] = new float[36];
float salarios[] = new float[36];
double distri[] = new double[36];
private String PrecioInit1,PrecioInit2, PublicidadInit, DistribucionInit, ComprasInit1, ComprasInit2, ContratacionInit, SalarioJInit, SalarioSInit, vensimCommand;
/**
* Constructor creates the application interface
*/
public VensimApp()
{
//TAMAÑO DE LA VENTANA DE APLICACION Y TITULO
setSize( APPWIDTH, APPHEIGHT );
setLayout( new BorderLayout(20,20) );
setTitle( "Java to Vensim" );
//PANEL DONDE ESTA INCLUIDOS TODOS LOS DEMAS PANELES
p1 = new Panel();
p1.setLayout( new BorderLayout(20,20) );
add( p1, BorderLayout.WEST );
//PANEL DEL TEXTO GRIS
p2 = new Panel();
p2.setLayout( new BorderLayout(20,20) );
add( p2, BorderLayout.CENTER );
//PANEL DONDE ESTAN LOS CAMPOS PARA INTRODUCIR LOS DATOS
p3 = new Panel();
p3.setLayout( new GridLayout(9,10) );
p1.add( p3, BorderLayout.NORTH );
//PANEL DE LOS BOTONES
p4 = new Panel();
p4.setLayout( new GridLayout(5,2,10,10) );
p1.add( p4, BorderLayout.CENTER );
//PANEL INFERIOR, DONDE ESTA EL CAMPO DE SALIDA
p5 = new Panel();
p5.setLayout( new FlowLayout() );
p1.add( p5, BorderLayout.SOUTH );
//AÑADE ETIQUETA Y CAMPO DE TEXTO AL PANEL 3
l1 = new Label( "Precio Producto 1" );
p3.add( l1 );
cprecio1 = new TextField( 10 );
p3.add( cprecio1 );
//AÑADE ETIQUETA Y CAMPO DE TEXTO AL PANEL 3
l2 = new Label( "Precio Producto 2" );
p3.add( l2 );
cprecio2 = new TextField( 10 );
p3.add(cprecio2);
//AÑADE ETIQUETA Y CAMPO DE TEXTO AL PANEL 3
l3 = new Label( "Gastos distribución ");
p3.add( l3 );
cdistribucion = new TextField( 10 );
p3.add(cdistribucion);
l4 = new Label ("Gastos publicidad ");
p3.add(l4);
cpublicidad = new TextField(10);
p3.add(cpublicidad);
l5 = new Label (" Compras almacen Producto 1");
p3.add(l5);
ccompras1 = new TextField (10);
p3.add(ccompras1);
l6 = new Label (" Compras almacen Producto 2");
p3.add(l6);
ccompras2 = new TextField(10);
p3.add(ccompras2);
l7 = new Label (" Plantilla Junior");
p3.add(l7);
ccontratacion = new TextField(10);
p3.add(ccontratacion);
l8 = new Label (" Salario Personal Junior");
p3.add(l8);
csalarioj = new TextField(10);
p3.add(csalarioj);
l9 = new Label (" Salario Personal Senior");
p3.add(l9);
csalarios = new TextField(10);
p3.add(csalarios);
//AÑADE BOTONES AL PANEL 4
b1 = new Button( "CARGAR MODELO" );
p4.add( b1 );
b1.addActionListener( this );
b2 = new Button( "SIMULAR" );
p4.add( b2 );
b2.addActionListener( this );
b3 = new Button( "SETUP GAME" );
p4.add( b3 );
b3.addActionListener( this );
b5 = new Button( "CONTINUAR EL JUEGO" );
p4.add( b5 );
b5.addActionListener( this );
b7 = new Button( "EMPEZAR EL JUEGO" );
p4.add( b7 );
b7.addActionListener( this );
//AÑADE ETIQUETA Y CAMPO DE SALIDA AL PANEL 5 (el de abajo del todo)
l10 = new Label( "EBITDA = " );
p5.add( l10 );
tf4 = new TextField( 15 );
tf4.setEditable(false);
p5.add( tf4 );
//AÑADE AREA DE SALIDA DE DATOS AL PANEL 2 (el campo de la derecha grande)
ta1 = new TextArea("CUADRO DE TEXTO: A QUE VOY A SALIR BIEN?....", 10,50);
ta1.setEditable( false );
p2.add( ta1, BorderLayout.NORTH );
//HACE LA APLICACIÓN VISIBLE
setVisible( true );
// CREAMOS ARRAY DE TIEMO Y VALORES, hardwired array length
tval = new float[41];
rval = new float[41];
result = vensim.be_quiet(2);
if (result == 0)
System.out.println( "Vensim be quiet failed" );
}
public void actionPerformed ( ActionEvent e )
{
//CARGAR MODELO
if (e.getSource() == b1)
{
result = vensim.command( "SPECIAL>LOADMODEL|C:\\Documents and Settings\\miriiam\\Escritorio\\PROYECTO\\mariaje\\MODELO\\ACI118MO00\\CIMD9.vmf" );
ta1.setText("MODELO VENSIM......OK");
}
//get the value for precio inicial and put it in the text field
result=vensim.get_data("base.vdf","precio inicial[producto1,competidor1]","TIME",precioinicial1,tval,41);
cprecio1.setText(Float.toString(precioinicial1[0]));
//get the value for precio inicial and put it in the text field
result=vensim.get_data("base.vdf","precio inicial[producto2,competidor2]","TIME",precioinicial2,tval,41);
cprecio2.setText(Float.toString(precioinicial2[0]));
result=vensim.get_data("base.vdf","Gastos distribucion[competidor1]","TIME",distribucion,tval,41);
cdistribucion.setText(Float.toString(distribucion[0]));
result=vensim.get_data("base.vdf","Gastos publicidad[competidor1]","TIME",publicidad,tval,41);
cpublicidad.setText(Float.toString(publicidad[0]));
result=vensim.get_data("base.vdf","Compras almacen[producto1,competidor1]","TIME",comprasalmacen1,tval,41); ccompras1.setText(Float.toString(comprasalmacen1[0]));
result=vensim.get_data("base.vdf","Compras almacen[producto2,competidor1]","TIME",comprasalmacen2,tval,41); ccompras2.setText(Float.toString(comprasalmacen2[0]));
result=vensim.get_data("base.vdf","contratacion junior[competidor1]","TIME",contratacion,tval,41); ccontratacion.setText(Float.toString(contratacion[0]));
result=vensim.get_data("base.vdf","Salario medio[junior,competidor1]","TIME",salarioj,tval,41);
csalarioj.setText(Float.toString(salarioj[0]));
//SALARIO SENIOR
result=vensim.get_data("base.vdf","Salario medio[senior,competidor1]","TIME",salarios,tval,41);
csalarios.setText(Float.toString(salarios[0]));
}
//SIMULAR
else if (e.getSource() == b2)
{
//set run name
result = vensim.command( "SIMULATE>RUNNAME|base" );
//COGE EL VALOR DEL CAMPO cprecio1
PrecioInit1 = cprecio1.getText();
vensimCommand = "SIMULATE>DATA|precio inicial[producto1,competidor1] = " + PrecioInit1;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO cprecio2
PrecioInit2 = cprecio2.getText;
vensimCommand = "SIMULATE>DATA|precio inicial[producto2,competidor1] = " + PrecioInit2;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO cdistribucion
DistribucionInit=cdistribucion.getText();
vensimCommand = "SIMULATE>DATA|Gastos distribucion[competidor1] = " + DistribucionInit;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO cpublicidad
PublicidadInit = cpublicidad.getText();
vensimCommand = "SIMULATE>DATA|Gastos publicidad[competidor1] = " + PublicidadInit;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO ccompras1
ComprasInit1 = ccompras1.getText();
vensimCommand = "SIMULATE>DATA|Compras almacen[producto1,competidor1] = " + ComprasInit1;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO ccompras2
ComprasInit2 = ccompras2.getText();
vensimCommand = "SIMULATE>DATA|Compras almacen[producto2,competidor1] = " + ComprasInit2;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO csalarios
SalarioSInit = csalarios.getText(); vensimCommand = "SIMULATE>DATA|Salario medio[senior,competidor1] = " + SalarioSInit;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPO csalarioj (salario junior)
SalarioJInit = csalarioj.getText();
vensimCommand = "SIMULATE>DATA|Salario medio[junior,competidor1] = " + SalarioJInit;
result = vensim.command( vensimCommand );
//COGE EL VALOR DEL CAMPOS ccontratacion
ContratacionInit = ccontratacion.getText();
vensimCommand = "SIMULATE>DATA|Contratacion junior[competidor1] = " + ContratacionInit;
result = vensim.command( vensimCommand );
//SIMULAMOS.....
result = vensim.command( "MENU>RUN|0" );
MY PROBLEM STARTS FROM HERE!!!!!!!
//OUTPUT
tpoints = vensim.get_data( "base.vdf", "EBITDA", "TIME", EBITDA, tval, 41 );
StringBuffer buf = new StringBuffer("EBITDA \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf.append(Float.toString(tval));
buf.append("\t");
}
buf.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf.append(Float.toString(EBITDA));
buf.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf.toString());
//coge el valor de ebitda y lo pone en el campo de texto
result=vensim.get_data("base.vdf","EBITDA","TIME",EBITDA,tval,41);
//se añade el valor actual?? en el campo de salida de abajo
tf4.setText(Float.toString(EBITDA[0]));
}
//SET UP
else if (e.getSource() == b3)
{
result = vensim.command("GAME>GAMEINTERVAL|1");
result = vensim.command("MENU>GAME");
if (result == 0)
ta1.setText("Start game fails");
else
ta1.setText("Start game succeeds");
/**
* Check the status of vensim
**/
result = vensim.start_simulation(1,1,1);
if (result != 5)
System.out.println( "Start a gaming simulation -- failed" );
else
ta1.setText("Vensim started a game");
}
else if (e.getSource() == b5)
{
//CONTINUE A GAME
//set the capital investment rate to the input field value
EBITDA = tf3.getText();
//continue the simulation game
result = vensim.command("GAME>GAMEON") ;
if (result == 1)
{
System.out.println( "game in progress" );
ta1.setText("game in progress");
}
else
{
System.out.println( "Vensim failed to continue game" );
ta1.setText("Vensim failed to continue game");
}
//get the value for EBITDA and put it in the text field
result=vensim.get_data("base.vdf","EBITDA","TIME",EBITDA,tval,41);
if (result == 0)
{
System.out.println( "get_val -- failed" );
ta1.setText("Failed to get EBITDA Values");
}
tf4.setText(Float.toString(EBITDA[0]));
}
Thank you very muchTextMY PROBLEM STARTS FROM HERE

-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
The three thing I can see wrong are:
EITBA has only 36 elements but you are telling Vensim it has 41. If the simulation has more than 36 saved points behavior will be unpredictable. )You also need to double check that EITBA is a model variable. )
The SIMULATE>DATA commands should be SIMULATE>SETVAL commands.
MENU>RUN|0 should be MENU>RUN|O (oh instead of zero).
EITBA has only 36 elements but you are telling Vensim it has 41. If the simulation has more than 36 saved points behavior will be unpredictable. )You also need to double check that EITBA is a model variable. )
The SIMULATE>DATA commands should be SIMULATE>SETVAL commands.
MENU>RUN|0 should be MENU>RUN|O (oh instead of zero).
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
I have already achieved
Now I have a doubt, when we put:
tpoints = vensim.get_data ( "base", "EBITDA [competidor1]", "TIME", EBITDA, tval, 36);
The base.vdf must exist? or you can put a. VDF and white that simulates what there?
I am not sure.
I would appreciate if someone explain the function. VDF there
Thank you very much
Now I have a doubt, when we put:
tpoints = vensim.get_data ( "base", "EBITDA [competidor1]", "TIME", EBITDA, tval, 36);
The base.vdf must exist? or you can put a. VDF and white that simulates what there?
I am not sure.
I would appreciate if someone explain the function. VDF there
Thank you very much
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
-
- Super Administrator
- Posts: 4838
- Joined: Wed Mar 05, 2003 3:10 am
-
- Super Administrator
- Posts: 4838
- Joined: Wed Mar 05, 2003 3:10 am
we store variables in .vdf
We do:
*Load the model
result = vensim.command( "SPECIAL>LOADMODEL|C:\\Documents and Settings\\miriiam\\Escritorio\\PROYECTO\\mariaje\\MODELO\\ACI118MO00\\CIMD9.vmf" );
*Get the initial values
result=vensim.get_data("base","precios[producto1,competidor1]","TIME",precioinicial1,tval,36);
*Simulate
result = vensim.command( "SIMULATE>RUNNAME|base" );
*Catch the result
tpoints = vensim.get_data( "base", "EBITDA[competidor1]", "TIME", EBITDA, tval, 36 );
[Edited on 9-25-2008 by vero]
We do:
*Load the model
result = vensim.command( "SPECIAL>LOADMODEL|C:\\Documents and Settings\\miriiam\\Escritorio\\PROYECTO\\mariaje\\MODELO\\ACI118MO00\\CIMD9.vmf" );
*Get the initial values
result=vensim.get_data("base","precios[producto1,competidor1]","TIME",precioinicial1,tval,36);
*Simulate
result = vensim.command( "SIMULATE>RUNNAME|base" );
*Catch the result
tpoints = vensim.get_data( "base", "EBITDA[competidor1]", "TIME", EBITDA, tval, 36 );
[Edited on 9-25-2008 by vero]
-
- Super Administrator
- Posts: 4838
- Joined: Wed Mar 05, 2003 3:10 am
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
I have the problem here:
if (e.getSource() == b2)
{
//set run name
result = vensim.command( "SIMULATE>RUNNAME|base" );
if (result == 0)
System.out.println( "SIMULATE>RUNNAME|base -- failed" );
//COGE EL VALOR DEL CAMPO cprecio1
PrecioInit1 = cprecio1.getText();
vensimCommand = "SIMULATE>SETVAL|precios [producto1,competidor1] = " + PrecioInit1;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|precio inicial = " + PrecioInit1 + " -- failed" );
//COGE EL VALOR DEL CAMPO cprecio2
PrecioInit2 = cprecio2.getText();
vensimCommand = "SIMULATE>SETVAL|precios [producto2,competidor1] = " + PrecioInit2;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|precios [producto2,competidor1]= " + PrecioInit2 + " -- failed" );
//COGE EL VALOR DEL CAMPO cdistribucion
DistribucionInit=cdistribucion.getText();
vensimCommand = "SIMULATE>SETVAL|Gastos distribucion[competidor1] = " + DistribucionInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Gastos distribucion[competidor1]= " + DistribucionInit + " -- failed" );
//COGE EL VALOR DEL CAMPO cpublicidad
PublicidadInit = cpublicidad.getText();
vensimCommand = "SIMULATE>SETVAL|Gastos publicidad[competidor1] = " + PublicidadInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Gastos publicidad[competidor1]= " + PublicidadInit + " -- failed" );
//COGE EL VALOR DEL CAMPO ccompras1
ComprasInit1 = ccompras1.getText();
vensimCommand = "SIMULATE>SETVAL|Compras almacen[producto1,competidor1] = " + ComprasInit1;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Compras almacen[producto1,competidor1]=" + ComprasInit1 + " -- failed" );
//COGE EL VALOR DEL CAMPO ccompras2
ComprasInit2 = ccompras2.getText();
vensimCommand = "SIMULATE>SETVAL|Compras almacen[producto2,competidor1] = " + ComprasInit2;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Compras almacen[producto2,competidor1]=" + ComprasInit2 + " -- failed" );
//COGE EL VALOR DEL CAMPO csalarios
SalarioSInit = csalarios.getText();
vensimCommand = "SIMULATE>SETVAL|Salario medio[senior,competidor1] = " + SalarioSInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Salario medio[senior,competidor1]= " + SalarioSInit + " -- failed" );
//COGE EL VALOR DEL CAMPO csalarioj (salario junior)
SalarioJInit = csalarioj.getText();
vensimCommand = "SIMULATE>SETVAL|Salario medio[junior,competidor1] = " + SalarioJInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Salario medio[junior, competidor1]= " + SalarioJInit + " -- failed" );
//COGE EL VALOR DEL CAMPOS ccontratacion
ContratacionInit = ccontratacion.getText();
vensimCommand = "SIMULATE>SETVAL|Contratacion junior[competidor1] = " + ContratacionInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Contratacion junior[competidor1]= " + ContratacionInit + " -- failed" );
//SIMULAMOS.....
result = vensim.command( "MENU>RUN|O" );
if (result == 0)
System.out.println( "MENU>RUN|O -- failed" );
/******SALIDA DE LA VARIABLE EBITDA PARA EL COMPETIDOR1******/
tpoints = vensim.get_data( "base", "EBITDA[competidor1]", "TIME", EBITDA, tval, 36 );
StringBuffer buf = new StringBuffer("EBITDA \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf.append(Float.toString(tval));
buf.append("\t");
}
buf.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf.append(Float.toString(EBITDA));
buf.append("\t");
}
//coge el valor de ebitda y lo pone en el campo de texto
result=vensim.get_data("base","EBITDA[competidor1]","TIME",EBITDA,tval,36);
//se añade el valor actual en el campo de salida de abajo
tf4.setText(Float.toString(EBITDA[35]));
/******SALIDA DE LA VARIABLE EBITDA ACUMULADO PARA EL COMPETIDOR1******/
tpoints = vensim.get_data( "base", "EBITDA acumulado[competidor1]", "TIME", EBITDAacumulado, tval, 36 );
StringBuffer buf1 = new StringBuffer("EBITDA acumulado \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf1.append(Float.toString(tval));
buf1.append("\t");
}
buf1.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf1.append(Float.toString(EBITDAacumulado));
buf1.append("\t");
}
result=vensim.get_data("base","EBITDA acumulado[competidor1]","TIME",EBITDAacumulado,tval,36);
//se añade el valor actual en el campo de salida de abajo
tf5.setText(Float.toString(EBITDAacumulado[35]));
/******SALIDA DE LA VARIABLE INGRESOS POR OPERACIONES******/
tpoints = vensim.get_data( "base", "Ingresos operaciones[competidor1]", "TIME", ingresosop, tval, 36 );
StringBuffer buf2 = new StringBuffer("Ingresos operaciones \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf2.append(Float.toString(tval));
buf2.append("\t");
}
buf2.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf2.append(Float.toString(ingresosop));
buf2.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf2.toString());
result=vensim.get_data("base","ingresos operaciones[competidor1]","TIME",ingresosop,tval,36);
if (result == 0)
{
System.out.println( "get_val INGRESOS OPERACIOENS -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf6.setText(Float.toString(ingresosop[35]));
/******SALIDA DE LA VARIABLE GASTOS POR OPERACIONES******/
tpoints = vensim.get_data( "base", "gastos operaciones[competidor1]", "TIME", gastosop, tval, 36 );
StringBuffer buf3 = new StringBuffer("Gastos operaciones \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf3.append(Float.toString(tval));
buf3.append("\t");
}
buf3.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf3.append(Float.toString(gastosop));
buf3.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf3.toString());
result=vensim.get_data("base","gastos operaciones[competidor1]","TIME",gastosop,tval,36);
if (result == 0)
{
System.out.println( "get_val Gastos operacioens -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf7.setText(Float.toString(gastosop[35]));
/******SALIDA DE LA VARIABLE CUOTA FINAL REAL PRODUCTO1******/
tpoints = vensim.get_data( "base", "Cuota final real[producto1,competidor1]", "TIME", cuotafinalreal1, tval, 36 );
StringBuffer buf4 = new StringBuffer("CUOTA FINAL REAL PRODUCTO1 \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf4.append(Float.toString(tval));
buf4.append("\t");
}
buf4.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf4.append(Float.toString(cuotafinalreal1));
buf4.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf4.toString());
result=vensim.get_data("base","cuota final real[producto1,competidor1]","TIME",cuotafinalreal1,tval,36);
if (result == 0)
{
System.out.println( "get_val CUOTA FINAL REAL PRODUCTO 1 -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf8.setText(Float.toString(cuotafinalreal1[35]));
/******SALIDA DE LA VARIABLE CUOTA FINAL REAL PRODUCTO 2******/
tpoints = vensim.get_data( "base", "cuota final real[producto2,competidor1]", "TIME", cuotafinalreal2, tval, 36 );
StringBuffer buf5 = new StringBuffer("CUOTA FINAL REAL PRODUCTO2 \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf5.append(Float.toString(tval[i]));
buf5.append("\t");
}
buf5.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf5.append(Float.toString(cuotafinalreal2[i]));
buf5.append("\t");
}
buf5.append("\n");
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf5.toString());
result=vensim.get_data("base","cuota final real[producto2,competidor1]","TIME",cuotafinalreal2,tval,36);
if (result == 0)
{
System.out.println( "get_val CUOTA FINAL REAL 2 -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf9.setText(Float.toString(cuotafinalreal2[35]));
/******SALIDA DE LA VARIABLE INDICE HERFINDAHL******/
tpoints = vensim.get_data( "base", "Indice de Herfindahl", "TIME", indiceherfindahl, tval, 36 );
StringBuffer buf6 = new StringBuffer("Indice de Herfindahl \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf6.append(Float.toString(tval[i]));
buf6.append("\t");
}
buf6.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf6.append(Float.toString(indiceherfindahl[i]));
buf6.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf6.toString());
result=vensim.get_data("base","Indice de Herfindahl","TIME",indiceherfindahl,tval,36);
if (result == 0)
{
System.out.println( "get_val Indice de Herfindahl -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf10.setText(Float.toString(indiceherfindahl[35]));
/******SALIDA DE LA VARIABLE INDICE DE HERFINDAHL PRODUCTO1******/
tpoints = vensim.get_data( "base", "Indice de Herfindahl por productos [producto1]", "TIME", herfindahl1, tval, 36 );
StringBuffer buf7 = new StringBuffer("Indice de Herfindahl 1 \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf7.append(Float.toString(tval[i]));
buf7.append("\t");
}
buf7.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf7.append(Float.toString(herfindahl1[i]));
buf7.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf7.toString());
result=vensim.get_data("base","Indice de Herfindahl por productos[producto1]","TIME",herfindahl1,tval,36);
if (result == 0)
{
System.out.println( "get_val Indice de Herfindahl -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf11.setText(Float.toString(herfindahl1[35]));
/******SALIDA DE LA VARIABLE INDICE DE HERFINDAHL POR PRODUCTOS 2******/
tpoints = vensim.get_data( "base", "Indice de Herfindahl por productos [producto2]", "TIME", herfindahl2, tval, 36 );
StringBuffer buf8 = new StringBuffer("Indice de Herfindahl \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf8.append(Float.toString(tval[i]));
buf8.append("\t");
}
buf8.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf8.append(Float.toString(herfindahl2[i]));
buf8.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf8.toString());
result=vensim.get_data("base","Indice de Herfindahl por productos [producto2]","TIME",herfindahl2,tval,36);
if (result == 0)
{
System.out.println( "get_val Indice de Herfindahl 2 -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf12.setText(Float.toString(herfindahl2[35]));
}
Errors are:
SIMULATE>SETVAL|precios [producto2,competidor1]= 111.0 -- failed
SIMULATE>SETVAL|Gastos distribucion[competidor1]= 250.0 -- failed
SIMULATE>SETVAL|Gastos publicidad[competidor1]= 250.0 -- failed
SIMULATE>SETVAL|Compras almacen[producto1,competidor1]=55.0 -- failed
SIMULATE>SETVAL|Compras almacen[producto2,competidor1]=150.0 -- failed
SIMULATE>SETVAL|Salario medio[senior,competidor1]= 2200.0 -- failed
SIMULATE>SETVAL|Salario medio[junior, competidor1]= 890.0 -- failed
SIMULATE>SETVAL|Contratacion junior[competidor1]= 3.0 -- failed
Someone could help me?? thank you
if (e.getSource() == b2)
{
//set run name
result = vensim.command( "SIMULATE>RUNNAME|base" );
if (result == 0)
System.out.println( "SIMULATE>RUNNAME|base -- failed" );
//COGE EL VALOR DEL CAMPO cprecio1
PrecioInit1 = cprecio1.getText();
vensimCommand = "SIMULATE>SETVAL|precios [producto1,competidor1] = " + PrecioInit1;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|precio inicial = " + PrecioInit1 + " -- failed" );
//COGE EL VALOR DEL CAMPO cprecio2
PrecioInit2 = cprecio2.getText();
vensimCommand = "SIMULATE>SETVAL|precios [producto2,competidor1] = " + PrecioInit2;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|precios [producto2,competidor1]= " + PrecioInit2 + " -- failed" );
//COGE EL VALOR DEL CAMPO cdistribucion
DistribucionInit=cdistribucion.getText();
vensimCommand = "SIMULATE>SETVAL|Gastos distribucion[competidor1] = " + DistribucionInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Gastos distribucion[competidor1]= " + DistribucionInit + " -- failed" );
//COGE EL VALOR DEL CAMPO cpublicidad
PublicidadInit = cpublicidad.getText();
vensimCommand = "SIMULATE>SETVAL|Gastos publicidad[competidor1] = " + PublicidadInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Gastos publicidad[competidor1]= " + PublicidadInit + " -- failed" );
//COGE EL VALOR DEL CAMPO ccompras1
ComprasInit1 = ccompras1.getText();
vensimCommand = "SIMULATE>SETVAL|Compras almacen[producto1,competidor1] = " + ComprasInit1;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Compras almacen[producto1,competidor1]=" + ComprasInit1 + " -- failed" );
//COGE EL VALOR DEL CAMPO ccompras2
ComprasInit2 = ccompras2.getText();
vensimCommand = "SIMULATE>SETVAL|Compras almacen[producto2,competidor1] = " + ComprasInit2;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Compras almacen[producto2,competidor1]=" + ComprasInit2 + " -- failed" );
//COGE EL VALOR DEL CAMPO csalarios
SalarioSInit = csalarios.getText();
vensimCommand = "SIMULATE>SETVAL|Salario medio[senior,competidor1] = " + SalarioSInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Salario medio[senior,competidor1]= " + SalarioSInit + " -- failed" );
//COGE EL VALOR DEL CAMPO csalarioj (salario junior)
SalarioJInit = csalarioj.getText();
vensimCommand = "SIMULATE>SETVAL|Salario medio[junior,competidor1] = " + SalarioJInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Salario medio[junior, competidor1]= " + SalarioJInit + " -- failed" );
//COGE EL VALOR DEL CAMPOS ccontratacion
ContratacionInit = ccontratacion.getText();
vensimCommand = "SIMULATE>SETVAL|Contratacion junior[competidor1] = " + ContratacionInit;
result = vensim.command( vensimCommand );
if (result == 0)
System.out.println( "SIMULATE>SETVAL|Contratacion junior[competidor1]= " + ContratacionInit + " -- failed" );
//SIMULAMOS.....
result = vensim.command( "MENU>RUN|O" );
if (result == 0)
System.out.println( "MENU>RUN|O -- failed" );
/******SALIDA DE LA VARIABLE EBITDA PARA EL COMPETIDOR1******/
tpoints = vensim.get_data( "base", "EBITDA[competidor1]", "TIME", EBITDA, tval, 36 );
StringBuffer buf = new StringBuffer("EBITDA \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf.append(Float.toString(tval));
buf.append("\t");
}
buf.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf.append(Float.toString(EBITDA));
buf.append("\t");
}
//coge el valor de ebitda y lo pone en el campo de texto
result=vensim.get_data("base","EBITDA[competidor1]","TIME",EBITDA,tval,36);
//se añade el valor actual en el campo de salida de abajo
tf4.setText(Float.toString(EBITDA[35]));
/******SALIDA DE LA VARIABLE EBITDA ACUMULADO PARA EL COMPETIDOR1******/
tpoints = vensim.get_data( "base", "EBITDA acumulado[competidor1]", "TIME", EBITDAacumulado, tval, 36 );
StringBuffer buf1 = new StringBuffer("EBITDA acumulado \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf1.append(Float.toString(tval));
buf1.append("\t");
}
buf1.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf1.append(Float.toString(EBITDAacumulado));
buf1.append("\t");
}
result=vensim.get_data("base","EBITDA acumulado[competidor1]","TIME",EBITDAacumulado,tval,36);
//se añade el valor actual en el campo de salida de abajo
tf5.setText(Float.toString(EBITDAacumulado[35]));
/******SALIDA DE LA VARIABLE INGRESOS POR OPERACIONES******/
tpoints = vensim.get_data( "base", "Ingresos operaciones[competidor1]", "TIME", ingresosop, tval, 36 );
StringBuffer buf2 = new StringBuffer("Ingresos operaciones \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf2.append(Float.toString(tval));
buf2.append("\t");
}
buf2.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf2.append(Float.toString(ingresosop));
buf2.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf2.toString());
result=vensim.get_data("base","ingresos operaciones[competidor1]","TIME",ingresosop,tval,36);
if (result == 0)
{
System.out.println( "get_val INGRESOS OPERACIOENS -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf6.setText(Float.toString(ingresosop[35]));
/******SALIDA DE LA VARIABLE GASTOS POR OPERACIONES******/
tpoints = vensim.get_data( "base", "gastos operaciones[competidor1]", "TIME", gastosop, tval, 36 );
StringBuffer buf3 = new StringBuffer("Gastos operaciones \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf3.append(Float.toString(tval));
buf3.append("\t");
}
buf3.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf3.append(Float.toString(gastosop));
buf3.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf3.toString());
result=vensim.get_data("base","gastos operaciones[competidor1]","TIME",gastosop,tval,36);
if (result == 0)
{
System.out.println( "get_val Gastos operacioens -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf7.setText(Float.toString(gastosop[35]));
/******SALIDA DE LA VARIABLE CUOTA FINAL REAL PRODUCTO1******/
tpoints = vensim.get_data( "base", "Cuota final real[producto1,competidor1]", "TIME", cuotafinalreal1, tval, 36 );
StringBuffer buf4 = new StringBuffer("CUOTA FINAL REAL PRODUCTO1 \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf4.append(Float.toString(tval));
buf4.append("\t");
}
buf4.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf4.append(Float.toString(cuotafinalreal1));
buf4.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf4.toString());
result=vensim.get_data("base","cuota final real[producto1,competidor1]","TIME",cuotafinalreal1,tval,36);
if (result == 0)
{
System.out.println( "get_val CUOTA FINAL REAL PRODUCTO 1 -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf8.setText(Float.toString(cuotafinalreal1[35]));
/******SALIDA DE LA VARIABLE CUOTA FINAL REAL PRODUCTO 2******/
tpoints = vensim.get_data( "base", "cuota final real[producto2,competidor1]", "TIME", cuotafinalreal2, tval, 36 );
StringBuffer buf5 = new StringBuffer("CUOTA FINAL REAL PRODUCTO2 \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf5.append(Float.toString(tval[i]));
buf5.append("\t");
}
buf5.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf5.append(Float.toString(cuotafinalreal2[i]));
buf5.append("\t");
}
buf5.append("\n");
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf5.toString());
result=vensim.get_data("base","cuota final real[producto2,competidor1]","TIME",cuotafinalreal2,tval,36);
if (result == 0)
{
System.out.println( "get_val CUOTA FINAL REAL 2 -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf9.setText(Float.toString(cuotafinalreal2[35]));
/******SALIDA DE LA VARIABLE INDICE HERFINDAHL******/
tpoints = vensim.get_data( "base", "Indice de Herfindahl", "TIME", indiceherfindahl, tval, 36 );
StringBuffer buf6 = new StringBuffer("Indice de Herfindahl \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf6.append(Float.toString(tval[i]));
buf6.append("\t");
}
buf6.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf6.append(Float.toString(indiceherfindahl[i]));
buf6.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf6.toString());
result=vensim.get_data("base","Indice de Herfindahl","TIME",indiceherfindahl,tval,36);
if (result == 0)
{
System.out.println( "get_val Indice de Herfindahl -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf10.setText(Float.toString(indiceherfindahl[35]));
/******SALIDA DE LA VARIABLE INDICE DE HERFINDAHL PRODUCTO1******/
tpoints = vensim.get_data( "base", "Indice de Herfindahl por productos [producto1]", "TIME", herfindahl1, tval, 36 );
StringBuffer buf7 = new StringBuffer("Indice de Herfindahl 1 \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf7.append(Float.toString(tval[i]));
buf7.append("\t");
}
buf7.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf7.append(Float.toString(herfindahl1[i]));
buf7.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf7.toString());
result=vensim.get_data("base","Indice de Herfindahl por productos[producto1]","TIME",herfindahl1,tval,36);
if (result == 0)
{
System.out.println( "get_val Indice de Herfindahl -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf11.setText(Float.toString(herfindahl1[35]));
/******SALIDA DE LA VARIABLE INDICE DE HERFINDAHL POR PRODUCTOS 2******/
tpoints = vensim.get_data( "base", "Indice de Herfindahl por productos [producto2]", "TIME", herfindahl2, tval, 36 );
StringBuffer buf8 = new StringBuffer("Indice de Herfindahl \n");
//se van insertando los datos en el array tval
for (int i = 0; i < tpoints; i++)
{
buf8.append(Float.toString(tval[i]));
buf8.append("\t");
}
buf8.append("\n");
for (int i = 0; i < tpoints; i++)
{
buf8.append(Float.toString(herfindahl2[i]));
buf8.append("\t");
}
//escribimos el stringbuffer en el campo grande de texto
ta1.setText(buf8.toString());
result=vensim.get_data("base","Indice de Herfindahl por productos [producto2]","TIME",herfindahl2,tval,36);
if (result == 0)
{
System.out.println( "get_val Indice de Herfindahl 2 -- failed" );
}
//se añade el valor actual en el campo de salida de abajo
tf12.setText(Float.toString(herfindahl2[35]));
}
Errors are:
SIMULATE>SETVAL|precios [producto2,competidor1]= 111.0 -- failed
SIMULATE>SETVAL|Gastos distribucion[competidor1]= 250.0 -- failed
SIMULATE>SETVAL|Gastos publicidad[competidor1]= 250.0 -- failed
SIMULATE>SETVAL|Compras almacen[producto1,competidor1]=55.0 -- failed
SIMULATE>SETVAL|Compras almacen[producto2,competidor1]=150.0 -- failed
SIMULATE>SETVAL|Salario medio[senior,competidor1]= 2200.0 -- failed
SIMULATE>SETVAL|Salario medio[junior, competidor1]= 890.0 -- failed
SIMULATE>SETVAL|Contratacion junior[competidor1]= 3.0 -- failed
Someone could help me?? thank you
-
- Super Administrator
- Posts: 4838
- Joined: Wed Mar 05, 2003 3:10 am
SETVAL not work for me because I got there just in another place like
PrecioInit1 = cprecio1.getText();
vensimCommand = "SIMULATE>SETVAL|precios [producto1,competidor1] = " + PrecioInit1;
result = vensim.command( vensimCommand );
and if that work for me.
The variables exist in the model
I want to do is pick up the initial values of these variables and put them in the fields inputs
Thank you
PrecioInit1 = cprecio1.getText();
vensimCommand = "SIMULATE>SETVAL|precios [producto1,competidor1] = " + PrecioInit1;
result = vensim.command( vensimCommand );
and if that work for me.
The variables exist in the model
I want to do is pick up the initial values of these variables and put them in the fields inputs
Thank you
-
- Super Administrator
- Posts: 4838
- Joined: Wed Mar 05, 2003 3:10 am