empty files initialized as zeroes

22 views
Skip to first unread message

Samuele Viaro

unread,
Jul 5, 2022, 3:56:54 PM7/5/22
to AMPL Modeling Language
Hello! I am trying to initialize a parameter in C++ with the following code

ampl::Parameter P_yBin = ampl.getParameter("yBin");

  /**
     Initialize vector yBin of zeros
  */
  int count = 0;
  for (auto i : P_yBin)
    {
      count++;
    }
  double values[count];
  for(int i_i = 0; i_i<count; i_i++)
    {
      values[i_i]=0.0;
    }
  P_yBin.setValues(values,count);

however, when I display the parameter, it is empty!! It will not be empty if I set this parameter with a number different than 0. Is this normal? I would like to use yBin as boolean, initializing the parameter as zeroes and than change it to ones when necessary. Does anyone have any suggestions?
Thanks
Sam

AMPL Google Group

unread,
Jul 6, 2022, 3:12:49 PM7/6/22
to AMPL Modeling Language
We are not able to reproduce the issue. The following program:

ampl::AMPL ampl;
ampl.eval("param yBin{1..10};");

ampl::Parameter P_yBin = ampl.getParameter("yBin");
int count = 0;
for (auto i : P_yBin)
{
count++;
}
double values[count];
for (int i_i = 0; i_i < count; i_i++)

{
values[i_i] = 0.0;
}
P_yBin.setValues(values, count);
ampl.eval("display yBin;");

produces the following output:

yBin [*] :=
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
;

Which version of the API are you using?


--
Filipe Brandão
am...@googlegroups.com
{#HS:1940632544-110854#}
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/82cb8804-e2c6-4a9d-8dae-4e43221ccce1n%40googlegroups.com.

Samuele Viaro

unread,
Jul 8, 2022, 2:43:42 AM7/8/22
to am...@googlegroups.com
Hello!
Thanks for the reply!
Where can I find the API version?

You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/fwExmjo925c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1940632544-5751608449-1657134765-872529468%40helpscout.net.

AMPL Google Group

unread,
Jul 8, 2022, 3:13:54 AM7/8/22
to AMPL Modeling Language
Inside amplapi/lib you should find a file named amplapi-version.lib/.dylib/.so (e.g., ampl-2.0.8.3.lib means version 2.0.8.3) depending on the platform.

What is the output for you using the code from the previous email?


--
Filipe Brandão
am...@googlegroups.com
{#HS:1940632544-110854#}
On Fri, Jul 8, 2022 at 6:43 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hello!

Thanks for the reply!
Where can I find the API version?

Samuele Viaro

unread,
Jul 9, 2022, 3:50:28 PM7/9/22
to am...@googlegroups.com
I only have this file:   ampl-2.0.6.0.jar   is this what you mean??
This is the output of my code:
yBin [*] :=
;

Thanks

You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/fwExmjo925c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1940632544-5756714732-1657264431-263439531%40helpscout.net.

AMPL Google Group

unread,
Jul 11, 2022, 9:26:45 AM7/11/22
to AMPL Modeling Language
Version 2.0.6 is quite old and that examples does not work there due to a bug that existed at the time. Could you please updated to the latest version version (you can downloaded it using the links at https://dev.ampl.com/en/latest/apis.html#id4)?


--
Filipe Brandão
am...@googlegroups.com
{#HS:1940632544-110854#}
On Sat, Jul 9, 2022 at 7:50 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
I only have this file: ampl-2.0.6.0.jar is this what you mean??
This is the output of my code:
yBin [*] :=
;

Thanks

On Fri, Jul 8, 2022 at 7:13 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Inside amplapi/lib you should find a file named amplapi-version.lib/.dylib/.so (e.g., ampl-2.0.8.3.lib means version 2.0.8.3) depending on the platform.

What is the output for you using the code from the previous email?


--
Filipe Brandão
am...@googlegroups.com

Samuele Viaro

unread,
Jul 13, 2022, 2:44:29 AM7/13/22
to am...@googlegroups.com
It worked!!
Thank you very much for your help!! 🙏☺

You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/fwExmjo925c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1940632544-5763355008-1657546001-2103279902%40helpscout.net.
Reply all
Reply to author
Forward
0 new messages