Optaplanner benchmarking with Quarkus - benchmarking

I want to do the advanced benchmarking with Quarkus Optaplanner app. What is the best way to implement and run it?
When going through "old" examples for Optaplanner they all have benchmarking implemented (in this video, there is a presentation about Optaplanner with Quarkus but benchmarking is shown with older examples). I built my optimization solver with Quarkus and I'm wondering how to implement benchmarking here. My input data is written in a JSON file and I would like to try different solver configurations.

This is missing feature, we're working on it, so you can just drop a benchmarkConfig.xml file in src/test/resources probably, without any entityClass etc information - or even without a config xml file at all - and just works.
Jira ticket
Pull request
It will land in 8.5 or 8.6 I believe.
Workaround
Meanwhile, this works:
// This needs to be in src/main/java, because src/test/java doesn't work
// TODO move this to src/test/java after https://issues.redhat.com/browse/PLANNER-2341
#QuarkusMain(name = "benchmark")
public class VaccinationScheduleBenchmark implements QuarkusApplication {
public static void main(String[] args) {
Quarkus.run(VaccinationScheduleBenchmark.class, args);
}
#Inject
ObjectMapper objectMapper;
#Override
public int run(String... args) {
generateDemoFile(5, 25, 0.0);
generateDemoFile(10, 50, 0.0);
generateDemoFile(10, 50, 0.3);
generateDemoFile(25, 500, 0.0);
generateDemoFile(50, 2000, 0.0);
generateDemoFile(50, 2000, 0.3);
// The solverBenchmarkConfig.xml explicitly mentions the entityClass, etc :(
PlannerBenchmarkFactory benchmarkFactory = PlannerBenchmarkFactory.createFromXmlResource("solverBenchmarkConfig.xml");
benchmarkFactory.buildPlannerBenchmark()
.benchmarkAndShowReportInBrowser();
return 0;
}
private void generateDemoFile(int vaccinationCenterCount, int totalBoothCount, double pinnedAppointmentRatio) {
File file = new File("local/input/" + vaccinationCenterCount + "vc-" + totalBoothCount + "booths"
+ (pinnedAppointmentRatio > 0.0 ? "-" + pinnedAppointmentRatio + "pinned" : "") + ".json");
if (!file.exists()) {
DemoDataGenerator demoDataGenerator = new DemoDataGenerator(33.40, 34.10, -84.90, -83.90);
VaccinationSchedule schedule = demoDataGenerator.generate(vaccinationCenterCount, totalBoothCount, pinnedAppointmentRatio);
try {
objectMapper.writeValue(file, schedule);
} catch (IOException e) {
throw new IllegalArgumentException("Failed writing file (" + file + ").", e);
}
}
}
}

Related

NeuroPh Error won't diminish

