Items tagged with optimization optimization Tagged Items Feed


I would like to know how to do the following. If I received a plot of a graph, but I did not know it function, how could I get an accurate value for its maximum and minum points? Any help is greatly appreciated! Thank you in advance!

Kind regards,

Gambia Man


how to solve lp  on maple when consrtaints are in interval 



 i try to find this on maple,but i could not found my desired ans.

i got an assignment in which 15 constraints are given and all are in interval.

anyone know the ans then plz help me

Hi all,

I have been trying to plot Riemann Zeta Function on certain range, but it takes a lot of time(several minutes ,maybe hours).These are the basic things.

How to speed up ploting Zeta?

The same problem with Optimization.

Mathematica don't have this such problems.

Mathematica ploting Zeta with 0.125 second and optimizing 3.42 second.Maple few hours maybe......





I ues the optimization tool in Maple2015.

In my experience, Maple optimizatiom tool just shows the optimum values, not a history of the optimizatiom process.

I want to know how I can obtain the history of the optimization process, such as values of the objective, constraints, and tolerance at every iteration.

Is there anyone who knows how to obtain the history data of the optimization process?


Hi, i got a litlle problem with fromats, i m realy bad at this.
i got procedure 'getone(z::list)' i was execute it like this  
>getone([seq(lineP[i], i = 1 .. pm)]::list)
where lineP is 

>pm := 3;
>rollx := rand(98.0 .. 102.0); rolly := rand(-1.0 .. 5);
>rolll := rand(.5 .. 1.0); rollf := rand(0. .. evalf(2*Pi));
>rollm := rand(0. .. 20.0);

>for i to pm do lineP[i] := [rollx(), rolly(), rolll(), rollf(), rollm()] end do;

it's pm times of z:=[rollx(), rolly(), rolll(), rollf(), rollm()] ::list

and i need make optimization work for any pm=1..100; with rabdomly generated iteration point as above.

The main queston is how make minimize as below
Minimize(z,variables=[z],   initialpoint={z=[seq(lineP[i], i = 1 .. pm)]},iterationlimit=1000,optimalitytolerance=0.01)

work with z::list kind of 

[[100.7798614, 1.109653266, 0.9840371500, 4.257816686, 9.737110573][100.0135459, 0.887539481, 0.9144164697, 3.980093624, 7.343851161][100.0661308, 3.724268229, 0.5020544909, 2.052134822, 14.37408543]]


Portfolio Optimization with Google Spreadsheet and Maple

I will in this post show how to manage data and do portfolio optimization in Maple by using google spreadsheet.

You can either use a direct link to the data:

or you can set up your own google spreadsheet. If you choice to set up your own spreedsheet follow the below road map:

1) select which market you want to follow:




2) Create a new google spreadsheet and name two sheets Blad1 and Panel. In the first cell of Blad1 you put the formula:


you need to change the url to match your selection in 1).

3) In the first cell of Panel you put the name "Ticker" and then you copy all the ticker names from Blad1.

4) In the script editor you put in the below java script code:

function PanelCreation_Stock() 

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = ss.getSheetByName("Blad1");
var dstSheet = ss.getSheetByName("Panel");
var curDat = new Date();
var day1 = curDat.getDay();
if(day1 == 0 || day1 == 1)
var lCol = dstSheet.getLastColumn();
var srcdate = dstSheet.getRange(1, 1, 1, lCol).getValues();

for(var k=1;k<=srcdate[0].length-1;k++)
if(Utilities.formatDate(srcdate[0][k],"GMT", "dd-MMM-yy") == Utilities.formatDate(curDat,"GMT", "dd-MMM-yy"))
var snRows = sourceSheet.getLastRow();
var dnRows = dstSheet.getLastRow();

var srcStock = sourceSheet.getRange("A2:A" + snRows).getValues();
var srcLastSale = sourceSheet.getRange("C2:C" + snRows).getValues();

var dstStock = dstSheet.getRange("A2:A" + dnRows).getValues();
var dstLastSale = dstSheet.getRange("Z2:Z" + dnRows).getValues();

for(var j=0;j<dnRows-1;j++)
var flag = "true";
var foundStock;
for(var i=0;i<snRows-1;i++) //snRows
var sStockVal = srcStock[i][0];

