Cycle Replace Operation in Problem Statement

Replace Cycle operation solves several problems by replacing several strings in the initial problem statement string by new sets of strings.

Syntax

 

for [sets_of_strings]

[problem_statement_string]

end for

 

Sets of strings sets_of_strings :

 

{dsstr1; dsstr2; …; dsstrN} = {asstr1_1; asstr1_2; …; asstr1_N1 },{asstr2_1; asstr2_2; …; asstr2_N2},…,{asstrK_1; asstrK_2; …, asstrK_NK},

where

{dsstr1; dsstr2; …; dsstrN} = initial set of strings replaced by a new set of strings;

{asstr1_1; asstr1_2; …; asstr1_N1}= new set of strings at the first step of cycle;

{asstr2_1; asstr2_2; …; asstr2_N2}= new set of strings at the second step of cycle;

.......................................................................................................

{asstrK_1; asstrK_2; …; asstrK_NK}= new set of strings at the last step of cycle.

 

Sets of strings are replaced in the problem_statement_string .

 

Description

 

At the first step of the cycle a set of strings {dsstr1; dsstr2; …; dsstrN} in the initial problem_statement_string are replaced by corresponding strings {asstr1_1; asstr1_2; …;asstr1_N1}. First, string dsstr1 is replaced by string asstr1_1 in problem_statement_string. Then, string dsstr2 is replaced by string asstr1_2 in problem_statement_string. And so on.

 

At the second step of the cycle a set of strings {dsstr1; dsstr2; …; dsstrN} in the initial problem_statement_string are replaced by corresponding strings {asstr2_1; asstr2_2; …; asstr2_N2}. And so on.

 

Thus the cycle performs K steps.

 

Number of substrings N1, N2,…, NK in every set may be different but can’t be greater than N. During contextual replacement actual substrings with the number greater than N are ignored.

 

         Examples

for {#S;#T;#L}={VAN;1e6;1},{CAR;10;2}

  for {#U;#P;#M}={15;5;1},{16;7;2}

    for {#G;#N}={10;1},{20;2}

     Problem: problem_Auto_meansquare_cardinality_#L#M#N, type = minimize

     Objective: objective_AutoMPG

     meansquare_scenarios(matrix_scenarios_auto)

     Constraint: constraint_cardn_new, upper_bound = #U

     cardn_new(1e-6, matrix_a)

     Box_of_Variables:

     Solver: #S, precision = #P, stages = #G, timelimit = #T

    end for

  end for

end for

 

The problem includes three nested cycles. The outer loop modifies parameters of solver, time limit and inserts number 1 and 2 in place of #L. The middle loop modifies parameters of upper bound of constraint, precision and inserts numbers 1 and 2 in place of #M. Inner loop modifies parameters of a number of stages and inserts numbers 1 and 2 in place of #N.

 

As a result of running of this file 8 problems are solved. Every problem has its unique name specified by the number generated instead of the string  “#L#M#N”

 

These problems differ one from another by parameters of solver, time limit, precision,  bound and number of stages.

 

Such running generates 25 output files: 3 files for every problem (individual problem statements, solution files and optimal point files. For example, the first modification generates the following output files:

-problem_auto_meansquare_cardinality_111.txt;
-solution_problem_auto_meansquare_cardinality_111.txt;
-point_problem_auto_meansquare_cardinality_111.txt.

Additionally the following common for all 8 problems file containing errors descriptions is generated: error_problem_cyles_tst.txt.

See also

Replace Operation in Problem Statement