I am creating a network for water level forecasting. I am using NeuroPh 2.91 for windows. I set the network to 3 inputs since it is accepting 3 inputs namely water level, rainfall, and inflow. I am using multi-layer perceptron, tanh as transfer function and backpropagation as learning rule with 9 hidden neurons.
I am always having this output:
Starting neural network training...
Training network try using data set adminshet
Training error: null
and the total network error according to the graph is 20,000+ .
What should i do? I am really new to ANN and Neuroph.
I've had the same issue here. Similar setup. It works for me, whe I strongly limit the Max-Iterations. e.g. to 10.
This makes me think, that there is a bug in the NeurophStudio.
Short Tip, which worked for me:
Do it yourself! Open Eclipse, add a Project, add the Neuroph jars and build your network. Its hard, but this works exactly as expected. You have to dump your own results into a csv file and display it with Excel. But ANN-handling doesn't work just by "clicking on a gui".
package de.sauer.dispe;
import org.neuroph.core.Layer;
import org.neuroph.core.NeuralNetwork;
import org.neuroph.core.Neuron;
import org.neuroph.core.data.DataSet;
import org.neuroph.core.transfer.Linear;
import org.neuroph.core.transfer.Tanh;
import org.neuroph.nnet.MultiLayerPerceptron;
import org.neuroph.nnet.learning.BackPropagation;
public class DirSpeCntrl {
private static final int MAX_ITER = 2000;
private static final double MAX_ERROR = 0.005;
private static final double LEARNING_RATE = 0.1;
public static void main(String[] args) {
System.out.println("Create ANN");
NeuralNetwork<BackPropagation> nn = new MultiLayerPerceptron(3, 15, 15, 1);
// Setting ALL neurons to TanH transferfunction (important, if you have negativ values)
Layer[] layers = nn.getLayers();
for(Layer curLayer: layers) {
for(Neuron curNeuron: curLayer.getNeurons()) {
curNeuron.setTransferFunction(new Tanh());
}
}
for(Neuron curNeuron: layers[3].getNeurons()) {
curNeuron.setTransferFunction(new Linear());
}
nn.randomizeWeights();
System.out.println("Load Sampledata...");
DataSet ds = DataSet.createFromFile(
"C:\\Users\\meist_000\\Documents\\Thesis\\vanilla_eng.csv",
3, 1, ";");
System.out.println("done: "+ds.getRows().size()+". Learn...");
// Setting stuff
BackPropagation lr = new BackPropagation();
lr.setLearningRate(LEARNING_RATE);
lr.setMaxIterations(MAX_ITER);
lr.setTrainingSet(ds);
lr.setNeuralNetwork(nn);
nn.setLearningRule(lr);
// bla.learn(ds); Faster bulk operation...
// Slower single operation with logging:
for(int i=0;i<MAX_ITER;i++) {
lr.doLearningEpoch(ds);
double curError = lr.getTotalNetworkError();
System.out.println(curError);
if(curError < MAX_ERROR) {
System.out.println("Stopped on "+i);
break;
}
}
// Testing the network
nn.setInput(new double[] {0.080484492, -0.138512128, -0.140826873});
nn.calculate();
double[] prediction = nn.getOutput();
System.out.println("Pred: "+prediction[0]);
}
}

The request to API call datastore_v3.Put() was too large without using datastore