//var foundStock = ArrayLib.indexOf(dstStock,0, sStockVal);

for(var j=0;j<dnRows-1;j++)
if(dstStock[j][0].toString().toUpperCase() == srcStock[i][0].toString().toUpperCase())
flag = "true";
foundStock = j;
dstLastSale[foundStock][0] = srcLastSale[i][0];
var dnRows1 = dstSheet.getLastRow()+1;
dstSheet.getRange("A" + dnRows1).setValue(srcStock[i][0]);
for(var k=2;k<=lCol;k++)
if(dstSheet.getRange(dnRows1, k).getValue()=="")
dstSheet.getRange(dnRows1, k).setValue("n/a");
dstSheet.getRange(2, lCol+1, dstLastSale.length, 1).setValues(dstLastSale);

5) Set it to run each day at 12:00. The code will save the new last sale price for monday to friday with one days lag.

Now we can move on to Maple.

In Maple run the following code to load the data:


X := proc (Url) local theDLL, URLDownloadToFile, myDirectory, myFile, Destination, DL;


theDLL := "C:\\WINDOWS\\SYSTEM32\\urlmon.dll";


URLDownloadToFile := define_external('URLDownloadToFileA', pCaller::(integer[4]), szURL::string, szFileName::string, dwReserved::(integer[4]), lpfnCB::(integer[4]), 'RETURN'::(integer[4]), LIB = theDLL);


if FileTools[Exists]("C:\\mydir") = true then FileTools:-RemoveDirectory("C:\\mydir", recurse = true, forceremove = true) else end if;


myDirectory := "C:\\mydir";
myFile := "data1.csv";
Destination := cat(myDirectory, "\\", myFile);


DL := proc () local M;


URLDownloadToFile(0, Url, Destination, 0, 0);
M := ImportMatrix("C:\\mydir\\data1.csv", delimiter = ",", datatype = string);
M := Matrix(M, datatype = anything)


end proc;


return DL()


end proc:


data := X("");
L := LinearAlgebra:-Transpose(data);

If you use your own spreadsheet you need to change the url to match that spreadsheet.
Select File -> Publish to the web in google spreadsheet

We can now run the portfolio optimization in Maple:



Nr, Nc := ArrayTools:-Size(L):
symb := L[1 .. 1, 2 .. Nc]:
LL := L[2 .. Nr, 2 .. Nc]:
Nr, Nc := ArrayTools:-Size(LL):


# Removing stocks with missing observations
for i to Nc do if Occurrences("n/a", convert(Column(LL, i), list)) >= 1 then AA[i] := i else AA[i] := 0 end if
end do;


DD := RemoveInRange([seq(AA[i], i = 1 .. Nc)], 0 .. 1):
symbb := DeleteColumn(symb, DD):
LLL := map(parse, DeleteColumn(LL, DD)):
Nr, Nc := ArrayTools:-Size(LLL):


# Calculate Return
for j to Nc do
for i from 2 to Nr do


r[i, j] := (LLL[i, j]-LLL[i-1, j])/LLL[i-1, j]


end do
end do;


RR := Matrix([seq([seq(r[i, j], j = 1 .. Nc)], i = 2 .. Nr)], datatype = float[8]);
n, nstock := ArrayTools:-Size(RR):


# Portfolio Optimization
W := Vector(nstock, symbol = w):
y := Vector(n, fill = 2, datatype = float[8]):
s1 := Optimization[LSSolve]([y, RR])[2];
Nr, Nc := ArrayTools:-Size(s1):


j := 0:
for i to Nr do if s1[i] <> 0 then j := j+1; ss1[j] := symbb[1, i] = s1[i] end if end do;


Vector(j, proc (i) options operator, arrow; ss1[i] end proc);




Hello everybody,

I am new on this forum, and please to join your community.
As part of a project related to Origami, I try to follow the paper entitled "Mathematical Approach to Model Foldable Conical Structures Using Conformal Mapping", in order to flat-fold a conical structure.

As described in the paper a non-linear system need to be solved in order to get a corrected angle beta... The paper advize the use of "fsolve" function in Matlab, but I did not manage to do it... So I tried with Maple, but I get an error using NLPSolve, and I do not understand why...

Here is the edited, withdrawn and finally back file :

