# Problem Description

Here we have a function depending on two variables. It was designed with the aim of checking the solutions through LS-OPT. These variables x and y are in the range of [-1,3]. Within that range we attempt to obtain the optima. In order to provide a solver for this function that can be used in LS-OPT we will write a little script in Perl. The function we attempt to solve is defined as follows:

`f = sin(4x)-2x + x ^ 2 + sin(4y)-2y + y ^ 2.`

### Design Formulation

The objective is to minimize the function f. And we will do this using LS-OPT as follows:
The first we do is to write the script in perl, which will be our input and perl will be the solver:

Since the perl script is going to be the input for the solver, we have to parametrize the script. The parameters are placed between `“<<”` and `“>>”`. LS-OPT is going to replace everything in between these markers with numbers where it wants to obtain discrete solutions of our function.

You can see how this is done in line 2 and 3 of the script. Within the markers you have to tell LS-OPT how the variable will be named and how many digits LS-OPT has to use to fill in the variable.

Attention!: since the `“\$”` is the common character in LS-DYNA files for comment lines LS-OPT will ignore each line starting with a `“\$”` therefore we placed a “ “ before that variable definitions. This way LS-OPT will not ignore that lines and recognize the variables.

After we calculated the result it will be written to a text file called out.txt. This file will later be evaluated by LS-OPT in order to obtain the response of the solver. At the end of the script we have to output `“N o r m a l”` to stdout. This will signal LS-OPT that everything went alright within the solver. If for some reason the solution of the function could not be calculated we'd have to output `“E r r o r”` at the end of our script.

```#!/usr/bin/perl
\$x=<<X:10>>;
\$y=<<Y:10>>;
\$f=sin(4*\$x)-2*\$x+\$x**2+sin(4*\$y)-2*\$y+\$y**2;

open(FILE,'>out.txt');
print FILE "\$f\n";
close FILE;
print "N o r m a l\n"; ```