com.google.apphosting.api.ApiProxy$RequestTooLargeException: The request to API call datastore_v3.Put() was too large.
public static List<Area> readAreas(URL url) {
List<Area> areas = new ArrayList<Area>();
try {
BufferedReader br = new BufferedReader(new FileReader(new File(url.toURI())));
String row;
while ((row = br.readLine()) != null) {
if (row.contains(SEARCHED_ROW)) {
//get the part after "c"
String coord[] = (row.split("c"));
String startCoordM = ((coord[0].trim()).split(" "))[1];
String curvesCoord= coord[1];
Area area = new Area();
area.mPoint= Point.toStartPoint(Point.readPoints(startCoordM));
area.curves = Curve.readCurves (curvesCoord);
areas.add(area);
}
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return areas;
}
This method runs without any errors but when I log out and log in to the same page of my web application this method runs again and again without problem but then this exception is thrown. I'm using google app engine 1.8.1 with jsf2 and primefaces 3.5. This method is invoked from managed bean :
public MapMB () {
eps = EPDAO.getEPList();
populateAdvancedModel(eps);
drawPolilines();
}
void drawPolilines() {
List<Area> areas = Area.readAreas(getFacesContext().getClass().getResource("/map-inksc.svg") );
for (Area area : areas) {
List<Curve> curves = area.getCurves();
Point endPoint = area.getmPoint();
Polyline polyline = new Polyline();
polyline.setStrokeWeight(1);
polyline.setStrokeColor("#FF0000");
polyline.setStrokeOpacity(1);
for (Curve curve : curves) {
polyline.getPaths().add( new LatLng(endPoint.getY(),endPoint.getX()) );
// curve start point is the end point of previous curve (endPoint.getX(),endPoint.getY() )
double step = 0.01;
for (double t=0;t<= 1;t=t+step) {
double x = getCoordFromCurve(endPoint.getX(), endPoint.getX() + curve.getP1().getX(),endPoint.getX() + curve.getP2().getX(),endPoint.getX() + curve.getP3().getX(), t);
double y = getCoordFromCurve(endPoint.getY(), endPoint.getY() + curve.getP1().getY(),endPoint.getY() + curve.getP2().getY(),endPoint.getY() + curve.getP3().getY(), t);
polyline.getPaths().add( new LatLng(y, x) );
}
endPoint = new Point (endPoint.getX() + curve.getP3().getX(), endPoint.getY() + curve.getP3().getY());
}
advancedModel.addOverlay(polyline);
polyline = new Polyline();
}
}
When I don't read any data (don't use readAreas() above) then everything works fine. So how reading from file is connected to this error? I don't understand.
If there is some information that I didn't put here please just say. All these methods run without errors and then this exception is thrown
See the edit
Ok. So ... somehow the problem is solved. How? I'm not sure. So I had:
a.xhtml < include b.xhtml
c.xhtml < include b.xhtml
a.xhtml and c.xhtml had the same method bFilterMethod()
JSF beans:
a, b, c all ViewScoped
b had a and c as Managed Properties
a.xhtml and c.xhtml have bFilterMethod() that getsSome() data from the database and sets aProperty and cProperty(which are the same). I saw in google app engine logs that the method getsSome() runs about 20 times like infinite loop after that the exception was thrown.
Now all beans are request scoped
a.xhtml has aFilterMethod that getsSome() data
b.xhtml has bFilterMethod that getsSome() data
and a and b has c as Managed Property
Hope this helps someone but as I sad I'm not sure what is the exact error but obviously is caused by too big request from the database no matter this request contains only 3 rows (this request is invoked too many times)
EDIT
After so many years I came back to my topic accidentally. The real reason for all this is that GAE saves the session in the datastore and jsf ViewScoped beans are not removed from the session as in normal java application server. So the solution is just don't use ViewScoped beans

WP7 Silverlight/XNA split

I want to make an app that has Silverlight menus but the game part of the app is XNA. I am trying to get the Silverlight/XNA split working using the code from this example game and the method of doing XNA rendering in Silverlight here. Combining these 2 tutorials I have source code that looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;
using Microsoft.Phone.Controls;
using System.Windows.Navigation;
namespace FYP
{
public partial class GamePage : PhoneApplicationPage
{
GameTimer timer;
SpriteBatch spriteBatch;
Texture2D ballTexture;
IList<Ball> balls = new List<Ball>();
bool touching = false;
public GamePage(ContentManager contentManager)
{
InitializeComponent();
//base.Initialize();
// Create a timer for this page
timer = new GameTimer();
timer.UpdateInterval = TimeSpan.FromTicks(333333);
//timer.Update += OnUpdate;
//timer.Draw += OnDraw;
// TODO: use this.Content to load your game content here
ballTexture = contentManager.Load<Texture2D>("Ball");
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// Set the sharing mode of the graphics device to turn on XNA rendering
SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);
timer.Start();
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
// Set the sharing mode of the graphics device to turn off XNA rendering
SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(false);
// Stop the timer
timer.Stop();
}
private void OnUpdate(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
//this.Exit();
// TODO: Add your update logic here
//base.Update(gameTime);
HandleTouches();
UpdateBalls();
}
private void OnDraw(GameTime gameTime)
{
SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.White);
// TODO: Add your drawing code here
foreach (Ball ball in balls)
{
ball.Draw(spriteBatch);
}
//base.Draw(gameTime);
}
private void HandleTouches()
{
TouchCollection touches = TouchPanel.GetState();
if (!touching && touches.Count > 0)
{
touching = true;
Random random = new Random(DateTime.Now.Millisecond);
Color ballColor = new Color(random.Next(255), random.Next(255), random.Next(255));
Vector2 velocity = new Vector2((random.NextDouble() > .5 ? -1 : 1) * random.Next(9), (random.NextDouble() > .5 ? -1 : 1) * random.Next(9)) + Vector2.UnitX + Vector2.UnitY;
//Vector2 center = new Vector2((float)SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Width / 2, (float)SharedGraphicsDeviceManager.Current.GraphicsDevice.Height / 2);
Vector2 center = new Vector2((float)SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Width / 2, 200);
float radius = 25f * (float)random.NextDouble() + 5f;
balls.Add(new Ball(this, ballColor, ballTexture, center, velocity, radius));
}
else if (touches.Count == 0)
{
touching = false;
}
}
private void UpdateBalls()
{
foreach (Ball ball in balls)
{
ball.Update();
}
}
}
}
I do not understand how base works, I've had to comment out base.initialize, update and draw however base.OnNavigatedFrom works.
Also, should I be able to get my code to work in theory? I find it very complicated and although reading about XNA/Silverlight to be possible I can't find any source code where people have successfully combined XNA and Silverlight into the same app.
these videos will help you out to understand XNA and SilverLight/XNA combined platform
http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-11a-XNA-for-Windows-Phone--Part-1
http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-11b-XNA-for-Windows-Phone--Part-2
Theoretically XNA and SilverLight XNA Combined platform are pretty much the same, just a difference of bits and pieces, You can even ask XNA to render some SilverLight Control, which will make it easier to handle some button event in your game.
Hope this helps

