« Previous « Start » Next »
10 GLC Problem
The
global mixed-integer nonlinear programming (
glc)
problem is defined as
|
|
f(x) |
|
|
s/t |
−∞ < |
xL |
≤ |
x |
≤ |
xU |
< ∞ |
|
bL |
≤ |
A x |
≤ |
bU |
|
|
cL |
≤ |
c(x) |
≤ |
cU, |
xj N j I, |
|
|
(12) |
where
x,
xL,
xU Rn,
f(
x)
R,
A
Rm1 × n,
bL,
bU Rm1
and
cL,
c(
x),
cU Rm2. The variables
x I,
the index subset of 1,...,
n, are restricted to be integers.
The following file defines a test problem in TOMNET.
using System;
using TOMNET;
namespace TOMNET
{
/// <summary>
/// Quick guide class for (glc) programming.
/// </summary>
public static class glcQG
{
/// <summary>
/// Computes function value for Hock-Schittkowski 59.
/// </summary>
private class glcQG_f : IFunction
{
//
// Constants used by objective function
//
public double[] u = new double[19]
{75.196, 3.8112, 0.0020567, 1.0345E-5,
6.8306, 0.030234, 1.28134E-3, 2.266E-7,
0.25645, 0.0034604, 1.3514E-5, 28.106,
5.2375E-6, 6.3E-8, 7E-10, 3.405E-4,
1.6638E-6, 2.8673, 3.5256E-5};
/// <summary>
/// Objective function.
/// </summary>
/// <param name="f">Value of the objective function.</param>
/// <param name="x">The decision variables.</param>
public void Evaluate(double[] f, double[] x)
{
f[0] = -u[0] + u[1] * x[0] +
u[2] * Math.Pow(x[0], 3)- u[3] * Math.Pow(x[0], 4) +
u[4] * x[1] - u[5] * x[0] * x[1] +
u[6] * x[1] * Math.Pow(x[0], 2) +
u[7] * Math.Pow(x[0], 4) * x[1] -
u[8] * Math.Pow(x[1], 2) + u[9] * Math.Pow(x[1], 3) -
u[10] * Math.Pow(x[1], 4) + u[11] / (x[1] + 1) +
u[12] * Math.Pow(x[0], 2) * Math.Pow(x[1], 2) +
u[13] * Math.Pow(x[0], 3) * Math.Pow(x[1], 2) -
u[14] * Math.Pow(x[0], 3) * Math.Pow(x[1], 3) +
u[17] * Math.Exp(0.0005 * x[0] * x[1]) -
u[18] * Math.Pow(x[0], 3) * x[1] -
u[15] * x[0] * Math.Pow(x[1], 2) +
u[16] * x[0] * Math.Pow(x[1], 3) -
0.12694 * Math.Pow(x[0], 2);
}
}
/// <summary>
/// Computes constraints for Hock-Schittkowski 59.
/// </summary>
private class glcQG_c : IDConstraints
{
/// <summary>
/// Nonlinear constraints evaluation.
/// </summary>
/// <param name="cx">
/// Values of the nonlinear constraints.
/// </param>
/// <param name="x">The decision variables.</param>
public void Evaluate(double[] cx, double[] x)
{
cx[0] = x[0] * x[1] - 700;
cx[1] = x[1] - Math.Pow(x[0], 2) / 125;
cx[2] = Math.Pow(x[1] - 50, 2) - 5 * (x[0] - 55);
}
/// <summary>
/// Nonlinear constraints evaluation,
/// alternative implementation
/// </summary>
/// <param name="x">The decision variables.</param>
/// <returns>Values of the nonlinear constraints.</returns>
public double[] Evaluate(double[] x)
{
double[] cx = new double[3];
this.Evaluate(cx, x);
return cx;
}
/// <summary>
/// Constraint Jacobian evaluation.
/// </summary>
/// <param name="Jac">Values of the constraint Jacobian.</param>
/// <param name="x">The decision variables.</param>
public void dc(Jacobian Jac, double[] x)
{
Jac[0,0] = x[1];
Jac[0,1] = x[0];
Jac[1,0] = 1;
Jac[1,1] = x[0] / 62.5;
Jac[2,0] = -5;
Jac[2,1] = 2 * x[1] - 100;
}
}
/// <summary>
/// Creates and returns a glcProblem.
/// </summary>
/// <returns>
/// glcProblem
/// </returns>
public static ConProblem getglcQG()
{
//
// Problem Name.
//
string Name = "glcQG";
//
// Number of decision variables and nonlinear constraints
//
const int N = 2;
const int mNonLin = 3;
//
// For use in bounds.
//
double inf = double.PositiveInfinity;
//
// Lower and upper bounds for decision variables as well
// as the starting point for the solver.
//
double[] x_0 = new double[N] { 10, 50 };
double[] x_L = new double[2] { 0, 0 };
double[] x_U = new double[2] { 75, 65};
//
// Lower and upper bounds for nonlinear constraints.
//
double[] c_L = new double[mNonLin] {0, 0, 0};
double[] c_U = new double[mNonLin] {inf, inf, inf};
//
// Information about Optimum.
//
double[] x_opt = new double[N] { 13.55010424, 51.66018129 };
double[] f_opt = new double[1] { -7.804226324 };
double f_Low = -20.0;
//
// Instances of objective function and nonlinear constraints
//
glcQG_f F = new glcQG_f();
glcQG_c C = new glcQG_c();
//
// Creating an instance of the problem
//
ConProblem Prob = new ConProblem(F, C, c_L, c_U, x_L, x_U, x_0,
Name, f_Low, f_opt, x_opt);
return Prob;
}
/// <summary>
/// Testprogram for glcQG.
/// </summary>
static void Main()
{
//
// Create a problem, solver and result instance.
//
ConProblem Prob = getglcQG();
SNOPT solver = new SNOPT();
Result result;
//
// Define a print file for SNOPT
//
string printfilename = "SnoptGlcQG.txt";
solver.Options.PrintFile = printfilename;
//
// Solve the problem
//
solver.Solve(Prob, out result);
//
// Get the solution results
//
double[] solution = result.x_k;
double objective = result.f_k;
// Display the solution on the screen
Console.WriteLine(" * * * * * * * *");
Console.WriteLine(" * Solved a glcProblem");
Console.WriteLine(" * Printfile: " + printfilename);
Console.WriteLine(" * Objective: {0,10:F6}", objective);
Console.WriteLine(" * Solution");
Console.WriteLine(" x_L[i] <= x_k[i] <= x_U[i]");
for (int i = 0; i < Prob.N; i++)
{
Console.WriteLine(" {0,10:F6} <= {1,10:F6} <= {2,10:F6} ",
Prob.x_L[i], solution[i], Prob.x_U[i]);
}
//
// Get the solution results for nonlinear constraints
//
double[] cx = new double[Prob.mNonLin];
Prob.c(cx, result.x_k);
//
// Display the solution on the console.
//
Console.WriteLine(" * Constraints");
Console.WriteLine(" c_L[i] <= cx[i] <= c_U[i]");
for (int i = 0; i < Prob.mNonLin; i++)
{
Console.WriteLine(" {0,10:F6} <= {1,10:F6} <= {2,10:F6} ",
Prob.c_L[i], cx[i], Prob.c_U[i]);
}
}
}
}
Only the objective function and nonlinear constraints are given for
this problem type.
f: Function
c: Constraints
The following picture illustrates the output displayed:
« Previous « Start » Next »