Do not hesitate to ask for any other explanations.

Any help is going to be appreciated.


How to find the maximum natural number n s. t. the sum of its cubed digits is greater than or equal to n? Of course, with Maple. The same question for the sum of the  digits to k-th power. Here are my unsuccessful attempts:
1.Optimization:-Maximize(n, {n <= convert(map(c ->c^3, convert(n, base, 10)), `+`)}, assume = integer);

Error, invalid input: `convert/base` expects its 1st argument, n, to be of type {integer, list(integer)}, but received n

2. for n while n <= convert(map(c ->c^3, convert(n, base, 10)), `+`) do print(n) end do;


Hi all,

Hope all to be in good health.

I have written following program to obtain minimum  under som constraints but it doesn't work due to some unknown error.

can any one help me?



best wishes

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department

This problem has real world applicability: Three vampires and three maidens are at the foot of a tall building and wish to get to the bar on the top floor.  The lift only holds two people (for convenience I am classing vampires as people), and needs one person to operate it.  If ever the vampires outnumber the maidens at any place, they will do something unspeakable.  How can the vampires and maidens all safety get to the top in the minimum of moves?

can this be solved procedurally or using optimization package?

possible manual soln:

No. m>= No. v

3m+3v, 0   [0]

2m+2v,m+v [1]

3m+2v,v  [2]

     3m, 3v [3]

3m+v , 2v  [4]

m+v  , 2m+2v [5]

#then reverse the steps

2m+2v, m+v [6]

       2v, 3m+v [7]

       3v, 3m  [8]

        v , 3m+2v [9]

    m+v, 2m+2v [10]

        0, 3m+3v [11]


What is the right syntax to solve :

min {sum(i=1 to 10) sum(j=1..10) (a_i_j)*(x_i)*(x_j) 

s.t sum(i=1..n) (b_i)*x_i=p and sum(i=1..n)x_i=1 

if a_i_j is a constant, b_i is a constant, p is a constant and x_i, x+j are the decision variables?

I understand that this is a quadratic programming problem and an application of Markowitz optimization. I've tried to use the in-built minimize function but haven't got the right output.

Please see attached document.


The 2 bits of data I am working with are a Constraint Function and Objective Function:



I need some pointers on how to do this. I keep getting solutions of

and I am ont receving an x value for some reason and leaving me unable to continue with the problem.

If anyone can send me some code I would be grateful. If anyone would like to send the correct full working code so I can see how to do this and review it I would be grateful.


 Code I had so far was:





I am trying to optimize a 39, 1 MATLAB matrix, but cannot seem to get a result beyond a 6, 1 matrix. I am getting "Warning, cannot resolve types, reassigning t##'s type" where t## varies from each time I run it, and can show multiple of these warnings. It also says "Warning, cannot translate list".


I found a pretty similar problem posted here earlier, where the user "Carl Love" suggested to replace a command from the original code with

     subsop([-1,1]= J, eval([codegen:-optimize](tmp, tryhard), pow= `^`)),
     output = string, defaulttype = numeric


I was wondering what exactly this command does? Can I apply it to my code to solve my problem? It yielded a result that looks (on the surface) as an optimized code, but I don't feel completely comfortable using it without being certain.

What I have done is simply to replace Matlab(tmp, optimize) with the suggested code above. My code is attached. Thanks in advance for any help.

Hello maple users,

I have 2 functions and each functions has 8 variables. I run a matlab code and get outputs for different values of these variables. I assumed 3 of them as constant because the combinations are too many. Anyway, I plot the results and I can see that one function is much better than the other. But I need to compare these functions mathematically. I need to show some proofs. Has anyone any idea what should I do? I wrote the functions on maple and take derivative with respect to one variable and try to see the reaction of the functions to that variable. i am confused.




I've got

f(x,y)= a.exp(1+xy) +( a^2 )*sin(x)+1

for which I've shown that there exists an implicit function x=g(y). ( df/dx <>0)

and df/dx = a*exp(1+xy) +( a^2 )*cosx now in the neighborhood of P=(0,0) for the implicit function to exist I'd need a*exp(1+xy)*y <>0 but at P, wouldn't this be 0?

Given, g(y)=x, how do I find the max,min,saddle points?

1 2 3 4 5 6 7 Last Page 1 of 13