BlackBerry Curve not enough storage exception

I have an application that downloads a video file that is roughly 6mb
I am trying to run this application on a Blackberry Curve 9360, which has 32mb of "media" storage
Sometimes this application runs and is able to download the video with no problems, however other times part way thru downloading the download process fails with an IO exception that states: "There is not enough free memory on the file system to complete this action"
after it fails in this manner I can open up the BlackBerry Desktop software and check the files section and see that the device is indeed reporting that 32/32 mb are full.
If I then restart the device with alt-shift-del and open up blackberry desktop software again the used space has shrunk back down to only 5-6 / 32mb full
Sometimes at this point I am able to run my application now and have it succeed the download, but other times it again gives me the same storage full error. The only thing I can notice that seems like it might be affecting whether or not it fails is how long the download takes total (i.e. it succeeds on wifi, and on good 3g signal and fails on poorer 3g signal, but this is anecdotal at best)
I have used this exact same application on a few different blackberry devices, including a few other Curve devices with the same storage size, and never run into this problem before.
My question is: Has anyone seen a BlackBerry curve device behave in such a way that it will report an incorrect storage space that gets fixed by a reboot?
And is there anything about this download code that could be causing this behavior?
class DownloadThread extends Thread {
public void run()
{
HttpConnection httpConn = null;
InputStream is = null;
try{
httpConn = (HttpConnection)Connector.open(videoUrl + ";interface=wifi");
is = httpConn.openInputStream();
}catch(IOException e){
try{
httpConn = (HttpConnection)Connector.open(videoUrl);
is = httpConn.openInputStream();
}catch(IOException ioe){
System.out.println("891: "+e.toString());
}
}
try{
if (!videoFconn.exists())
videoFconn.create();
else{
videoFconn.delete();
videoFconn.create();
}
OutputStream os = videoFconn.openOutputStream();
lengthOfWebFile = httpConn.getLength();
total = 0;
System.out.println("##################### length of web file = " + lengthOfWebFile + " #################");
byte data[] = new byte[256];
while ((count = is.read(data)) != -1) {
total += count;
progress = (int)(total*100/lengthOfWebFile);
if(model.getValue() < progress){
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
EmbeddedMediaScreen.this.model.setValue(progress);
}
});
}
//write this chunk
os.write(data, 0, count);
Thread.yield();
}
os.flush();
os.close();
is.close();
httpConn.close();
lengthOfLocalFile = videoFconn.fileSize();
System.out.println("###################### Local Length = " + lengthOfLocalFile + "#####################");
if(lengthOfLocalFile == lengthOfWebFile){
amDownloading = false;
startVideo();
}else{
downloadVideo();
}
}catch(FileNotFoundException fnf){
}catch(IOException e){
//ScreenSaverActivity.errorDialog("975: "+e.toString());
System.out.println("980: "+e.toString());
//e.printStackTrace();
}catch(NullPointerException npe){
System.out.println("983: "+npe.toString());
} /*catch (InterruptedException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
}*/
}
public synchronized void postProgress(final int p){
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
//Set the progress bar
EmbeddedMediaScreen.this.model.setValue(p);
}
});
}
}

Issues with XPSDocumentWriter and PrintDialog.PrintDocument

Our company is developing an application (WPF, targeted to .NET 3.5) with the WPF Diagramming Components from MindFusion.Apparently, printing and saving XPS Documents results in various errors on different systems.
I reduced the problem to a single sample XPS Document created from our application.I'll first give an overview of the concerned systems and break down the issues when respectively saving an xps document and printing the diagram visual using the new WPF Printing Path in the following list:
Note: All three systems have Windows XP SP3 with .NET 3.5 Framework SP1 installed.
Using the XpsDocumentWriter to write a XPS document with the Paginator:
PC 1 - The XPS Viewer (working with IE 7.0) doesn’t work (even after reinstall of .Net 3.5). XPS Viewer from the Essential Pack opens the document, but the view is completely blurred. But as you can see, our application on the right side of the screenshot uses a DocumentViewer to test this issue, which works correctly. Printing from the corrupted XPS Viewer results in the same output as on screen, while printing from the integrated print function in the DocumentViewer ( without intervention from our application) gives a blurry output which is a little more readable, but still not acceptable.
PC 2 - The IE XPS Viewer works correctly. The print ouput is inconsistent. Sometimes, the graphics (Shapes) are not complete, or the printing device notifies about lack of memory (with the same document).
PC 3 – The IE XPS Viewer works correctly, but initiating a print job always leads to this exception within IE itself.
Note: All heretofore mentioned issues have been tested with the XPS Document (already mentioned above) created by our application.
Creating a print job with PrintDialog.PrintDocument and the Paginator:
Printing from our application gives a consistent output with all system: the bigger the document (speaking in term of the page media size), the more blurry it gets. Unfortunately, a lot of potential causes have been already omitted.
The code for printing the document is fairly simple.
• Instead of using our own Paginator, I replaced the latter with another Paginator part of the MindFusion WPF Diagraming Components we use. I achieved the same result. (This statement is also true for XPSDocuments saved as file).
• I used the latest print driver available
• Changes to PrintTicket Resolution doesn’t seem to affect the ouput in any way
• Using another Visual instead of a diagram (like the Window of our Application itself) doesn’t affect the output
Due to these various issues, it seems that multiple causes are also probable. The previous exclusions lead me to assume that some crucial settings are missing in the PrintTicket, or something terribly wrong happens with the XPS to GDI Conversion behnd scenes. Apart from these assumptions, I'm running out of ideas.
Note: All print devices have non-XPS Drivers. HP Designjet 500, HP 2100
Last but not least, I serialised the same PrintTicket used for XPS Document file and the print job.
I would be thankful if anybody has experienced similar issues. Any suggestion is welcome.
I have currently working code but I am still having alignment issues. But print is not blurred I am giving you my code in hope that it may help you and we both could find a solution.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Documents;
using System.Windows;
using System.Windows.Media;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Controls;
using System.Data;
namespace VD
{
public class CustomPaginator : DocumentPaginator
{
private int _RowsPerPage;
private Size _PageSize;
private int _Rows;
public static DataTable dtToPrint;
public CustomPaginator()
{
}
public CustomPaginator(int rows, Size pageSize, DataTable dt)
{
_Rows = rows;
PageSize = pageSize;
dtToPrint = dt;
}
public override DocumentPage GetPage(int pageNumber)
{
int currentRow = _RowsPerPage * pageNumber;
var page = new PageElement(currentRow, Math.Min(_RowsPerPage, _Rows - currentRow))
{
Width = PageSize.Width,
Height = PageSize.Height,
};
page.Measure(PageSize);
page.Arrange(new Rect(new Point(0,0), PageSize));
return new DocumentPage(page);
}
public override bool IsPageCountValid
{ get { return true; } }
public override int PageCount
{ get { return (int)Math.Ceiling(_Rows / (double)_RowsPerPage); } }
public DataTable getDtProtols
{
get
{
return dtToPrint;
}
}
public override Size PageSize
{
get { return _PageSize; }
set
{
_PageSize = value;
_RowsPerPage = PageElement.RowsPerPage(PageSize.Height);
//Can't print anything if you can't fit a row on a page
Debug.Assert(_RowsPerPage > 0);
}
}
public override IDocumentPaginatorSource Source
{ get { return null; } }
}
public class PageElement : UserControl
{
private const int PageMargin = 75;
private const int HeaderHeight = 25;
private const int LineHeight = 20;
private const int ColumnWidth = 140;
private CustomPaginator objParent = new CustomPaginator();
private DataTable ProtocolsDT = null;
private int _CurrentRow;
private int _Rows;
public PageElement(int currentRow, int rows)
{
Margin = new Thickness(PageMargin);
_CurrentRow = currentRow;
_Rows = rows;
}
private static FormattedText MakeText(string text)
{
return new FormattedText(text, CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface("Tahoma"), 14, Brushes.Black);
}
public static int RowsPerPage(double height)
{
return (int)Math.Floor((height - (2 * PageMargin)
- HeaderHeight) / LineHeight);
}
protected override void OnRender(DrawingContext dc)
{
ProtocolsDT = objParent.getDtProtols;
Point curPoint = new Point(0, 0);
dc.DrawText(MakeText("Host Names"),curPoint );
curPoint.X += ColumnWidth;
for (int i = 1; i < ProtocolsDT.Columns.Count; i++)
{
dc.DrawText(MakeText(ProtocolsDT.Columns[i].ToString()), curPoint);
curPoint.X += ColumnWidth;
}
curPoint.X = 0;
curPoint.Y += LineHeight;
dc.DrawRectangle(Brushes.Black, null, new Rect(curPoint, new Size(Width, 2)));
curPoint.Y += HeaderHeight - LineHeight;
Random numberGen = new Random();
//for (int i = _CurrentRow; i < _CurrentRow + _Rows; i++)
//{
// dc.DrawText(MakeText(ProtocolsDT.Rows[i][0].ToString()), curPoint);
//curPoint.X += ColumnWidth;
for (int j = 0; j < ProtocolsDT.Rows.Count; j++)
{
for (int z = 0; z < ProtocolsDT.Rows[j].ItemArray.Length; z++)
{
dc.DrawText(MakeText(ProtocolsDT.Rows[j].ItemArray[z].ToString()), curPoint);
curPoint.X += ColumnWidth;
}
curPoint.Y += LineHeight;
curPoint.X = 0;
//dc.DrawText(MakeText(ProtocolsDT.Rows[j].ItemArray[1].ToString()), curPoint);
//curPoint.X += ColumnWidth;
//dc.DrawText(MakeText(ProtocolsDT.Rows[j].ItemArray[2].ToString()), curPoint);
//curPoint.X += ColumnWidth;
//}
//curPoint.Y += LineHeight;
//curPoint.X = 0;
}
}
}
}
Another Class
private void PrintDataTable(DataTable dt)
{
var printDialog = new PrintDialog();
if (printDialog.ShowDialog() == true)
{
var paginator = new CustomPaginator(dt.Rows.Count,
new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight),dt);
try
{
printDialog.PrintDocument(paginator, "Running Protocols Report");
}
catch (Exception ex)
{
MessageBox.Show(this, "Unable to print protocol information. Please check your printer settings.", "VD", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
}
}
}

Resources